| The Gaudi Framework v32r1 (f65d50dc)

DataTypeInfo.cpp
Go to the documentation of this file.
1 // ====================================================================
2 //
3 // DataTypeInfo.cpp
4 // --------------------------------------------------------------------
5 //
6 // Package : Kernel
7 // Data Object types - implementation
8 //
9 // Author : Markus Frank
10 // History:
11 // +---------+----------------------------------------------+---------+
12 // | Date | Comment | Who |
13 // +---------+----------------------------------------------+---------+
14 // | 3/07/00 | Initial version | M.Frank |
15 // +---------+----------------------------------------------+---------+
16 // ====================================================================
17 #define GAUDI_KERNEL_DATATYPEINFO_CPP 1
18
19 #include "GaudiKernel/DataTypeInfo.h"
20 #include "GaudiKernel/IOpaqueAddress.h"
21 #include "GaudiKernel/System.h"
22
23 // Access to type information
24 DataTypeInfo::Type DataTypeInfo::idByName( const std::string& typ ) {
25 if ( typ == "unsigned char" || typ == "const unsigned char" )
26 return UCHAR;
27 else if ( typ == "unsigned short" || typ == "const unsigned short" )
28 return USHORT;
29 else if ( typ == "unsigned int" || typ == "const unsigned int" )
30 return UINT;
31 else if ( typ == "unsigned long" || typ == "const unsigned long" )
32 return ULONG;
33 else if ( typ == "char" || typ == "const char" )
34 return CHAR;
35 else if ( typ == "short" || typ == "const short" )
36 return SHORT;
37 else if ( typ == "int" || typ == "const int" )
38 return INT;
39 else if ( typ == "long" || typ == "const long" )
40 return LONG;
41 else if ( typ == "bool" || typ == "const bool" )
42 return BOOL;
43 else if ( typ == "float" || typ == "const float" )
44 return FLOAT;
45 else if ( typ == "double" || typ == "const double" )
46 return DOUBLE;
47 else if ( typ == "std::string" || typ == "const std::string" )
48 return STRING;
49 else if ( typ == "char*" || typ == "const char*" )
50 return NTCHAR;
51 else if ( typ == "IOpaqueAddress*" || typ == "const IOpaqueAddress*" )
52 return OBJECT_ADDR;
53 else if ( typ == "SmartRef<DataObject>" || typ == "const SmartRef<DataObject>" )
54 return OBJECT_REF;
55 else if ( typ == "SmartRef<ContainedObject>" || typ == "const SmartRef<ContainedObject>" )
56 return CONTAINED_REF;
57 else if ( typ == "void*" || typ == "const void*" )
58 return POINTER;
59 else
60 return UNKNOWN;
61 }
62
63 // Access to type information
64 const std::type_info& DataTypeInfo::typeByName( const std::string& typ ) {
65 if ( typ == "unsigned char" || typ == "const unsigned char" )
66 return typeid( unsigned char );
67 else if ( typ == "unsigned short" || typ == "const unsigned short" )
68 return typeid( unsigned short );
69 else if ( typ == "unsigned int" || typ == "const unsigned int" )
70 return typeid( unsigned int );
71 else if ( typ == "unsigned long" || typ == "const unsigned long" )
72 return typeid( unsigned long );
73 else if ( typ == "char" || typ == "const char" )
74 return typeid( char );
75 else if ( typ == "short" || typ == "const short" )
76 return typeid( short );
77 else if ( typ == "int" || typ == "const int" )
78 return typeid( int );
79 else if ( typ == "long" || typ == "const long" )
80 return typeid( long );
81 else if ( typ == "bool" || typ == "const bool" )
82 return typeid( bool );
83 else if ( typ == "float" || typ == "const float" )
84 return typeid( float );
85 else if ( typ == "double" || typ == "const double" )
86 return typeid( double );
87 else if ( typ == "std::string" || typ == "const std::string" )
88 return typeid( std::string );
89 else if ( typ == "char*" || typ == "const char*" )
90 return typeid( char* );
91 else if ( typ == "IOpaqueAddress*" || typ == "const IOpaqueAddress*" )
92 return typeid( IOpaqueAddress );
93 else if ( typ == "SmartRef<DataObject>" || typ == "const SmartRef<DataObject>" )
94 return typeid( DataObject* );
95 else if ( typ == "SmartRef<ContainedObject>" || typ == "const SmartRef<ContainedObject>" )
96 return typeid( SmartRef<ContainedObject> );
97 else
98 return typeid( void* );
99 }
100
101 // Access the type name by type ID
102 std::string DataTypeInfo::name( long typ ) {
103 switch ( typ ) {
104 case UCHAR:
105 return System::typeinfoName( typeid( unsigned char ) );
106 case USHORT:
107 return System::typeinfoName( typeid( unsigned short ) );
108 case UINT:
109 return System::typeinfoName( typeid( unsigned int ) );
110 case ULONG:
111 return System::typeinfoName( typeid( unsigned long ) );
112 case CHAR:
113 return System::typeinfoName( typeid( char ) );
114 case SHORT:
115 return System::typeinfoName( typeid( short ) );
116 case INT:
117 return System::typeinfoName( typeid( int ) );
118 case LONG:
119 return System::typeinfoName( typeid( long ) );
120 case BOOL:
121 return System::typeinfoName( typeid( bool ) );
122 case FLOAT:
123 return System::typeinfoName( typeid( float ) );
124 case DOUBLE:
125 return System::typeinfoName( typeid( double ) );
126 case STRING:
127 return System::typeinfoName( typeid( std::string ) );
128 case LONG_STRING:
129 return System::typeinfoName( typeid( std::string ) );
130 case NTCHAR:
131 return System::typeinfoName( typeid( char* ) );
132 case LONG_NTCHAR:
133 return System::typeinfoName( typeid( char* ) );
134 case OBJECT_ADDR:
135 return System::typeinfoName( typeid( IOpaqueAddress* ) );
136 case OBJECT_REF:
137 return System::typeinfoName( typeid( SmartRef<DataObject> ) );
138 case CONTAINED_REF:
139 return System::typeinfoName( typeid( SmartRef<ContainedObject> ) );
140 case POINTER:
141 return System::typeinfoName( typeid( void* ) );
142 case UNKNOWN:
143 default:
144 return "";
145 }
146 }
147
148 // Access the type name by type_info
149 std::string DataTypeInfo::name( const std::type_info& typ ) {
150 if ( typ == typeid( unsigned char ) )
151 return DataTypeInfo::name( UCHAR );
152 else if ( typ == typeid( unsigned short ) )
153 return DataTypeInfo::name( USHORT );
154 else if ( typ == typeid( unsigned int ) )
155 return DataTypeInfo::name( UINT );
156 else if ( typ == typeid( unsigned long ) )
157 return DataTypeInfo::name( ULONG );
158 else if ( typ == typeid( char ) )
159 return DataTypeInfo::name( CHAR );
160 else if ( typ == typeid( short ) )
161 return DataTypeInfo::name( SHORT );
162 else if ( typ == typeid( int ) )
163 return DataTypeInfo::name( INT );
164 else if ( typ == typeid( long ) )
165 return DataTypeInfo::name( LONG );
166 else if ( typ == typeid( bool ) )
167 return DataTypeInfo::name( BOOL );
168 else if ( typ == typeid( float ) )
169 return DataTypeInfo::name( FLOAT );
170 else if ( typ == typeid( double ) )
171 return DataTypeInfo::name( DOUBLE );
172 else if ( typ == typeid( std::string ) )
173 return DataTypeInfo::name( STRING );
174 else if ( typ == typeid( char* ) )
175 return DataTypeInfo::name( NTCHAR );
176 else if ( typ == typeid( IOpaqueAddress* ) )
177 return DataTypeInfo::name( OBJECT_ADDR );
178 else if ( typ == typeid( SmartRef<DataObject> ) )
179 return DataTypeInfo::name( OBJECT_REF );
180 else if ( typ == typeid( SmartRef<ContainedObject> ) )
181 return DataTypeInfo::name( CONTAINED_REF );
182 else if ( typ == typeid( void* ) )
183 return DataTypeInfo::name( POINTER );
184 else
185 return DataTypeInfo::name( UNKNOWN );
186 }
System.h
DataTypeInfo::OBJECT_REF
Definition: DataTypeInfo.h:38
DataTypeInfo::POINTER
Definition: DataTypeInfo.h:40
DataTypeInfo::INT
Definition: DataTypeInfo.h:31
DataTypeInfo.h
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
DataTypeInfo::CHAR
Definition: DataTypeInfo.h:29
SmartRef< ContainedObject >
DataTypeInfo::STRING
Definition: DataTypeInfo.h:36
DataTypeInfo::SHORT
Definition: DataTypeInfo.h:30
DataTypeInfo::NTCHAR
Definition: DataTypeInfo.h:37
std::type_info
std::string
STL class.
DataTypeInfo::UINT
Definition: DataTypeInfo.h:27
DataTypeInfo::USHORT
Definition: DataTypeInfo.h:26
DataTypeInfo::Type
Type
Definition: DataTypeInfo.h:23
DataTypeInfo::BOOL
Definition: DataTypeInfo.h:33
DataTypeInfo::UCHAR
Definition: DataTypeInfo.h:25
DataTypeInfo::ULONG
Definition: DataTypeInfo.h:28
DataTypeInfo::LONG
Definition: DataTypeInfo.h:32
DataTypeInfo::DOUBLE
Definition: DataTypeInfo.h:35
DataTypeInfo::UNKNOWN
Definition: DataTypeInfo.h:24
DataTypeInfo::idByName
static Type idByName(const std::string &typ)
Access to type information.
Definition: DataTypeInfo.cpp:24
DataTypeInfo::LONG_NTCHAR
Definition: DataTypeInfo.h:43
DataTypeInfo::CONTAINED_REF
Definition: DataTypeInfo.h:39
IOpaqueAddress.h
DataTypeInfo::OBJECT_ADDR
Definition: DataTypeInfo.h:41
DataTypeInfo::LONG_STRING
Definition: DataTypeInfo.h:42
DataTypeInfo::FLOAT
Definition: DataTypeInfo.h:34
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
DataTypeInfo::name
static std::string name(long typ)
Definition: DataTypeInfo.cpp:102
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
DataTypeInfo::typeByName
static const std::type_info & typeByName(const std::string &typ)
Access to type information.
Definition: DataTypeInfo.cpp:64