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
6 
8  m_ptr(0),
9  m_type(){
10 }
11 
12 ora::Object::Object( const void* ptr, const std::type_info& typeInfo ):
13  m_ptr( const_cast<void*>(ptr) ){
14  m_type = ClassUtils::lookupDictionary( typeInfo, true );
15 }
16 
17 ora::Object::Object( const void* ptr, const edm::TypeWithDict& type ):
18  m_ptr( const_cast<void*>(ptr) ),
19  m_type( type ){
20 }
21 
22 ora::Object::Object( const void* ptr, const std::string& typeName ):
23  m_ptr( const_cast<void*>(ptr) ),
24  m_type(edm::TypeWithDict::byName( typeName )){
25 }
26 
27 ora::Object::Object( const Object& rhs):
28  m_ptr( rhs.m_ptr ),
29  m_type( rhs.m_type ){
30 }
31 
33 }
34 
36  m_ptr = rhs.m_ptr;
37  m_type = rhs.m_type;
38  return *this;
39 }
40 
41 bool ora::Object::operator==( const Object& rhs) const{
42  if( m_ptr != rhs.m_ptr ) return false;
43  if( m_type != rhs.m_type ) return false;
44  return true;
45 }
46 
47 bool ora::Object::operator!=( const Object& rhs) const{
48  return !operator==( rhs );
49 }
50 
51 void* ora::Object::address() const {
52  return m_ptr;
53 }
54 
56  return m_type;
57 }
58 
60  return m_type.cppName();
61 }
62 
63 void* ora::Object::cast( const std::type_info& typeInfo ) const{
64  edm::TypeWithDict castType = ClassUtils::lookupDictionary( typeInfo );
65  if( ! m_type ){
66  throwException( "Object input class has not been found in the dictionary.",
67  "Object::cast" );
68 
69  }
70  return ClassUtils::upCast( m_type, m_ptr, castType );
71 }
72 
73 boost::shared_ptr<void> ora::Object::makeShared( ) const {
74  boost::shared_ptr<void> ret;
75  if( m_ptr ) {
76  ret = boost::shared_ptr<void>( m_ptr, RflxDeleter( m_type ) );
77  }
78  return ret;
79 }
80 
82  if( ! m_type ){
83  throwException( "Object input class has not been found in the dictionary.",
84  "Object::destruct" );
85 
86  }
87  if( m_ptr ){
88  m_type.destruct( m_ptr );
89  m_ptr = 0;
90  }
91 }
92 
type
Definition: HCALResponse.h:21
boost::shared_ptr< void > makeShared() const
Definition: Object.cc:73
std::string typeName() const
Definition: Object.cc:59
const edm::TypeWithDict & type() const
Definition: Object.cc:55
void * address() const
Definition: Object.cc:51
edm::TypeWithDict m_type
Definition: Object.h:35
void * upCast(const edm::TypeWithDict &type, void *ptr, const edm::TypeWithDict &asType)
Definition: ClassUtils.cc:38
void * m_ptr
Definition: Object.h:34
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
bool operator==(const Object &rhs) const
Definition: Object.cc:41
edm::TypeWithDict lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:170
Object()
Definition: Object.cc:7
Object & operator=(const Object &rhs)
Definition: Object.cc:35
T * cast() const
Definition: Object.h:56
virtual ~Object()
Definition: Object.cc:32
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:47
void destruct()
Definition: Object.cc:81