The Gaudi Framework  master (01b473db)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataTypeInfo Class Reference

#include <GaudiKernel/DataTypeInfo.h>

Public Types

enum  Type {
  UNKNOWN = 0, UCHAR, USHORT, UINT,
  ULONG, CHAR, SHORT, INT,
  LONG, BOOL, FLOAT, DOUBLE,
  STRING, NTCHAR, OBJECT_REF, CONTAINED_REF,
  POINTER, OBJECT_ADDR, LONG_STRING, LONG_NTCHAR,
  LONGLONG, ULONGLONG
}
 

Static Public Member Functions

static Type ID (const bool)
 Access to type information: bool. More...
 
static Type ID (const char)
 Access to type information: char. More...
 
static Type ID (const short)
 Access to type information: short. More...
 
static Type ID (const int)
 Access to type information: int. More...
 
static Type ID (const long)
 Access to type information: long. More...
 
static Type ID (const long long)
 Access to type information: long long. More...
 
static Type ID (const unsigned char)
 Access to type information: unsigned char. More...
 
static Type ID (const unsigned short)
 Access to type information: unsigned short. More...
 
static Type ID (const unsigned int)
 Access to type information: unsigned int. More...
 
static Type ID (const unsigned long)
 Access to type information: unsigned long. More...
 
static Type ID (const unsigned long long)
 Access to type information: unsigned long long. More...
 
static Type ID (const float)
 Access to type information: float. More...
 
static Type ID (const double)
 Access to type information: float. More...
 
static Type ID (const std::string &)
 Access to type information: std::string. More...
 
static Type ID (const char *)
 Access to type information: char* (NULL terminated) More...
 
static Type ID (const IOpaqueAddress *)
 Access to type information: IOpaqueAddress. More...
 
static Type ID (const void *)
 Access to type information: Pointers. More...
 
static Type ID (const SmartRef< DataObject > &)
 Access to type information: DataObject. More...
 
static Type ID (const SmartRef< ContainedObject > &)
 Access to type information: Contained object. More...
 
static Type ID (const std::type_info &typ)
 Access to type information: the reverse way. More...
 
static const std::type_info & type (long typ)
 Access to type information: the reverse way. More...
 
static long size (long typ)
 Access to type information: the reverse way. More...
 
static long size (const std::type_info &typ)
 Access to type information: the reverse way. More...
 
static int copy (void *tar, const void *src, long typ, int numObj)
 Copy data. More...
 
static std::string name (long typ)
 
static std::string name (const std::type_info &typ)
 
static Type idByName (const std::string &typ)
 Access to type information. More...
 
static const std::type_info & typeByName (const std::string &typ)
 Access to type information. More...
 

Private Member Functions

 DataTypeInfo ()
 

Detailed Description

Small class which allows access to internal type IDs.

Definition at line 25 of file DataTypeInfo.h.

Member Enumeration Documentation

◆ Type

Enumerator
UNKNOWN 
UCHAR 
USHORT 
UINT 
ULONG 
CHAR 
SHORT 
INT 
LONG 
BOOL 
FLOAT 
DOUBLE 
STRING 
NTCHAR 
OBJECT_REF 
CONTAINED_REF 
POINTER 
OBJECT_ADDR 
LONG_STRING 
LONG_NTCHAR 
LONGLONG 
ULONGLONG 

Definition at line 32 of file DataTypeInfo.h.

32  {
33  UNKNOWN = 0,
34  UCHAR,
35  USHORT,
36  UINT,
37  ULONG,
38  CHAR,
39  SHORT,
40  INT,
41  LONG,
42  BOOL,
43  FLOAT,
44  DOUBLE,
45  STRING,
46  NTCHAR,
47  OBJECT_REF,
49  POINTER,
53  LONGLONG,
54  ULONGLONG
55  };

Constructor & Destructor Documentation

◆ DataTypeInfo()

DataTypeInfo::DataTypeInfo ( )
inlineprivate

Definition at line 28 of file DataTypeInfo.h.

28 {}

Member Function Documentation

◆ copy()

static int DataTypeInfo::copy ( void *  tar,
const void *  src,
long  typ,
int  numObj 
)
inlinestatic

