OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
StringDataSource.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef STRING_DATA_SOURCE_H
12 #define STRING_DATA_SOURCE_H
13 
14 /***********************************************************************
15  *
16  * StringDataSource is a DataSource for strings.
17  * It makes a string available for another program or data processing
18  * API (e.g., visualization) through the DataSource API.
19  *
20 ***********************************************************************/
21 
22 // include files
23 #include "DataSource/DataSource.h"
24 
25 // forward declarations
26 class DataSourceObject;
27 class DataConnect;
28 
29 
30 // A DataSource class for handling strings
31 // A string can be a char* (T=char) or std::string (T=string)
32 template <class T>
33 class StringDataSource : public DataSource {
34 
35 public:
36  // constructor
37  StringDataSource(T* S, int mlen) : MyString(S), StringLen(mlen) {};
38 
39  // destructor
40  virtual ~StringDataSource() { }
41 
42  // Return ptr to Scalar
43  T *stringPtr() { return MyString; }
44  const T *stringPtr() const { return MyString; }
45 
46  // Return max length of string
47  int stringLen() const { return StringLen; }
48 
49 protected:
50  // a virtual function which is called by this base class to get a
51  // specific instance of DataSourceObject based on the type of data
52  // and the connection method (the argument to the call).
53  virtual DataSourceObject *createDataSourceObject(const char *,
54  DataConnect *,
55  int);
56 
57 private:
58  // The string
60  int StringLen;
61 };
62 
64 
65 #endif // STRING_DATA_SOURCE_H
66 
67 /***************************************************************************
68  * $RCSfile: StringDataSource.h,v $ $Author: adelmann $
69  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:25 $
70  * IPPL_VERSION_ID: $Id: StringDataSource.h,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $
71  ***************************************************************************/
int stringLen() const
Definition: rbendmap.h:8
const T * stringPtr() const
virtual DataSourceObject * createDataSourceObject(const char *, DataConnect *, int)
StringDataSource(T *S, int mlen)
virtual ~StringDataSource()