| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

# DataTypeInfo.h

Go to the documentation of this file.

    00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/DataTypeInfo.h,v 1.6 2008/10/27 19:22:20 marcocle Exp $
    00002 #ifndef GAUDIKERNEL_DATATYPES_H
    00003 #define GAUDIKERNEL_DATATYPES_H
    00004
    00005 #include <string>
    00006 #include <cstring>
    00007 #include "GaudiKernel/SmartRef.h"
    00008
    00009 class DataObject;
    00010 class ContainedObject;
    00011 class IOpaqueAddress;
    00012
    00017 class GAUDI_API DataTypeInfo {
    00018 private:
    00019   // This object cannot be instantiated!
    00020   DataTypeInfo() {}
    00021 public:
    00022   // Accepted Data type definitions
    00023   enum Type  {
    00024         UNKNOWN = 0,
    00025         UCHAR,        USHORT,        UINT,        ULONG,
    00026         CHAR,         SHORT,         INT,         LONG,
    00027         BOOL,         FLOAT,         DOUBLE,
    00028         STRING,       NTCHAR,
    00029         OBJECT_REF, CONTAINED_REF, POINTER, OBJECT_ADDR,
    00030         LONG_STRING,  LONG_NTCHAR, LONGLONG,  ULONGLONG
    00031   };
    00033   static Type ID( const bool)             { return BOOL;          }
    00035   static Type ID( const char)             { return CHAR;          }
    00037   static Type ID( const short)            { return SHORT;         }
    00039   static Type ID( const int)              { return INT;           }
    00041   static Type ID( const long)             { return LONG;          }
    00043   static Type ID( const long long)        { return LONGLONG;      }
    00045   static Type ID( const unsigned char)    { return UCHAR;         }
    00047   static Type ID( const unsigned short)   { return USHORT;        }
    00049   static Type ID( const unsigned int)     { return UINT;          }
    00051   static Type ID( const unsigned long)    { return ULONG;         }
    00053   static Type ID( const unsigned long long) { return ULONGLONG;   }
    00055   static Type ID( const float)            { return FLOAT;         }
    00057   static Type ID( const double)           { return DOUBLE;        }
    00059   static Type ID( const std::string&)     { return STRING;        }
    00061   static Type ID( const char*)            { return NTCHAR;        }
    00063   static Type ID( const IOpaqueAddress*)  { return OBJECT_ADDR;   }
    00065   static Type ID( const void*)            { return POINTER;       }
    00067   static Type ID( const SmartRef<DataObject>&)      { return OBJECT_REF;    }
    00069   static Type ID( const SmartRef<ContainedObject>&) { return CONTAINED_REF; }
    00070
    00072   static Type ID( const std::type_info& typ )   {
    00073     if ( typ == typeid(unsigned char) )
    00074       return UCHAR;
    00075     else if ( typ == typeid(unsigned short) )
    00076       return USHORT;
    00077     else if ( typ == typeid(unsigned int) )
    00078       return UINT;
    00079     else if ( typ == typeid(unsigned long) )
    00080       return ULONG;
    00081     else if ( typ == typeid(unsigned long long) )
    00082       return ULONGLONG;
    00083     else if ( typ == typeid(char) )
    00084       return CHAR;
    00085     else if ( typ == typeid(short) )
    00086       return SHORT;
    00087     else if ( typ == typeid(int) )
    00088       return INT;
    00089     else if ( typ == typeid(long) )
    00090       return LONG;
    00091     else if ( typ == typeid(long long) )
    00092       return LONGLONG;
    00093     else if ( typ == typeid(bool) )
    00094       return BOOL;
    00095     else if ( typ == typeid(float) )
    00096       return FLOAT;
    00097     else if ( typ == typeid(double) )
    00098       return DOUBLE;
    00099     else if ( typ == typeid(std::string) )
    00100       return STRING;
    00101     else if ( typ == typeid(char*) )
    00102       return NTCHAR;
    00103     else if ( typ == typeid(SmartRef<DataObject>) )
    00104       return OBJECT_REF;
    00105     else if ( typ == typeid(SmartRef<ContainedObject>) )
    00106       return CONTAINED_REF;
    00107     else if ( typ == typeid(IOpaqueAddress*) )
    00108       return OBJECT_ADDR;
    00109     else if ( typ == typeid(void*) )
    00110       return POINTER;
    00111     else
    00112       return UNKNOWN;
    00113   }
    00114
    00116   static const std::type_info& type( long typ )   {
    00117     switch(typ)   {
    00118     case UCHAR:
    00119       return typeid(unsigned char);
    00120     case USHORT:
    00121       return typeid(unsigned short);
    00122     case UINT:
    00123       return typeid(unsigned int);
    00124     case ULONG:
    00125       return typeid(unsigned long);
    00126     case ULONGLONG:
    00127       return typeid(unsigned long long);
    00128     case CHAR:
    00129       return typeid(char);
    00130     case SHORT:
    00131       return typeid(short);
    00132     case INT:
    00133       return typeid(int);
    00134     case LONG:
    00135       return typeid(long);
    00136     case LONGLONG:
    00137       return typeid(long long);
    00138     case BOOL:
    00139       return typeid(bool);
    00140     case FLOAT:
    00141       return typeid(float);
    00142     case DOUBLE:
    00143       return typeid(double);
    00144     case LONG_STRING:
    00145       return typeid(std::string);
    00146     case STRING:
    00147       return typeid(std::string);
    00148     case NTCHAR:
    00149       return typeid(char*);
    00150     case LONG_NTCHAR:
    00151       return typeid(char*);
    00152     case OBJECT_REF:
    00153       return typeid(SmartRef<DataObject>);
    00154     case CONTAINED_REF:
    00155       return typeid(SmartRef<ContainedObject>);
    00156     case OBJECT_ADDR:
    00157       return typeid(IOpaqueAddress*);
    00158     case POINTER:
    00159     case UNKNOWN:
    00160     default:
    00161       return typeid(void*);
    00162     }
    00163   }
    00164
    00166   static long size( long typ )   {
    00167     switch(typ)   {
    00168     case UCHAR:
    00169       return sizeof(unsigned char);
    00170     case USHORT:
    00171       return sizeof(unsigned short);
    00172     case UINT:
    00173       return sizeof(unsigned int);
    00174     case ULONG:
    00175       return sizeof(unsigned long);
    00176     case ULONGLONG:
    00177       return sizeof(unsigned long long);
    00178     case CHAR:
    00179       return sizeof(char);
    00180     case SHORT:
    00181       return sizeof(short);
    00182     case INT:
    00183       return sizeof(int);
    00184     case LONG:
    00185       return sizeof(long);
    00186     case LONGLONG:
    00187       return sizeof(long long);
    00188     case BOOL:
    00189       return sizeof(bool);
    00190     case FLOAT:
    00191       return sizeof(float);
    00192     case DOUBLE:
    00193       return sizeof(double);
    00194     case STRING:
    00195       return sizeof(std::string);
    00196     case LONG_STRING:
    00197       return sizeof(std::string);
    00198     case NTCHAR:
    00199       return sizeof(char*);
    00200     case LONG_NTCHAR:
    00201       return sizeof(char*);
    00202     case OBJECT_ADDR:
    00203     case POINTER:
    00204     case OBJECT_REF:
    00205     case CONTAINED_REF:
    00206     case UNKNOWN:
    00207     default:
    00208       return 0;
    00209     }
    00210   }
    00211
    00213   static long size( const std::type_info& typ )   {
    00214     return size( ID(typ) );
    00215   }
    00216
    00218   static int copy( void* tar, const void* src, long typ, int numObj )   {
    00219     switch(typ)   {
    00220     case UCHAR:      numObj *= sizeof(unsigned char);       break;
    00221     case USHORT:     numObj *= sizeof(unsigned short);      break;
    00222     case UINT:       numObj *= sizeof(unsigned int);        break;
    00223     case ULONG:      numObj *= sizeof(unsigned long);       break;
    00224     case ULONGLONG:  numObj *= sizeof(unsigned long long);  break;
    00225     case CHAR:       numObj *= sizeof(char);                break;
    00226     case SHORT:      numObj *= sizeof(short);               break;
    00227     case INT:        numObj *= sizeof(int);                 break;
    00228     case LONG:       numObj *= sizeof(long);                break;
    00229     case LONGLONG:   numObj *= sizeof(long long);           break;
    00230     case BOOL:       numObj *= sizeof(bool);                break;
    00231     case FLOAT:      numObj *= sizeof(float);               break;
    00232     case DOUBLE:     numObj *= sizeof(double);              break;
    00233     case UNKNOWN:
    00234     default:         numObj *= 0;                           break;
    00235     }
    00236     memcpy(tar, src, numObj);
    00237     return numObj;
    00238   }
    00239
    00240   // Access the type name by type ID
    00241   static std::string name(long typ);
    00242   // Access the type name by type_info
    00243   static std::string name(const std::type_info& typ);
    00245   static Type idByName( const std::string& typ );
    00247   static const std::type_info& typeByName( const std::string& typ );
    00248 };
    00249 #endif // GAUDIKERNEL_DATATYPES_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines