| The Gaudi Framework v29r1 (5cd95fa2)

- 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 "GaudiKernel/SmartRef.h"
5 #include <cstring>
6 #include <string>
7
8 class DataObject;
9 class ContainedObject;
10 class IOpaqueAddress;
11
16 class GAUDI_API DataTypeInfo
17 {
18 private:
19 // This object cannot be instantiated!
20 DataTypeInfo() {}
21
22 public:
23 // Accepted Data type definitions
24 enum Type {
25 UNKNOWN = 0,
26 UCHAR,
27 USHORT,
28 UINT,
29 ULONG,
30 CHAR,
31 SHORT,
32 INT,
33 LONG,
34 BOOL,
35 FLOAT,
36 DOUBLE,
37 STRING,
38 NTCHAR,
39 OBJECT_REF,
40 CONTAINED_REF,
41 POINTER,
42 OBJECT_ADDR,
43 LONG_STRING,
44 LONG_NTCHAR,
45 LONGLONG,
46 ULONGLONG
47 };
49 static Type ID( const bool ) { return BOOL; }
51 static Type ID( const char ) { return CHAR; }
53 static Type ID( const short ) { return SHORT; }
55 static Type ID( const int ) { return INT; }
57 static Type ID( const long ) { return LONG; }
59 static Type ID( const long long ) { return LONGLONG; }
61 static Type ID( const unsigned char ) { return UCHAR; }
63 static Type ID( const unsigned short ) { return USHORT; }
65 static Type ID( const unsigned int ) { return UINT; }
67 static Type ID( const unsigned long ) { return ULONG; }
69 static Type ID( const unsigned long long ) { return ULONGLONG; }
71 static Type ID( const float ) { return FLOAT; }
73 static Type ID( const double ) { return DOUBLE; }
75 static Type ID( const std::string& ) { return STRING; }
77 static Type ID( const char* ) { return NTCHAR; }
79 static Type ID( const IOpaqueAddress* ) { return OBJECT_ADDR; }
81 static Type ID( const void* ) { return POINTER; }
83 static Type ID( const SmartRef<DataObject>& ) { return OBJECT_REF; }
85 static Type ID( const SmartRef<ContainedObject>& ) { return CONTAINED_REF; }
86
88 static Type ID( const std::type_info& typ )
89 {
90 if ( typ == typeid( unsigned char ) )
91 return UCHAR;
92 else if ( typ == typeid( unsigned short ) )
93 return USHORT;
94 else if ( typ == typeid( unsigned int ) )
95 return UINT;
96 else if ( typ == typeid( unsigned long ) )
97 return ULONG;
98 else if ( typ == typeid( unsigned long long ) )
99 return ULONGLONG;
100 else if ( typ == typeid( char ) )
101 return CHAR;
102 else if ( typ == typeid( short ) )
103 return SHORT;
104 else if ( typ == typeid( int ) )
105 return INT;
106 else if ( typ == typeid( long ) )
107 return LONG;
108 else if ( typ == typeid( long long ) )
109 return LONGLONG;
110 else if ( typ == typeid( bool ) )
111 return BOOL;
112 else if ( typ == typeid( float ) )
113 return FLOAT;
114 else if ( typ == typeid( double ) )
115 return DOUBLE;
116 else if ( typ == typeid( std::string ) )
117 return STRING;
118 else if ( typ == typeid( char* ) )
119 return NTCHAR;
120 else if ( typ == typeid( SmartRef<DataObject> ) )
121 return OBJECT_REF;
122 else if ( typ == typeid( SmartRef<ContainedObject> ) )
123 return CONTAINED_REF;
124 else if ( typ == typeid( IOpaqueAddress* ) )
125 return OBJECT_ADDR;
126 else if ( typ == typeid( void* ) )
127 return POINTER;
128 else
129 return UNKNOWN;
130 }
131
133 static const std::type_info& type( long typ )
134 {
135 switch ( typ ) {
136 case UCHAR:
137 return typeid( unsigned char );
138 case USHORT:
139 return typeid( unsigned short );
140 case UINT:
141 return typeid( unsigned int );
142 case ULONG:
143 return typeid( unsigned long );
144 case ULONGLONG:
145 return typeid( unsigned long long );
146 case CHAR:
147 return typeid( char );
148 case SHORT:
149 return typeid( short );
150 case INT:
151 return typeid( int );
152 case LONG:
153 return typeid( long );
154 case LONGLONG:
155 return typeid( long long );
156 case BOOL:
157 return typeid( bool );
158 case FLOAT:
159 return typeid( float );
160 case DOUBLE:
161 return typeid( double );
162 case LONG_STRING:
163 return typeid( std::string );
164 case STRING:
165 return typeid( std::string );
166 case NTCHAR:
167 return typeid( char* );
168 case LONG_NTCHAR:
169 return typeid( char* );
170 case OBJECT_REF:
171 return typeid( SmartRef<DataObject> );
172 case CONTAINED_REF:
173 return typeid( SmartRef<ContainedObject> );
174 case OBJECT_ADDR:
175 return typeid( IOpaqueAddress* );
176 case POINTER:
177 case UNKNOWN:
178 default:
179 return typeid( void* );
180 }
181 }
182
184 static long size( long typ )
185 {
186 switch ( typ ) {
187 case UCHAR:
188 return sizeof( unsigned char );
189 case USHORT:
190 return sizeof( unsigned short );
191 case UINT:
192 return sizeof( unsigned int );
193 case ULONG:
194 return sizeof( unsigned long );
195 case ULONGLONG:
196 return sizeof( unsigned long long );
197 case CHAR:
198 return sizeof( char );
199 case SHORT:
200 return sizeof( short );
201 case INT:
202 return sizeof( int );
203 case LONG:
204 return sizeof( long );
205 case LONGLONG:
206 return sizeof( long long );
207 case BOOL:
208 return sizeof( bool );
209 case FLOAT:
210 return sizeof( float );
211 case DOUBLE:
212 return sizeof( double );
213 case STRING:
214 return sizeof( std::string );
215 case LONG_STRING:
216 return sizeof( std::string );
217 case NTCHAR:
218 return sizeof( char* );
219 case LONG_NTCHAR:
220 return sizeof( char* );
221 case OBJECT_ADDR:
222 case POINTER:
223 case OBJECT_REF:
224 case CONTAINED_REF:
225 case UNKNOWN:
226 default:
227 return 0;
228 }
229 }
230
232 static long size( const std::type_info& typ ) { return size( ID( typ ) ); }
233
235 static int copy( void* tar, const void* src, long typ, int numObj )
236 {
237 switch ( typ ) {
238 case UCHAR:
239 numObj *= sizeof( unsigned char );
240 break;
241 case USHORT:
242 numObj *= sizeof( unsigned short );
243 break;
244 case UINT:
245 numObj *= sizeof( unsigned int );
246 break;
247 case ULONG:
248 numObj *= sizeof( unsigned long );
249 break;
250 case ULONGLONG:
251 numObj *= sizeof( unsigned long long );
252 break;
253 case CHAR:
254 numObj *= sizeof( char );
255 break;
256 case SHORT:
257 numObj *= sizeof( short );
258 break;
259 case INT:
260 numObj *= sizeof( int );
261 break;
262 case LONG:
263 numObj *= sizeof( long );
264 break;
265 case LONGLONG:
266 numObj *= sizeof( long long );
267 break;
268 case BOOL:
269 numObj *= sizeof( bool );
270 break;
271 case FLOAT:
272 numObj *= sizeof( float );
273 break;
274 case DOUBLE:
275 numObj *= sizeof( double );
276 break;
277 case UNKNOWN:
278 default:
279 numObj *= 0;
280 break;
281 }
282 memcpy( tar, src, numObj );
283 return numObj;
284 }
285
286 // Access the type name by type ID
287 static std::string name( long typ );
288 // Access the type name by type_info
289 static std::string name( const std::type_info& typ );
291 static Type idByName( const std::string& typ );
293 static const std::type_info& typeByName( const std::string& typ );
294 };
295 #endif // GAUDIKERNEL_DATATYPES_H
DataTypeInfo::OBJECT_REF
Definition: DataTypeInfo.h:39
DataTypeInfo::POINTER
Definition: DataTypeInfo.h:41
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
DataTypeInfo::INT
Definition: DataTypeInfo.h:32
DataTypeInfo::ID
static Type ID(const long)
Access to type information: long.
Definition: DataTypeInfo.h:57
DataTypeInfo::ID
static Type ID(const unsigned long)
Access to type information: unsigned long.
Definition: DataTypeInfo.h:67
DataTypeInfo::ID
static Type ID(const bool)
Access to type information: bool.
Definition: DataTypeInfo.h:49
DataTypeInfo::CHAR
Definition: DataTypeInfo.h:30
DataTypeInfo::ID
static Type ID(const int)
Access to type information: int.
Definition: DataTypeInfo.h:55
DataTypeInfo::ID
static Type ID(const unsigned int)
Access to type information: unsigned int.
Definition: DataTypeInfo.h:65
SmartRef< DataObject >
DataTypeInfo::STRING
Definition: DataTypeInfo.h:37
DataTypeInfo::SHORT
Definition: DataTypeInfo.h:31
DataTypeInfo::NTCHAR
Definition: DataTypeInfo.h:38
DataTypeInfo::ID
static Type ID(const short)
Access to type information: short.
Definition: DataTypeInfo.h:53
std::type_info
std::string
STL class.
DataTypeInfo::ID
static Type ID(const unsigned char)
Access to type information: unsigned char.
Definition: DataTypeInfo.h:61
DataTypeInfo::UINT
Definition: DataTypeInfo.h:28
DataTypeInfo::USHORT
Definition: DataTypeInfo.h:27
DataTypeInfo::ID
static Type ID(const SmartRef< ContainedObject > &)
Access to type information: Contained object.
Definition: DataTypeInfo.h:85
DataTypeInfo::Type
Type
Definition: DataTypeInfo.h:24
DataTypeInfo::BOOL
Definition: DataTypeInfo.h:34
DataTypeInfo::ID
static Type ID(const char *)
Access to type information: char* (NULL terminated)
Definition: DataTypeInfo.h:77
DataTypeInfo::UCHAR
Definition: DataTypeInfo.h:26
DataTypeInfo::ULONG
Definition: DataTypeInfo.h:29
DataTypeInfo::ID
static Type ID(const IOpaqueAddress *)
Access to type information: IOpaqueAddress.
Definition: DataTypeInfo.h:79
DataTypeInfo::ID
static Type ID(const unsigned long long)
Access to type information: unsigned long long.
Definition: DataTypeInfo.h:69
DataTypeInfo::LONG
Definition: DataTypeInfo.h:33
DataTypeInfo::DataTypeInfo
DataTypeInfo()
Definition: DataTypeInfo.h:20
DataTypeInfo::ID
static Type ID(const float)
Access to type information: float.
Definition: DataTypeInfo.h:71
DataTypeInfo::DOUBLE
Definition: DataTypeInfo.h:36
DataTypeInfo::LONG_NTCHAR
Definition: DataTypeInfo.h:44
DataTypeInfo::CONTAINED_REF
Definition: DataTypeInfo.h:40
DataTypeInfo::type
static const std::type_info & type(long typ)
Access to type information: the reverse way.
Definition: DataTypeInfo.h:133
DataTypeInfo::LONGLONG
Definition: DataTypeInfo.h:45
ContainedObject
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
Definition: ContainedObject.h:31
DataTypeInfo::OBJECT_ADDR
Definition: DataTypeInfo.h:42
DataTypeInfo::size
static long size(long typ)
Access to type information: the reverse way.
Definition: DataTypeInfo.h:184
DataTypeInfo::ID
static Type ID(const long long)
Access to type information: long long.
Definition: DataTypeInfo.h:59
DataTypeInfo::copy
static int copy(void *tar, const void *src, long typ, int numObj)
Copy data.
Definition: DataTypeInfo.h:235
SmartRef.h
DataTypeInfo::LONG_STRING
Definition: DataTypeInfo.h:43
DataTypeInfo::ID
static Type ID(const char)
Access to type information: char.
Definition: DataTypeInfo.h:51
DataTypeInfo::ID
static Type ID(const unsigned short)
Access to type information: unsigned short.
Definition: DataTypeInfo.h:63
DataTypeInfo::ID
static Type ID(const SmartRef< DataObject > &)
Access to type information: DataObject.
Definition: DataTypeInfo.h:83
DataTypeInfo::ID
static Type ID(const std::string &)
Access to type information: std::string.
Definition: DataTypeInfo.h:75
DataTypeInfo::FLOAT
Definition: DataTypeInfo.h:35
Io::UNKNOWN
Definition: IFileMgr.h:157
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:232
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
DataTypeInfo::ID
static Type ID(const void *)
Access to type information: Pointers.
Definition: DataTypeInfo.h:81
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:88
DataTypeInfo::ID
static Type ID(const double)
Access to type information: float.
Definition: DataTypeInfo.h:73