| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

DataTypeInfo.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATATYPES_H
2 #define GAUDIKERNEL_DATATYPES_H
3
4 #include <string>
5 #include <cstring>
6 #include "GaudiKernel/SmartRef.h"
7
8 class DataObject;
9 class ContainedObject;
10 class IOpaqueAddress;
11
16 class GAUDI_API DataTypeInfo {
17 private:
18 // This object cannot be instantiated!
19 DataTypeInfo() {}
20 public:
21 // Accepted Data type definitions
22 enum Type {
23 UNKNOWN = 0,
24 UCHAR, USHORT, UINT, ULONG,
25 CHAR, SHORT, INT, LONG,
26 BOOL, FLOAT, DOUBLE,
27 STRING, NTCHAR,
28 OBJECT_REF, CONTAINED_REF, POINTER, OBJECT_ADDR,
29 LONG_STRING, LONG_NTCHAR, LONGLONG, ULONGLONG
30 };
32 static Type ID( const bool) { return BOOL; }
34 static Type ID( const char) { return CHAR; }
36 static Type ID( const short) { return SHORT; }
38 static Type ID( const int) { return INT; }
40 static Type ID( const long) { return LONG; }
42 static Type ID( const long long) { return LONGLONG; }
44 static Type ID( const unsigned char) { return UCHAR; }
46 static Type ID( const unsigned short) { return USHORT; }
48 static Type ID( const unsigned int) { return UINT; }
50 static Type ID( const unsigned long) { return ULONG; }
52 static Type ID( const unsigned long long) { return ULONGLONG; }
54 static Type ID( const float) { return FLOAT; }
56 static Type ID( const double) { return DOUBLE; }
58 static Type ID( const std::string&) { return STRING; }
60 static Type ID( const char*) { return NTCHAR; }
62 static Type ID( const IOpaqueAddress*) { return OBJECT_ADDR; }
64 static Type ID( const void*) { return POINTER; }
66 static Type ID( const SmartRef<DataObject>&) { return OBJECT_REF; }
68 static Type ID( const SmartRef<ContainedObject>&) { return CONTAINED_REF; }
69
71 static Type ID( const std::type_info& typ ) {
72 if ( typ == typeid(unsigned char) )
73 return UCHAR;
74 else if ( typ == typeid(unsigned short) )
75 return USHORT;
76 else if ( typ == typeid(unsigned int) )
77 return UINT;
78 else if ( typ == typeid(unsigned long) )
79 return ULONG;
80 else if ( typ == typeid(unsigned long long) )
81 return ULONGLONG;
82 else if ( typ == typeid(char) )
83 return CHAR;
84 else if ( typ == typeid(short) )
85 return SHORT;
86 else if ( typ == typeid(int) )
87 return INT;
88 else if ( typ == typeid(long) )
89 return LONG;
90 else if ( typ == typeid(long long) )
91 return LONGLONG;
92 else if ( typ == typeid(bool) )
93 return BOOL;
94 else if ( typ == typeid(float) )
95 return FLOAT;
96 else if ( typ == typeid(double) )
97 return DOUBLE;
98 else if ( typ == typeid(std::string) )
99 return STRING;
100 else if ( typ == typeid(char*) )
101 return NTCHAR;
102 else if ( typ == typeid(SmartRef<DataObject>) )
103 return OBJECT_REF;
104 else if ( typ == typeid(SmartRef<ContainedObject>) )
105 return CONTAINED_REF;
106 else if ( typ == typeid(IOpaqueAddress*) )
107 return OBJECT_ADDR;
108 else if ( typ == typeid(void*) )
109 return POINTER;
110 else
111 return UNKNOWN;
112 }
113
115 static const std::type_info& type( long typ ) {
116 switch(typ) {
117 case UCHAR:
118 return typeid(unsigned char);
119 case USHORT:
120 return typeid(unsigned short);
121 case UINT:
122 return typeid(unsigned int);
123 case ULONG:
124 return typeid(unsigned long);
125 case ULONGLONG:
126 return typeid(unsigned long long);
127 case CHAR:
128 return typeid(char);
129 case SHORT:
130 return typeid(short);
131 case INT:
132 return typeid(int);
133 case LONG:
134 return typeid(long);
135 case LONGLONG:
136 return typeid(long long);
137 case BOOL:
138 return typeid(bool);
139 case FLOAT:
140 return typeid(float);
141 case DOUBLE:
142 return typeid(double);
143 case LONG_STRING:
144 return typeid(std::string);
145 case STRING:
146 return typeid(std::string);
147 case NTCHAR:
148 return typeid(char*);
149 case LONG_NTCHAR:
150 return typeid(char*);
151 case OBJECT_REF:
152 return typeid(SmartRef<DataObject>);
153 case CONTAINED_REF:
154 return typeid(SmartRef<ContainedObject>);
155 case OBJECT_ADDR:
156 return typeid(IOpaqueAddress*);
157 case POINTER:
158 case UNKNOWN:
159 default:
160 return typeid(void*);
161 }
162 }
163
165 static long size( long typ ) {
166 switch(typ) {
167 case UCHAR:
168 return sizeof(unsigned char);
169 case USHORT:
170 return sizeof(unsigned short);
171 case UINT:
172 return sizeof(unsigned int);
173 case ULONG:
174 return sizeof(unsigned long);
175 case ULONGLONG:
176 return sizeof(unsigned long long);
177 case CHAR:
178 return sizeof(char);
179 case SHORT:
180 return sizeof(short);
181 case INT:
182 return sizeof(int);
183 case LONG:
184 return sizeof(long);
185 case LONGLONG:
186 return sizeof(long long);
187 case BOOL:
188 return sizeof(bool);
189 case FLOAT:
190 return sizeof(float);
191 case DOUBLE:
192 return sizeof(double);
193 case STRING:
194 return sizeof(std::string);
195 case LONG_STRING:
196 return sizeof(std::string);
197 case NTCHAR:
198 return sizeof(char*);
199 case LONG_NTCHAR:
200 return sizeof(char*);
201 case OBJECT_ADDR:
202 case POINTER:
203 case OBJECT_REF:
204 case CONTAINED_REF:
205 case UNKNOWN:
206 default:
207 return 0;
208 }
209 }
210
212 static long size( const std::type_info& typ ) {
213 return size( ID(typ) );
214 }
215
217 static int copy( void* tar, const void* src, long typ, int numObj ) {
218 switch(typ) {
219 case UCHAR: numObj *= sizeof(unsigned char); break;
220 case USHORT: numObj *= sizeof(unsigned short); break;
221 case UINT: numObj *= sizeof(unsigned int); break;
222 case ULONG: numObj *= sizeof(unsigned long); break;
223 case ULONGLONG: numObj *= sizeof(unsigned long long); break;
224 case CHAR: numObj *= sizeof(char); break;
225 case SHORT: numObj *= sizeof(short); break;
226 case INT: numObj *= sizeof(int); break;
227 case LONG: numObj *= sizeof(long); break;
228 case LONGLONG: numObj *= sizeof(long long); break;
229 case BOOL: numObj *= sizeof(bool); break;
230 case FLOAT: numObj *= sizeof(float); break;
231 case DOUBLE: numObj *= sizeof(double); break;
232 case UNKNOWN:
233 default: numObj *= 0; break;
234 }
235 memcpy(tar, src, numObj);
236 return numObj;
237 }
238
239 // Access the type name by type ID
240 static std::string name(long typ);
241 // Access the type name by type_info
242 static std::string name(const std::type_info& typ);
244 static Type idByName( const std::string& typ );
246 static const std::type_info& typeByName( const std::string& typ );
247 };
248 #endif // GAUDIKERNEL_DATATYPES_H
DataTypeInfo::POINTER
Definition: DataTypeInfo.h:28
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
DataTypeInfo::ID
static Type ID(const long)
Access to type information: long.
Definition: DataTypeInfo.h:40
DataTypeInfo::ID
static Type ID(const unsigned long)
Access to type information: unsigned long.
Definition: DataTypeInfo.h:50
DataTypeInfo::ID
static Type ID(const bool)
Access to type information: bool.
Definition: DataTypeInfo.h:32
DataTypeInfo::ID
static Type ID(const int)
Access to type information: int.
Definition: DataTypeInfo.h:38
DataTypeInfo::ID
static Type ID(const unsigned int)
Access to type information: unsigned int.
Definition: DataTypeInfo.h:48
SmartRef< DataObject >
DataTypeInfo::STRING
Definition: DataTypeInfo.h:27
DataTypeInfo::SHORT
Definition: DataTypeInfo.h:25
DataTypeInfo::ID
static Type ID(const short)
Access to type information: short.
Definition: DataTypeInfo.h:36
std::type_info
std::string
STL class.
DataTypeInfo::ID
static Type ID(const unsigned char)
Access to type information: unsigned char.
Definition: DataTypeInfo.h:44
DataTypeInfo::USHORT
Definition: DataTypeInfo.h:24
DataTypeInfo::ID
static Type ID(const SmartRef< ContainedObject > &)
Access to type information: Contained object.
Definition: DataTypeInfo.h:68
DataTypeInfo::Type
Type
Definition: DataTypeInfo.h:22
DataTypeInfo::ID
static Type ID(const char *)
Access to type information: char* (NULL terminated)
Definition: DataTypeInfo.h:60
DataTypeInfo::ID
static Type ID(const IOpaqueAddress *)
Access to type information: IOpaqueAddress.
Definition: DataTypeInfo.h:62
DataTypeInfo::ID
static Type ID(const unsigned long long)
Access to type information: unsigned long long.
Definition: DataTypeInfo.h:52
DataTypeInfo::DataTypeInfo
DataTypeInfo()
Definition: DataTypeInfo.h:19
DataTypeInfo::ID
static Type ID(const float)
Access to type information: float.
Definition: DataTypeInfo.h:54
DataTypeInfo::type
static const std::type_info & type(long typ)
Access to type information: the reverse way.
Definition: DataTypeInfo.h:115
ContainedObject
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
Definition: ContainedObject.h:29
DataTypeInfo::size
static long size(long typ)
Access to type information: the reverse way.
Definition: DataTypeInfo.h:165
DataTypeInfo::ID
static Type ID(const long long)
Access to type information: long long.
Definition: DataTypeInfo.h:42
DataTypeInfo::copy
static int copy(void *tar, const void *src, long typ, int numObj)
Copy data.
Definition: DataTypeInfo.h:217
SmartRef.h
DataTypeInfo::ID
static Type ID(const char)
Access to type information: char.
Definition: DataTypeInfo.h:34
DataTypeInfo::ID
static Type ID(const unsigned short)
Access to type information: unsigned short.
Definition: DataTypeInfo.h:46
DataTypeInfo::ID
static Type ID(const SmartRef< DataObject > &)
Access to type information: DataObject.
Definition: DataTypeInfo.h:66
DataTypeInfo::ID
static Type ID(const std::string &)
Access to type information: std::string.
Definition: DataTypeInfo.h:58
DataTypeInfo::FLOAT
Definition: DataTypeInfo.h:26
Io::UNKNOWN
Definition: IFileMgr.h:151
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
DataTypeInfo::size
static long size(const std::type_info &typ)
Access to type information: the reverse way.
Definition: DataTypeInfo.h:212
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
DataTypeInfo::ID
static Type ID(const void *)
Access to type information: Pointers.
Definition: DataTypeInfo.h:64
DataTypeInfo
Small class which allows access to internal type IDs.
Definition: DataTypeInfo.h:16
DataTypeInfo::ID
static Type ID(const std::type_info &typ)
Access to type information: the reverse way.
Definition: DataTypeInfo.h:71
DataTypeInfo::ID
static Type ID(const double)
Access to type information: float.
Definition: DataTypeInfo.h:56