CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Object.cc
Go to the documentation of this file.
3 #include "ClassUtils.h"
4 // externals
5 #include "Reflex/Object.h"
6 
8  m_ptr(0),
9  m_type(){
10 }
11 
12 ora::Object::Object( const void* ptr, const Reflex::Type& type ):
13  m_ptr( const_cast<void*>(ptr) ),
14  m_type( type ){
15 }
16 
17 ora::Object::Object( const void* ptr, const std::string& typeName ):
18  m_ptr( const_cast<void*>(ptr) ),
19  m_type(Reflex::Type::ByName( typeName )){
20 }
21 
23  m_ptr( rhs.m_ptr ),
24  m_type( rhs.m_type ){
25 }
26 
28 }
29 
31  m_ptr = rhs.m_ptr;
32  m_type = rhs.m_type;
33  return *this;
34 }
35 
36 bool ora::Object::operator==( const Object& rhs) const{
37  if( m_ptr != rhs.m_ptr ) return false;
38  if( m_type != rhs.m_type ) return false;
39  return true;
40 }
41 
42 bool ora::Object::operator!=( const Object& rhs) const{
43  return !operator==( rhs );
44 }
45 
46 void* ora::Object::address() const {
47  return m_ptr;
48 }
49 
51  return m_type;
52 }
53 
55  return m_type.Name( Reflex::SCOPED );
56 }
57 
58 void* ora::Object::cast( const std::type_info& typeInfo ) const{
59  Reflex::Type castType = ClassUtils::lookupDictionary( typeInfo );
60  if( ! m_type ){
61  throwException( "Object input class has not been found in the dictionary.",
62  "Object::cast" );
63 
64  }
65  return ClassUtils::upCast( m_type, m_ptr, castType );
66 }
67 
68 boost::shared_ptr<void> ora::Object::makeShared() const {
69  return boost::shared_ptr<void>( m_ptr, RflxDeleter( m_type ) );
70 }
71 
73  if( ! m_type ){
74  throwException( "Object input class has not been found in the dictionary.",
75  "Object::destruct" );
76 
77  }
78  if( m_ptr ){
79  m_type.Destruct( m_ptr );
80  m_ptr = 0;
81  }
82 }
83 
type
Definition: HCALResponse.h:21
boost::shared_ptr< void > makeShared() const
Definition: Object.cc:68
Reflex::Type m_type
Definition: Object.h:31
std::string typeName() const
Definition: Object.cc:54
void * address() const
Definition: Object.cc:46
bool operator==(const CaloTower &t1, const CaloTower &t2)
Definition: CaloTower.h:209
void * m_ptr
Definition: Object.h:30
bool operator==(const Object &rhs) const
Definition: Object.cc:36
Object()
Definition: Object.cc:7
Object & operator=(const Object &rhs)
Definition: Object.cc:30
T * cast() const
Definition: Object.h:38
virtual ~Object()
Definition: Object.cc:27
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
bool operator!=(const Object &rhs) const
Definition: Object.cc:42
const Reflex::Type & type() const
Definition: Object.cc:50
void * upCast(const Reflex::Type &type, void *ptr, const Reflex::Type &asType)
Definition: ClassUtils.cc:32
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
void destruct()
Definition: Object.cc:72