| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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/System.h"
20 #include "GaudiKernel/DataTypeInfo.h"
21 #include "GaudiKernel/IOpaqueAddress.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 if ( typ == "void*" || typ == "const void*" )
98 return typeid(void*);
99 else
100 return typeid(void*);
101 }
102
103 // Access the type name by type ID
104 std::string DataTypeInfo::name(long typ) {
105 switch(typ) {
106 case UCHAR:
107 return System::typeinfoName(typeid(unsigned char));
108 case USHORT:
109 return System::typeinfoName(typeid(unsigned short));
110 case UINT:
111 return System::typeinfoName(typeid(unsigned int));
112 case ULONG:
113 return System::typeinfoName(typeid(unsigned long));
114 case CHAR:
115 return System::typeinfoName(typeid(char));
116 case SHORT:
117 return System::typeinfoName(typeid(short));
118 case INT:
119 return System::typeinfoName(typeid(int));
120 case LONG:
121 return System::typeinfoName(typeid(long));
122 case BOOL:
123 return System::typeinfoName(typeid(bool));
124 case FLOAT:
125 return System::typeinfoName(typeid(float));
126 case DOUBLE:
127 return System::typeinfoName(typeid(double));
128 case STRING:
129 return System::typeinfoName(typeid(std::string));
130 case LONG_STRING:
131 return System::typeinfoName(typeid(std::string));
132 case NTCHAR:
133 return System::typeinfoName(typeid(char*));
134 case LONG_NTCHAR:
135 return System::typeinfoName(typeid(char*));
136 case OBJECT_ADDR:
137 return System::typeinfoName(typeid(IOpaqueAddress*));
138 case OBJECT_REF:
139 return System::typeinfoName(typeid(SmartRef<DataObject>));
140 case CONTAINED_REF:
141 return System::typeinfoName(typeid(SmartRef<ContainedObject>));
142 case POINTER:
143 return System::typeinfoName(typeid(void*));
144 case UNKNOWN:
145 default:
146 return "";
147 }
148 }
149
150 // Access the type name by type_info
151 std::string DataTypeInfo::name(const std::type_info& typ) {
152 if ( typ == typeid(unsigned char) )
153 return DataTypeInfo::name(UCHAR);
154 else if ( typ == typeid(unsigned short) )
155 return DataTypeInfo::name(USHORT);
156 else if ( typ == typeid(unsigned int) )
157 return DataTypeInfo::name(UINT);
158 else if ( typ == typeid(unsigned long) )
159 return DataTypeInfo::name(ULONG);
160 else if ( typ == typeid(char) )
161 return DataTypeInfo::name(CHAR);
162 else if ( typ == typeid(short) )
163 return DataTypeInfo::name(SHORT);
164 else if ( typ == typeid(int) )
165 return DataTypeInfo::name(INT);
166 else if ( typ == typeid(long) )
167 return DataTypeInfo::name(LONG);
168 else if ( typ == typeid(bool) )
169 return DataTypeInfo::name(BOOL);
170 else if ( typ == typeid(float) )
171 return DataTypeInfo::name(FLOAT);
172 else if ( typ == typeid(double) )
173 return DataTypeInfo::name(DOUBLE);
174 else if ( typ == typeid(std::string) )
175 return DataTypeInfo::name(STRING);
176 else if ( typ == typeid(char*) )
177 return DataTypeInfo::name(NTCHAR);
178 else if ( typ == typeid(IOpaqueAddress*) )
179 return DataTypeInfo::name(OBJECT_ADDR);
180 else if ( typ == typeid(SmartRef<DataObject>) )
181 return DataTypeInfo::name(OBJECT_REF);
182 else if ( typ == typeid(SmartRef<ContainedObject>) )
183 return DataTypeInfo::name(CONTAINED_REF);
184 else if ( typ == typeid(void*) )
185 return DataTypeInfo::name(POINTER);
186 else
187 return DataTypeInfo::name(UNKNOWN);
188 }
System.h
DataTypeInfo::OBJECT_REF
Definition: DataTypeInfo.h:28
DataTypeInfo::POINTER
Definition: DataTypeInfo.h:28
DataTypeInfo::INT
Definition: DataTypeInfo.h:25
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:299
DataTypeInfo::CHAR
Definition: DataTypeInfo.h:25
SmartRef< ContainedObject >
DataTypeInfo::STRING
Definition: DataTypeInfo.h:27
DataTypeInfo::SHORT
Definition: DataTypeInfo.h:25
DataTypeInfo::NTCHAR
Definition: DataTypeInfo.h:27
std::type_info
std::string
STL class.
DataTypeInfo::UINT
Definition: DataTypeInfo.h:24
DataTypeInfo::USHORT
Definition: DataTypeInfo.h:24
DataTypeInfo::Type
Type
Definition: DataTypeInfo.h:22
DataTypeInfo::BOOL
Definition: DataTypeInfo.h:26
DataTypeInfo::UCHAR
Definition: DataTypeInfo.h:24
DataTypeInfo::ULONG
Definition: DataTypeInfo.h:24
DataTypeInfo::LONG
Definition: DataTypeInfo.h:25
DataTypeInfo::DOUBLE
Definition: DataTypeInfo.h:26
DataTypeInfo::UNKNOWN
Definition: DataTypeInfo.h:23
DataTypeInfo::idByName
static Type idByName(const std::string &typ)
Access to type information.
Definition: DataTypeInfo.cpp:24
DataTypeInfo::LONG_NTCHAR
Definition: DataTypeInfo.h:29
DataTypeInfo::CONTAINED_REF
Definition: DataTypeInfo.h:28
IOpaqueAddress.h
DataTypeInfo::OBJECT_ADDR
Definition: DataTypeInfo.h:28
DataTypeInfo::LONG_STRING
Definition: DataTypeInfo.h:29
DataTypeInfo::FLOAT
Definition: DataTypeInfo.h:26
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
DataTypeInfo::name
static std::string name(long typ)
Definition: DataTypeInfo.cpp:104
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