Copy data.

Definition at line 240 of file DataTypeInfo.h.

240  {
241  switch ( typ ) {
242  case UCHAR:
243  numObj *= sizeof( unsigned char );
244  break;
245  case USHORT:
246  numObj *= sizeof( unsigned short );
247  break;
248  case UINT:
249  numObj *= sizeof( unsigned int );
250  break;
251  case ULONG:
252  numObj *= sizeof( unsigned long );
253  break;
254  case ULONGLONG:
255  numObj *= sizeof( unsigned long long );
256  break;
257  case CHAR:
258  numObj *= sizeof( char );
259  break;
260  case SHORT:
261  numObj *= sizeof( short );
262  break;
263  case INT:
264  numObj *= sizeof( int );
265  break;
266  case LONG:
267  numObj *= sizeof( long );
268  break;
269  case LONGLONG:
270  numObj *= sizeof( long long );
271  break;
272  case BOOL:
273  numObj *= sizeof( bool );
274  break;
275  case FLOAT:
276  numObj *= sizeof( float );
277  break;
278  case DOUBLE:
279  numObj *= sizeof( double );
280  break;
281  case UNKNOWN:
282  default:
283  numObj *= 0;
284  break;
285  }
286  memcpy( tar, src, numObj );
287  return numObj;
288  }

◆ ID() [1/20]

static Type DataTypeInfo::ID ( const bool  )
inlinestatic

Access to type information: bool.

Definition at line 57 of file DataTypeInfo.h.

57 { return BOOL; }

◆ ID() [2/20]

static Type DataTypeInfo::ID ( const char *  )
inlinestatic

Access to type information: char* (NULL terminated)

Definition at line 85 of file DataTypeInfo.h.

85 { return NTCHAR; }

◆ ID() [3/20]

static Type DataTypeInfo::ID ( const char  )
inlinestatic

Access to type information: char.

Definition at line 59 of file DataTypeInfo.h.

59 { return CHAR; }

◆ ID() [4/20]

static Type DataTypeInfo::ID ( const double  )
inlinestatic

Access to type information: float.

Definition at line 81 of file DataTypeInfo.h.

81 { return DOUBLE; }

◆ ID() [5/20]

static Type DataTypeInfo::ID ( const float  )
inlinestatic

Access to type information: float.

Definition at line 79 of file DataTypeInfo.h.

79 { return FLOAT; }

◆ ID() [6/20]

static Type DataTypeInfo::ID ( const int  )
inlinestatic

Access to type information: int.

Definition at line 63 of file DataTypeInfo.h.

63 { return INT; }

◆ ID() [7/20]

static Type DataTypeInfo::ID ( const IOpaqueAddress )
inlinestatic

Access to type information: IOpaqueAddress.

Definition at line 87 of file DataTypeInfo.h.

87 { return OBJECT_ADDR; }

◆ ID() [8/20]

static Type DataTypeInfo::ID ( const long long  )
inlinestatic

Access to type information: long long.

Definition at line 67 of file DataTypeInfo.h.

67 { return LONGLONG; }

◆ ID() [9/20]

static Type DataTypeInfo::ID ( const long  )
inlinestatic

Access to type information: long.

Definition at line 65 of file DataTypeInfo.h.

65 { return LONG; }

◆ ID() [10/20]

static Type DataTypeInfo::ID ( const short  )
inlinestatic

Access to type information: short.

Definition at line 61 of file DataTypeInfo.h.

61 { return SHORT; }

◆ ID() [11/20]

static Type DataTypeInfo::ID ( const SmartRef< ContainedObject > &  )
inlinestatic

Access to type information: Contained object.

Definition at line 93 of file DataTypeInfo.h.

93 { return CONTAINED_REF; }

◆ ID() [12/20]

static Type DataTypeInfo::ID ( const SmartRef< DataObject > &  )
inlinestatic

Access to type information: DataObject.

Definition at line 91 of file DataTypeInfo.h.

91 { return OBJECT_REF; }

◆ ID() [13/20]

static Type DataTypeInfo::ID ( const std::string &  )
inlinestatic

Access to type information: std::string.

Definition at line 83 of file DataTypeInfo.h.

