Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/DataSource/StringDataSource.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  *
00007  * Visit http://people.web.psi.ch/adelmann/ for more details
00008  *
00009  ***************************************************************************/
00010 
00011 #ifndef STRING_DATA_SOURCE_H
00012 #define STRING_DATA_SOURCE_H
00013 
00014 /***********************************************************************
00015  * 
00016  * StringDataSource is a DataSource for strings.
00017  * It makes a string available for another program or data processing 
00018  * API (e.g., visualization) through the DataSource API. 
00019  *
00020 ***********************************************************************/
00021 
00022 // include files
00023 #include "DataSource/DataSource.h"
00024 
00025 // forward declarations
00026 class DataSourceObject;
00027 class DataConnect;
00028 
00029 
00030 // A DataSource class for handling strings
00031 // A string can be a char* (T=char) or std::string (T=string)
00032 template <class T>
00033 class StringDataSource : public DataSource {
00034 
00035 public:
00036   // constructor
00037   StringDataSource(T* S, int mlen) : MyString(S), StringLen(mlen) {}; 
00038 
00039   // destructor
00040   virtual ~StringDataSource() { }
00041 
00042   // Return ptr to Scalar
00043   T *stringPtr() { return MyString; }
00044   const T *stringPtr() const { return MyString; }
00045   
00046   // Return max length of string
00047   int stringLen() const { return StringLen; }
00048 
00049 protected:
00050   // a virtual function which is called by this base class to get a
00051   // specific instance of DataSourceObject based on the type of data
00052   // and the connection method (the argument to the call).
00053   virtual DataSourceObject *createDataSourceObject(const char *,
00054                                                    DataConnect *,
00055                                                    int);
00056 
00057 private:
00058   // The string
00059   T* MyString;
00060   int StringLen;
00061 };
00062 
00063 #include "DataSource/StringDataSource.cpp"
00064 
00065 #endif // STRING_DATA_SOURCE_H
00066 
00067 /***************************************************************************
00068  * $RCSfile: StringDataSource.h,v $   $Author: adelmann $
00069  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:25 $
00070  * IPPL_VERSION_ID: $Id: StringDataSource.h,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $ 
00071  ***************************************************************************/

Generated on Fri Nov 2 01:25:55 2007 for IPPL by doxygen 1.3.5