00001
00002
00003 #ifndef XAODROOTACCESS_TOOLS_THOLDER_H
00004 #define XAODROOTACCESS_TOOLS_THOLDER_H
00005
00006
00007 #include <map>
00008
00009
00010 #include <Rtypes.h>
00011
00012
00013 namespace std {
00014 class type_info;
00015 }
00016 class TClass;
00017
00018 namespace xAOD {
00019
00036 class THolder {
00037
00038 public:
00040 THolder();
00042 THolder( void* object, ::TClass* type, ::Bool_t owner = kTRUE );
00044 THolder( void* object, const std::type_info& type,
00045 ::Bool_t owner = kTRUE );
00047 THolder( const THolder& parent );
00049 THolder( THolder&& parent );
00051 virtual ~THolder();
00052
00054 THolder& operator=( const THolder& rhs );
00056 THolder& operator=( THolder&& rhs );
00057
00059 void* get() const;
00061 void** getPtr();
00062
00064 virtual void set( void* obj );
00065
00067 ::Bool_t isOwner() const;
00069 void setOwner( ::Bool_t state = kTRUE );
00070
00072 virtual void* getAs( const std::type_info& tid,
00073 ::Bool_t silent = kFALSE ) const;
00075 virtual const void* getAsConst( const std::type_info& tid,
00076 ::Bool_t silent = kFALSE ) const;
00077
00079 ::TClass* getClass() const;
00081 const std::type_info* getTypeInfo() const;
00082
00084 void renew();
00085
00086 protected:
00088 void deleteObject();
00089
00091 void* m_object;
00093 ::TClass* m_type;
00095 const std::type_info* m_typeInfo;
00097 ::Bool_t m_owner;
00098
00100 typedef std::map< const std::type_info*, TClass* > TypeCache_t;
00102 static TypeCache_t s_typeMap;
00103
00105 typedef std::map< void*, int > SharedCount_t;
00107 static SharedCount_t s_sharedCount;
00108
00109 };
00110
00111 }
00112
00113 #endif // XAODROOTACCESS_TOOLS_THOLDER_H