| The Gaudi Framework v32r1 (f65d50dc)

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