test
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 #include <string>
5 //
6 #include <typeinfo>
7 #include <boost/shared_ptr.hpp>
8 // externals
10 
11 namespace ora {
12 
13  class Object {
14  public:
15  Object();
16  template <typename T>
17  explicit Object( const T& obj );
18  Object( const void* ptr, const std::type_info& typeInfo );
19  Object( const void* ptr, const edm::TypeWithDict& type );
20  Object( const void* ptr, const std::string& typeName );
21  Object( const Object& rhs);
22  virtual ~Object();
23  Object& operator=( const Object& rhs);
24  bool operator==( const Object& rhs) const;
25  bool operator!=( const Object& rhs) const;
26  void* address() const;
27  const edm::TypeWithDict& type() const;
28  std::string typeName() const;
29  void* cast( const std::type_info& asType ) const;
30  template <typename T> T* cast() const;
31  boost::shared_ptr<void> makeShared() const;
32  void destruct();
33  private:
34  void* m_ptr;
36  };
37 
38  template<>
39  inline
40  Object::Object( const Object& rhs ):
41  m_ptr( rhs.m_ptr ),
42  m_type( rhs.m_type ){
43  }
44 
45 }
46 
47 template <typename T>
48 inline
50  Object( &obj, typeid(obj) ){
51 }
52 
53 template <typename T>
54 inline
55 T*
57  const std::type_info& typeInfo = typeid(T);
58  return static_cast<T*>( cast( typeInfo ) );
59 }
60 
61 #endif
62 
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 * m_ptr
Definition: Object.h:34
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:56
virtual ~Object()
Definition: Object.cc:32
bool operator!=(const Object &rhs) const
Definition: Object.cc:47
long double T
void destruct()
Definition: Object.cc:81