CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/CondCore/ORA/interface/Object.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_OBJECT_H
00002 #define INCLUDE_ORA_OBJECT_H
00003 
00004 //
00005 #include <typeinfo>
00006 // externals
00007 #include "Reflex/Type.h"
00008 
00009 namespace ora {
00010   
00011   class Object {
00012     public:
00013     Object();
00014     Object( const void* ptr, const Reflex::Type& type );
00015     Object( const Object& rhs);
00016     virtual ~Object();
00017     Object& operator=( const Object& rhs);
00018     bool operator==( const Object& rhs) const;
00019     bool operator!=( const Object& rhs) const;
00020     void* address() const;
00021     const Reflex::Type& type() const;
00022     std::string typeName() const;
00023     void* cast( const std::type_info& asType ) const;
00024     template <typename T> T* cast() const;
00025     void destruct();
00026     private:
00027     void* m_ptr;
00028     Reflex::Type m_type;
00029   };
00030 }
00031 
00032 template <typename T>
00033 inline
00034 T* 
00035 ora::Object::cast() const {
00036   const std::type_info& typeInfo = typeid(T);
00037   return static_cast<T*>( cast( typeInfo ) );
00038 }
00039 
00040 #endif
00041