83 { return STRING; }

◆ ID() [14/20]

static Type DataTypeInfo::ID ( const std::type_info &  typ)
inlinestatic

Access to type information: the reverse way.

Definition at line 96 of file DataTypeInfo.h.

96  {
97  if ( typ == typeid( unsigned char ) )
98  return UCHAR;
99  else if ( typ == typeid( unsigned short ) )
100  return USHORT;
101  else if ( typ == typeid( unsigned int ) )
102  return UINT;
103  else if ( typ == typeid( unsigned long ) )
104  return ULONG;
105  else if ( typ == typeid( unsigned long long ) )
106  return ULONGLONG;
107  else if ( typ == typeid( char ) )
108  return CHAR;
109  else if ( typ == typeid( short ) )
110  return SHORT;
111  else if ( typ == typeid( int ) )
112  return INT;
113  else if ( typ == typeid( long ) )
114  return LONG;
115  else if ( typ == typeid( long long ) )
116  return LONGLONG;
117  else if ( typ == typeid( bool ) )
118  return BOOL;
119  else if ( typ == typeid( float ) )
120  return FLOAT;
121  else if ( typ == typeid( double ) )
122  return DOUBLE;
123  else if ( typ == typeid( std::string ) )
124  return STRING;
125  else if ( typ == typeid( char* ) )
126  return NTCHAR;
127  else if ( typ == typeid( SmartRef<DataObject> ) )
128  return OBJECT_REF;
129  else if ( typ == typeid( SmartRef<ContainedObject> ) )
130  return CONTAINED_REF;
131  else if ( typ == typeid( IOpaqueAddress* ) )
132  return OBJECT_ADDR;
133  else if ( typ == typeid( void* ) )
134  return POINTER;
135  else
136  return UNKNOWN;
137  }

◆ ID() [15/20]

static Type DataTypeInfo::ID ( const unsigned char  )
inlinestatic

Access to type information: unsigned char.

Definition at line 69 of file DataTypeInfo.h.

69 { return UCHAR; }

◆ ID() [16/20]

static Type DataTypeInfo::ID ( const unsigned int  )
inlinestatic

Access to type information: unsigned int.

Definition at line 73 of file DataTypeInfo.h.

73 { return UINT; }

◆ ID() [17/20]

static Type DataTypeInfo::ID ( const unsigned long long  )
inlinestatic

Access to type information: unsigned long long.

Definition at line 77 of file DataTypeInfo.h.

77 { return ULONGLONG; }

◆ ID() [18/20]

static Type DataTypeInfo::ID ( const unsigned long  )
inlinestatic

Access to type information: unsigned long.

Definition at line 75 of file DataTypeInfo.h.

75 { return ULONG; }

◆ ID() [19/20]

static Type DataTypeInfo::ID ( const unsigned short  )
inlinestatic

Access to type information: unsigned short.

Definition at line 71 of file DataTypeInfo.h.

71 { return USHORT; }

◆ ID() [20/20]

static Type DataTypeInfo::ID ( const void *  )
inlinestatic

Access to type information: Pointers.

Definition at line 89 of file DataTypeInfo.h.

89 { return POINTER; }

◆ idByName()

DataTypeInfo::Type DataTypeInfo::idByName ( const std::string &  typ)
static

Access to type information.

Definition at line 16 of file DataTypeInfo.cpp.

