| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

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