CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Object.h
Go to the documentation of this file.
1 #ifndef INCLUDE_ORA_OBJECT_H
2 #define INCLUDE_ORA_OBJECT_H
3 
4 //
5 #include <typeinfo>
6 #include <boost/shared_ptr.hpp>
7 // externals
8 #include "Reflex/Type.h"
9 
10 namespace ora {
11 
12  class Object {
13  public:
14  Object();
15  template <typename T>
16  explicit Object( const T& obj );
17  Object( const void* ptr, const std::type_info& typeInfo );
18  Object( const void* ptr, const Reflex::Type& type );
19  Object( const void* ptr, const std::string& typeName );
20  Object( const Object& rhs);
21  virtual ~Object();
22  Object& operator=( const Object& rhs);
23  bool operator==( const Object& rhs) const;
24  bool operator!=( const Object& rhs) const;
25  void* address() const;
26  const Reflex::Type& type() const;
27  std::string typeName() const;
28  void* cast( const std::type_info& asType ) const;
29  template <typename T> T* cast() const;
30  boost::shared_ptr<void> makeShared() const;
31  void destruct();
32  private:
33  void* m_ptr;
35  };
36 
37  template<>
38  inline
39  Object::Object( const Object& rhs ):
40  m_ptr( rhs.m_ptr ),
41  m_type( rhs.m_type ){
42  }
43 
44 }
45 
46 template <typename T>
47 inline
49  Object( &obj, typeid(obj) ){
50 }
51 
52 template <typename T>
53 inline
54 T*
56  const std::type_info& typeInfo = typeid(T);
57  return static_cast<T*>( cast( typeInfo ) );
58 }
59 
60 #endif
61 
type
Definition: HCALResponse.h:21
boost::shared_ptr< void > makeShared() const
Definition: Object.cc:73
Reflex::Type m_type
Definition: Object.h:34
std::string typeName() const
Definition: Object.cc:59
void * address() const
Definition: Object.cc:51
void * m_ptr
Definition: Object.h:33
bool operator==(const Object &rhs) const
Definition: Object.cc:41
Object()
Definition: Object.cc:7
Object & operator=(const Object &rhs)
Definition: Object.cc:35
T * cast() const
Definition: Object.h:55
virtual ~Object()
Definition: Object.cc:32
bool operator!=(const Object &rhs) const
Definition: Object.cc:47
const Reflex::Type & type() const
Definition: Object.cc:55
long double T
void destruct()
Definition: Object.cc:81