16  {
17  if ( typ == "unsigned char" || typ == "const unsigned char" )
18  return UCHAR;
19  else if ( typ == "unsigned short" || typ == "const unsigned short" )
20  return USHORT;
21  else if ( typ == "unsigned int" || typ == "const unsigned int" )
22  return UINT;
23  else if ( typ == "unsigned long" || typ == "const unsigned long" )
24  return ULONG;
25  else if ( typ == "char" || typ == "const char" )
26  return CHAR;
27  else if ( typ == "short" || typ == "const short" )
28  return SHORT;
29  else if ( typ == "int" || typ == "const int" )
30  return INT;
31  else if ( typ == "long" || typ == "const long" )
32  return LONG;
33  else if ( typ == "bool" || typ == "const bool" )
34  return BOOL;
35  else if ( typ == "float" || typ == "const float" )
36  return FLOAT;
37  else if ( typ == "double" || typ == "const double" )
38  return DOUBLE;
39  else if ( typ == "std::string" || typ == "const std::string" )
40  return STRING;
41  else if ( typ == "char*" || typ == "const char*" )
42  return NTCHAR;
43  else if ( typ == "IOpaqueAddress*" || typ == "const IOpaqueAddress*" )
44  return OBJECT_ADDR;
45  else if ( typ == "SmartRef<DataObject>" || typ == "const SmartRef<DataObject>" )
46  return OBJECT_REF;
47  else if ( typ == "SmartRef<ContainedObject>" || typ == "const SmartRef<ContainedObject>" )
48  return CONTAINED_REF;
49  else if ( typ == "void*" || typ == "const void*" )
50  return POINTER;
51  else
52  return UNKNOWN;
53 }

◆ name() [1/2]

std::string DataTypeInfo::name ( const std::type_info &  typ)
static

Definition at line 141 of file DataTypeInfo.cpp.

141  {
142  if ( typ == typeid( unsigned char ) )
143  return DataTypeInfo::name( UCHAR );
144  else if ( typ == typeid( unsigned short ) )
145  return DataTypeInfo::name( USHORT );
146  else if ( typ == typeid( unsigned int ) )
147  return DataTypeInfo::name( UINT );
148  else if ( typ == typeid( unsigned long ) )
149  return DataTypeInfo::name( ULONG );
150  else if ( typ == typeid( char ) )
151  return DataTypeInfo::name( CHAR );
152  else if ( typ == typeid( short ) )
153  return DataTypeInfo::name( SHORT );
154  else if ( typ == typeid( int ) )
155  return DataTypeInfo::name( INT );
156  else if ( typ == typeid( long ) )
157  return DataTypeInfo::name( LONG );
158  else if ( typ == typeid( bool ) )
159  return DataTypeInfo::name( BOOL );
160  else if ( typ == typeid( float ) )
161  return DataTypeInfo::name( FLOAT );
162  else if ( typ == typeid( double ) )
163  return DataTypeInfo::name( DOUBLE );
164  else if ( typ == typeid( std::string ) )
165  return DataTypeInfo::name( STRING );
166  else if ( typ == typeid( char* ) )
167  return DataTypeInfo::name( NTCHAR );
168  else if ( typ == typeid( IOpaqueAddress* ) )
170  else if ( typ == typeid( SmartRef<DataObject> ) )
171  return DataTypeInfo::name( OBJECT_REF );
172  else if ( typ == typeid( SmartRef<ContainedObject> ) )
174  else if ( typ == typeid( void* ) )
175  return DataTypeInfo::name( POINTER );
176  else
177  return DataTypeInfo::name( UNKNOWN );
178 }

◆ name() [2/2]

std::string DataTypeInfo::name ( long  typ)
static

Definition at line 94 of file DataTypeInfo.cpp.

94  {
95  switch ( typ ) {
96  case UCHAR:
97  return System::typeinfoName( typeid( unsigned char ) );
98  case USHORT:
99  return System::typeinfoName( typeid( unsigned short ) );
100  case UINT:
101  return System::typeinfoName( typeid( unsigned int ) );
102  case ULONG:
103  return System::typeinfoName( typeid( unsigned long ) );
104  case CHAR:
105  return System::typeinfoName( typeid( char ) );
106  case SHORT:
107  return System::typeinfoName( typeid( short ) );
108  case INT:
109  return System::typeinfoName( typeid( int ) );
110  case LONG:
111  return System::typeinfoName( typeid( long ) );
112  case BOOL:
113  return System::typeinfoName( typeid( bool ) );
114  case FLOAT:
115  return System::typeinfoName( typeid( float ) );
116  case DOUBLE:
117  return System::typeinfoName( typeid( double ) );
118  case STRING:
119  return System::typeinfoName( typeid( std::string ) );
120  case LONG_STRING:
121  return System::typeinfoName( typeid( std::string ) );
122  case NTCHAR:
123  return System::typeinfoName( typeid( char* ) );
124  case LONG_NTCHAR:
125  return System::typeinfoName( typeid( char* ) );
126  case OBJECT_ADDR:
127  return System::typeinfoName( typeid( IOpaqueAddress* ) );
128  case OBJECT_REF:
129  return System::typeinfoName( typeid( SmartRef<DataObject> ) );
130  case CONTAINED_REF:
132  case POINTER:
133  return System::typeinfoName( typeid( void* ) );
134  case UNKNOWN:
135  default:
136  return "";
137  }
138 }

