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 
18  m_ptr( rhs.m_ptr ),
19  m_type( rhs.m_type ){
20 }
21 
23 }
24 
26  m_ptr = rhs.m_ptr;
27  m_type = rhs.m_type;
28  return *this;
29 }
30 
31 bool ora::Object::operator==( const Object& rhs) const{
32  if( m_ptr != rhs.m_ptr ) return false;
33  if( m_type != rhs.m_type ) return false;
34  return true;
35 }
36 
37 bool ora::Object::operator!=( const Object& rhs) const{
38  return !operator==( rhs );
39 }
40 
41 void* ora::Object::address() const {
42  return m_ptr;
43 }
44 
46  return m_type;
47 }
48 
50  return m_type.Name( Reflex::SCOPED );
51 }
52 
53 void* ora::Object::cast( const std::type_info& typeInfo ) const{
54  Reflex::Type castType = ClassUtils::lookupDictionary( typeInfo );
55  if( ! m_type ){
56  throwException( "Object input class has not been found in the dictionary.",
57  "Object::cast" );
58 
59  }
60  return ClassUtils::upCast( m_type, m_ptr, castType );
61 }
62 
64  if( ! m_type ){
65  throwException( "Object input class has not been found in the dictionary.",
66  "Object::destruct" );
67 
68  }
69  if( m_ptr ){
70  m_type.Destruct( m_ptr );
71  m_ptr = 0;
72  }
73 }
74 
type
Definition: HCALResponse.h:21
Reflex::Type m_type
Definition: Object.h:28
std::string typeName() const
Definition: Object.cc:49
void * address() const
Definition: Object.cc:41
bool operator==(const CaloTower &t1, const CaloTower &t2)
Definition: CaloTower.h:211
void * m_ptr
Definition: Object.h:27
bool operator==(const Object &rhs) const
Definition: Object.cc:31
Object()
Definition: Object.cc:7
Object & operator=(const Object &rhs)
Definition: Object.cc:25
T * cast() const
Definition: Object.h:35
virtual ~Object()
Definition: Object.cc:22
bool operator!=(const Object &rhs) const
Definition: Object.cc:37
const Reflex::Type & type() const
Definition: Object.cc:45
void * upCast(const Reflex::Type &type, void *ptr, const Reflex::Type &asType)
Definition: ClassUtils.cc:32
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
void destruct()
Definition: Object.cc:63