CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CondCore/ORA/src/Object.cc

Go to the documentation of this file.
00001 #include "CondCore/ORA/interface/Object.h"
00002 #include "CondCore/ORA/interface/Exception.h"
00003 #include "ClassUtils.h"
00004 // externals
00005 #include "Reflex/Object.h"
00006 
00007 ora::Object::Object():
00008   m_ptr(0),
00009   m_type(){
00010 }
00011 
00012 ora::Object::Object( const void* ptr, const Reflex::Type& type ):
00013   m_ptr( const_cast<void*>(ptr) ),
00014   m_type( type ){
00015 }
00016 
00017 ora::Object::Object( const Object& rhs):
00018   m_ptr( rhs.m_ptr ),
00019   m_type( rhs.m_type ){
00020 }
00021 
00022 ora::Object::~Object(){
00023 }
00024 
00025 ora::Object& ora::Object::operator=( const Object& rhs){
00026   m_ptr = rhs.m_ptr;
00027   m_type = rhs.m_type;
00028   return *this;
00029 }
00030 
00031 bool ora::Object::operator==( const Object& rhs) const{
00032   if( m_ptr != rhs.m_ptr ) return false;
00033   if( m_type != rhs.m_type ) return false;
00034   return true;
00035 }
00036 
00037 bool ora::Object::operator!=( const Object& rhs) const{
00038   return !operator==( rhs );
00039 }
00040 
00041 void* ora::Object::address() const {
00042   return m_ptr;
00043 }
00044 
00045 const Reflex::Type& ora::Object::type() const {
00046   return m_type;
00047 }
00048 
00049 std::string ora::Object::typeName() const {
00050   return m_type.Name( Reflex::SCOPED );
00051 }
00052 
00053 void* ora::Object::cast( const std::type_info& typeInfo ) const{
00054   Reflex::Type castType = ClassUtils::lookupDictionary( typeInfo );
00055   if( ! m_type ){
00056     throwException( "Object input class has not been found in the dictionary.",
00057                     "Object::cast" );
00058     
00059   }
00060   return ClassUtils::upCast( m_type, m_ptr, castType );
00061 }
00062 
00063 void ora::Object::destruct() {
00064   if( ! m_type ){
00065     throwException( "Object input class has not been found in the dictionary.",
00066                     "Object::cast" );
00067     
00068   }
00069   if( m_ptr ){
00070     m_type.Destruct( m_ptr );
00071     m_ptr = 0;
00072   }
00073 }
00074