◆ size() [1/2]

static long DataTypeInfo::size ( const std::type_info &  typ)
inlinestatic

Access to type information: the reverse way.

Definition at line 237 of file DataTypeInfo.h.

237 { return size( ID( typ ) ); }

◆ size() [2/2]

static long DataTypeInfo::size ( long  typ)
inlinestatic

Access to type information: the reverse way.

Definition at line 190 of file DataTypeInfo.h.

190  {
191  switch ( typ ) {
192  case UCHAR:
193  return sizeof( unsigned char );
194  case USHORT:
195  return sizeof( unsigned short );
196  case UINT:
197  return sizeof( unsigned int );
198  case ULONG:
199  return sizeof( unsigned long );
200  case ULONGLONG:
201  return sizeof( unsigned long long );
202  case CHAR:
203  return sizeof( char );
204  case SHORT:
205  return sizeof( short );
206  case INT:
207  return sizeof( int );
208  case LONG:
209  return sizeof( long );
210  case LONGLONG:
211  return sizeof( long long );
212  case BOOL:
213  return sizeof( bool );
214  case FLOAT:
215  return sizeof( float );
216  case DOUBLE:
217  return sizeof( double );
218  case STRING:
219  return sizeof( std::string );
220  case LONG_STRING:
221  return sizeof( std::string );
222  case NTCHAR:
223  return sizeof( char* );
224  case LONG_NTCHAR:
225  return sizeof( char* );
226  case OBJECT_ADDR:
227  case POINTER:
228  case OBJECT_REF:
229  case CONTAINED_REF:
230  case UNKNOWN:
231  default:
232  return 0;
233  }
234  }

◆ type()

static const std::type_info& DataTypeInfo::type ( long  typ)
inlinestatic

Access to type information: the reverse way.

Definition at line 140 of file DataTypeInfo.h.

140  {
141  switch ( typ ) {
142  case UCHAR:
143  return typeid( unsigned char );
144  case USHORT:
145  return typeid( unsigned short );
146  case UINT:
147  return typeid( unsigned int );
148  case ULONG:
149  return typeid( unsigned long );
150  case ULONGLONG:
151  return typeid( unsigned long long );
152  case CHAR:
153  return typeid( char );
154  case SHORT:
155  return typeid( short );
156  case INT:
157  return typeid( int );
158  case LONG:
159  return typeid( long );
160  case LONGLONG:
161  return typeid( long long );
162  case BOOL:
163  return typeid( bool );
164  case FLOAT:
165  return typeid( float );
166  case DOUBLE:
167  return typeid( double );
168  case LONG_STRING:
169  return typeid( std::string );
170  case STRING:
171  return typeid( std::string );
172  case NTCHAR:
173  return typeid( char* );
174  case LONG_NTCHAR:
175  return typeid( char* );
176  case OBJECT_REF:
177  return typeid( SmartRef<DataObject> );
178  case CONTAINED_REF:
179  return typeid( SmartRef<ContainedObject> );
180  case OBJECT_ADDR:
181  return typeid( IOpaqueAddress* );
182  case POINTER:
183  case UNKNOWN:
184  default:
185  return typeid( void* );
186  }
187  }

◆ typeByName()

const std::type_info & DataTypeInfo::typeByName ( const std::string &  typ)
static

Access to type information.

Definition at line 56 of file DataTypeInfo.cpp.

