My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
DataType.h
Go to the documentation of this file.
1 // $Id: DataType.h,v 1.1.1.1 2009/07/06 23:57:25 eml Exp $
2 
3 #ifndef GCP_UTIL_DATATYPE_H
4 #define GCP_UTIL_DATATYPE_H
5 
15 #include "gcp/control/code/unix/libunix_src/common/regmap.h"
16 
17 #include "gcp/util/common/Complex.h"
18 #include "gcp/util/common/RegDate.h"
19 #include <ostream>
20 
21 namespace gcp {
22  namespace util {
23 
27  class DataType {
28  public:
29 
30  enum Type {
31  NONE = 0x0,
32  UNKNOWN = 0x0,
33  UCHAR = 0x1,
34  CHAR = 0x2,
35  BOOL = 0x4,
36  USHORT = 0x8,
37  SHORT = 0x10,
38  UINT = 0x20,
39  INT = 0x40,
40  ULONG = 0x80,
41  LONG = 0x100,
42  FLOAT = 0x200,
43  DOUBLE = 0x400,
44  DATE = 0x800,
45  COMPLEX_FLOAT = 0x1000,
46  STRING = 0x2000
47  };
48 
49 
50  DataType();
51  DataType(bool b);
52  DataType(unsigned char uc);
53  DataType(char ch);
54  DataType(unsigned short us);
55  DataType(short s);
56  DataType(unsigned int ui);
57  DataType(int i);
58  DataType(unsigned long ul);
59  DataType(long l);
60  DataType(float f);
61  DataType(double d);
64 
65  virtual ~DataType();
66 
70  static unsigned sizeOf(Type type);
71 
76  static unsigned sizeOf(RegMapBlock* blk);
77 
81  static Type typeOf(RegMapBlock* blk);
82 
83  // Take the stored value and convert to the type corresponding
84  // to a register block
85 
86  void convertToTypeOf(RegMapBlock* blk);
87  double getValAsDouble();
88 
92  void operator=(bool b);
93  void operator=(unsigned char uc);
94  void operator=(char ch);
95  void operator=(unsigned short us);
96  void operator=(short s);
97  void operator=(unsigned int ui);
98  void operator=(int i);
99  void operator=(unsigned long ul);
100  void operator=(long l);
101  void operator=(float f);
102  void operator=(double d);
103  void operator=(gcp::util::RegDate date);
105 
109  void operator=(bool* b);
110  void operator=(unsigned char* uc);
111  void operator=(char* ch);
112  void operator=(unsigned short* us);
113  void operator=(short* s);
114  void operator=(unsigned int* ui);
115  void operator=(int* i);
116  void operator=(unsigned long* ul);
117  void operator=(long* l);
118  void operator=(float* f);
119  void operator=(double* d);
120  void operator=(gcp::util::RegDate* date);
122 
123  void operator=(DataType& dataType);
124  void operator=(const DataType& dataType);
125 
126  void operator-=(DataType& dataType);
127 
128  bool operator==(DataType& dataType);
129  bool operator>(DataType& dataType);
130  bool operator>=(DataType& dataType);
131  bool operator<(DataType& dataType);
132  bool operator<=(DataType& dataType);
133 
134  void operator++();
135 
136  void convertToAbs();
137 
138  friend std::ostream& operator<<(std::ostream& os, DataType& dataType);
139  friend std::ostream& operator<<(std::ostream& os, DataType::Type& type);
140 
144  void* data();
145 
146  // The actual data in this DataType will be stored as a union
147 
148  union {
149  bool b;
150  unsigned char uc;
151  char c;
152  unsigned short us;
153  short s;
154  unsigned int ui;
155  int i;
156  unsigned long ul;
157  long l;
158  float f;
159  double d;
162  } data_;
163 
164  Type type_;
165 
166  void checkType(DataType& dataType);
167 
168  // True if we are indexing an array of data
169 
170  bool isArray_;
171 
172  // A void ptr to the array
173 
174  void* ptr_;
175 
176  // Overloaded utility methods
177 
178  static Type typeOf(bool* obj);
179  static Type typeOf(unsigned char* obj);
180  static Type typeOf(char* obj);
181  static Type typeOf(unsigned short* obj);
182  static Type typeOf(short* obj);
183  static Type typeOf(unsigned int* obj);
184  static Type typeOf(int* obj);
185  static Type typeOf(unsigned long* obj);
186  static Type typeOf(long* obj);
187  static Type typeOf(float* obj);
188  static Type typeOf(double* obj);
189  static Type typeOf(gcp::util::RegDate* obj);
190  static Type typeOf(gcp::util::Complex<float>* obj);
191  static Type typeOf(gcp::util::RegDate::Data* obj);
192  static Type typeOf(gcp::util::Complex<float>::Data* obj);
193 
194  }; // End class DataType
195 
196  } // End namespace util
197 } // End namespace gcp
198 
199 
200 
201 
202 #endif // End #ifndef GCP_UTIL_DATATYPE_H
static Type typeOf(RegMapBlock *blk)
Definition: DataType.cc:223
static unsigned sizeOf(Type type)
Definition: DataType.cc:145
Definition: RegDate.h:22
Definition: Complex.h:48
virtual ~DataType()
Definition: DataType.cc:17
Definition: RegDate.h:19
Definition: DataType.h:27
DataType()
Definition: DataType.cc:12
void operator=(bool b)
Definition: DataType.cc:267
void * data()
Definition: DataType.cc:906
void operator++()
Definition: DataType.cc:958