Gaudi Framework, version v20r4

Generated: 8 Jan 2009

DataTypeInfo.cpp

Go to the documentation of this file.
00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/DataTypeInfo.cpp,v 1.5 2008/10/27 19:22:21 marcocle Exp $
00002 //      ====================================================================
00003 //
00004 //      DataTypeInfo.cpp
00005 //      --------------------------------------------------------------------
00006 //
00007 //      Package   : Kernel
00008 //              Data Object types - implementation
00009 //
00010 //      Author    : Markus Frank
00011 //  History:
00012 //  +---------+----------------------------------------------+---------+
00013 //  |    Date |                 Comment                      | Who     |
00014 //  +---------+----------------------------------------------+---------+
00015 //  | 3/07/00 | Initial version                              | M.Frank |
00016 //  +---------+----------------------------------------------+---------+
00017 //      ====================================================================
00018 #define GAUDI_KERNEL_DATATYPEINFO_CPP 1
00019 
00020 #include "GaudiKernel/System.h"
00021 #include "GaudiKernel/DataTypeInfo.h"
00022 #include "GaudiKernel/IOpaqueAddress.h"
00023 
00024 // Access to type information
00025 DataTypeInfo::Type DataTypeInfo::idByName( const std::string& typ )   {
00026   if ( typ == "unsigned char"         || typ == "const unsigned char" )
00027     return UCHAR;
00028   else if ( typ == "unsigned short"   || typ == "const unsigned short" )
00029     return USHORT;
00030   else if ( typ == "unsigned int"     || typ == "const unsigned int" )
00031     return UINT;
00032   else if ( typ == "unsigned long"    || typ == "const unsigned long" )
00033     return ULONG;
00034   else if ( typ == "char"             || typ == "const char" )
00035     return CHAR;
00036   else if ( typ == "short"            || typ == "const short" )
00037     return SHORT;
00038   else if ( typ == "int"              || typ == "const int" )
00039     return INT;
00040   else if ( typ == "long"             || typ == "const long" )
00041     return LONG;
00042   else if ( typ == "bool"             || typ == "const bool" )
00043     return BOOL;
00044   else if ( typ == "float"            || typ == "const float" )
00045     return FLOAT;
00046   else if ( typ == "double"           || typ == "const double" )
00047     return DOUBLE;
00048   else if ( typ == "std::string"      || typ == "const std::string" )
00049     return STRING;
00050   else if ( typ == "char*"            || typ == "const char*" )
00051     return NTCHAR;
00052   else if ( typ == "IOpaqueAddress*"  || typ == "const IOpaqueAddress*" )
00053     return OBJECT_ADDR;
00054   else if ( typ == "SmartRef<DataObject>"      || typ == "const SmartRef<DataObject>" )
00055     return OBJECT_REF;
00056   else if ( typ == "SmartRef<ContainedObject>" || typ == "const SmartRef<ContainedObject>" )
00057     return CONTAINED_REF;
00058   else if ( typ == "void*"            || typ == "const void*" )
00059     return POINTER;
00060   else
00061     return UNKNOWN;
00062 }
00063 
00064 // Access to type information
00065 const std::type_info& DataTypeInfo::typeByName( const std::string& typ )   {
00066   if ( typ == "unsigned char"         || typ == "const unsigned char" )
00067     return typeid(unsigned char);
00068   else if ( typ == "unsigned short"   || typ == "const unsigned short" )
00069     return typeid(unsigned short);
00070   else if ( typ == "unsigned int"     || typ == "const unsigned int" )
00071     return typeid(unsigned int);
00072   else if ( typ == "unsigned long"    || typ == "const unsigned long" )
00073     return typeid(unsigned long);
00074   else if ( typ == "char"             || typ == "const char" )
00075     return typeid(char);
00076   else if ( typ == "short"            || typ == "const short" )
00077     return typeid(short);
00078   else if ( typ == "int"              || typ == "const int" )
00079     return typeid(int);
00080   else if ( typ == "long"             || typ == "const long" )
00081     return typeid(long);
00082   else if ( typ == "bool"             || typ == "const bool" )
00083     return typeid(bool);
00084   else if ( typ == "float"            || typ == "const float" )
00085     return typeid(float);
00086   else if ( typ == "double"           || typ == "const double" )
00087     return typeid(double);
00088   else if ( typ == "std::string"      || typ == "const std::string" )
00089     return typeid(std::string);
00090   else if ( typ == "char*"            || typ == "const char*" )
00091     return typeid(char*);
00092   else if ( typ == "IOpaqueAddress*"  || typ == "const IOpaqueAddress*" )
00093     return typeid(IOpaqueAddress);
00094   else if ( typ == "SmartRef<DataObject>"      || typ == "const SmartRef<DataObject>" )
00095     return typeid(DataObject*);
00096   else if ( typ == "SmartRef<ContainedObject>" || typ == "const SmartRef<ContainedObject>" )
00097     return typeid(SmartRef<ContainedObject>);
00098   else if ( typ == "void*"            || typ == "const void*" )
00099     return typeid(void*);
00100   else
00101     return typeid(void*);
00102 }
00103 
00104 // Access the type name by type ID
00105 std::string DataTypeInfo::name(long typ)   {
00106   switch(typ)   {
00107   case UCHAR:
00108     return System::typeinfoName(typeid(unsigned char));
00109   case USHORT:
00110     return System::typeinfoName(typeid(unsigned short));
00111   case UINT:
00112     return System::typeinfoName(typeid(unsigned int));
00113   case ULONG:
00114     return System::typeinfoName(typeid(unsigned long));
00115   case CHAR:
00116     return System::typeinfoName(typeid(char));
00117   case SHORT:
00118     return System::typeinfoName(typeid(short));
00119   case INT:
00120     return System::typeinfoName(typeid(int));
00121   case LONG:
00122     return System::typeinfoName(typeid(long));
00123   case BOOL:
00124     return System::typeinfoName(typeid(bool));
00125   case FLOAT:
00126     return System::typeinfoName(typeid(float));
00127   case DOUBLE:
00128     return System::typeinfoName(typeid(double));
00129   case STRING:
00130     return System::typeinfoName(typeid(std::string));
00131   case LONG_STRING:
00132     return System::typeinfoName(typeid(std::string));
00133   case NTCHAR:
00134     return System::typeinfoName(typeid(char*));
00135   case LONG_NTCHAR:
00136     return System::typeinfoName(typeid(char*));
00137   case OBJECT_ADDR:
00138     return System::typeinfoName(typeid(IOpaqueAddress*));
00139   case OBJECT_REF:
00140     return System::typeinfoName(typeid(SmartRef<DataObject>));
00141   case CONTAINED_REF:
00142     return System::typeinfoName(typeid(SmartRef<ContainedObject>));
00143   case POINTER:
00144     return System::typeinfoName(typeid(void*));
00145   case UNKNOWN:
00146   default:
00147     return "";
00148   }
00149 }
00150 
00151 // Access the type name by type_info
00152 std::string DataTypeInfo::name(const std::type_info& typ)    {
00153   if ( typ == typeid(unsigned char) )
00154     return DataTypeInfo::name(UCHAR);
00155   else if ( typ == typeid(unsigned short) )
00156     return DataTypeInfo::name(USHORT);
00157   else if ( typ == typeid(unsigned int) )
00158     return DataTypeInfo::name(UINT);
00159   else if ( typ == typeid(unsigned long) )
00160     return DataTypeInfo::name(ULONG);
00161   else if ( typ == typeid(char) )
00162     return DataTypeInfo::name(CHAR);
00163   else if ( typ == typeid(short) )
00164     return DataTypeInfo::name(SHORT);
00165   else if ( typ == typeid(int) )
00166     return DataTypeInfo::name(INT);
00167   else if ( typ == typeid(long) )
00168     return DataTypeInfo::name(LONG);
00169   else if ( typ == typeid(bool) )
00170     return DataTypeInfo::name(BOOL);
00171   else if ( typ == typeid(float) )
00172     return DataTypeInfo::name(FLOAT);
00173   else if ( typ == typeid(double) )
00174     return DataTypeInfo::name(DOUBLE);
00175   else if ( typ == typeid(std::string) )
00176     return DataTypeInfo::name(STRING);
00177   else if ( typ == typeid(char*) )
00178     return DataTypeInfo::name(NTCHAR);
00179   else if ( typ == typeid(IOpaqueAddress*) )
00180     return DataTypeInfo::name(OBJECT_ADDR);
00181   else if ( typ == typeid(SmartRef<DataObject>) )
00182     return DataTypeInfo::name(OBJECT_REF);
00183   else if ( typ == typeid(SmartRef<ContainedObject>) )
00184     return DataTypeInfo::name(CONTAINED_REF);
00185   else if ( typ == typeid(void*) )
00186     return DataTypeInfo::name(POINTER);
00187   else
00188     return DataTypeInfo::name(UNKNOWN);
00189 }

Generated at Thu Jan 8 17:44:21 2009 for Gaudi Framework, version v20r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004