56  {
57  if ( typ == "unsigned char" || typ == "const unsigned char" )
58  return typeid( unsigned char );
59  else if ( typ == "unsigned short" || typ == "const unsigned short" )
60  return typeid( unsigned short );
61  else if ( typ == "unsigned int" || typ == "const unsigned int" )
62  return typeid( unsigned int );
63  else if ( typ == "unsigned long" || typ == "const unsigned long" )
64  return typeid( unsigned long );
65  else if ( typ == "char" || typ == "const char" )
66  return typeid( char );
67  else if ( typ == "short" || typ == "const short" )
68  return typeid( short );
69  else if ( typ == "int" || typ == "const int" )
70  return typeid( int );
71  else if ( typ == "long" || typ == "const long" )
72  return typeid( long );
73  else if ( typ == "bool" || typ == "const bool" )
74  return typeid( bool );
75  else if ( typ == "float" || typ == "const float" )
76  return typeid( float );
77  else if ( typ == "double" || typ == "const double" )
78  return typeid( double );
79  else if ( typ == "std::string" || typ == "const std::string" )
80  return typeid( std::string );
81  else if ( typ == "char*" || typ == "const char*" )
82  return typeid( char* );
83  else if ( typ == "IOpaqueAddress*" || typ == "const IOpaqueAddress*" )
84  return typeid( IOpaqueAddress );
85  else if ( typ == "SmartRef<DataObject>" || typ == "const SmartRef<DataObject>" )
86  return typeid( DataObject* );
87  else if ( typ == "SmartRef<ContainedObject>" || typ == "const SmartRef<ContainedObject>" )
88  return typeid( SmartRef<ContainedObject> );
89  else
90  return typeid( void* );
91 }

The documentation for this class was generated from the following files:
DataTypeInfo::ID
static Type ID(const bool)
Access to type information: bool.
Definition: DataTypeInfo.h:57
DataTypeInfo::STRING
@ STRING
Definition: DataTypeInfo.h:45
IOpaqueAddress
Definition: IOpaqueAddress.h:28
DataTypeInfo::NTCHAR
@ NTCHAR
Definition: DataTypeInfo.h:46
DataTypeInfo::POINTER
@ POINTER
Definition: DataTypeInfo.h:49
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:260
DataTypeInfo::USHORT
@ USHORT
Definition: DataTypeInfo.h:35
DataTypeInfo::ULONG
@ ULONG
Definition: DataTypeInfo.h:37
DataTypeInfo::LONG
@ LONG
Definition: DataTypeInfo.h:41
DataTypeInfo::size
static long size(long typ)
Access to type information: the reverse way.
Definition: DataTypeInfo.h:190
DataTypeInfo::DOUBLE
@ DOUBLE
Definition: DataTypeInfo.h:44
DataTypeInfo::SHORT
@ SHORT
Definition: DataTypeInfo.h:39
DataTypeInfo::UNKNOWN
@ UNKNOWN
Definition: DataTypeInfo.h:33
DataTypeInfo::CONTAINED_REF
@ CONTAINED_REF
Definition: DataTypeInfo.h:48
DataTypeInfo::LONG_STRING
@ LONG_STRING
Definition: DataTypeInfo.h:51
DataTypeInfo::FLOAT
@ FLOAT
Definition: DataTypeInfo.h:43
DataTypeInfo::UCHAR
@ UCHAR
Definition: DataTypeInfo.h:34
DataTypeInfo::UINT
@ UINT
Definition: DataTypeInfo.h:36
DataTypeInfo::BOOL
@ BOOL
Definition: DataTypeInfo.h:42
DataTypeInfo::name
static std::string name(long typ)
Definition: DataTypeInfo.cpp:94
DataTypeInfo::ULONGLONG
@ ULONGLONG
Definition: DataTypeInfo.h:54
DataObject
Definition: DataObject.h:37
DataTypeInfo::LONG_NTCHAR
@ LONG_NTCHAR
Definition: DataTypeInfo.h:52
DataTypeInfo::OBJECT_ADDR
@ OBJECT_ADDR
Definition: DataTypeInfo.h:50
SmartRef< DataObject >
DataTypeInfo::LONGLONG
@ LONGLONG
Definition: DataTypeInfo.h:53
DataTypeInfo::OBJECT_REF
@ OBJECT_REF
Definition: DataTypeInfo.h:47
DataTypeInfo::INT
@ INT
Definition: DataTypeInfo.h:40
DataTypeInfo::CHAR
@ CHAR
Definition: DataTypeInfo.h:38