00001
00002
00003 #ifndef XAODROOTACCESS_TSTORE_H
00004 #define XAODROOTACCESS_TSTORE_H
00005
00006
00007 #include <string>
00008 #include <map>
00009 #include <memory>
00010
00011
00012 #include <Rtypes.h>
00013
00014
00015 #ifndef __CINT__
00016 # include "AthContainers/ConstDataVector.h"
00017 #endif // __CINT__
00018
00019
00020 #include "xAODRootAccess/tools/TReturnCode.h"
00021
00022 namespace xAOD {
00023
00024
00025 class THolder;
00026 class TEvent;
00027
00045 class TStore {
00046
00048 friend class TEvent;
00049
00050 public:
00052 TStore();
00054 virtual ~TStore();
00055
00057 void setActive();
00058
00061
00063 template< typename T >
00064 ::Bool_t contains( const std::string& key ) const;
00065
00067 template< typename T >
00068 ::Bool_t isConst( const std::string& key ) const;
00069
00071 template< typename T >
00072 TReturnCode retrieve( const T*& obj, const std::string& key ) const;
00074 template< typename T >
00075 TReturnCode retrieve( T*& obj, const std::string& key ) const;
00076
00078 template< typename T >
00079 TReturnCode record( T* obj, const std::string& key );
00081 template< typename T >
00082 TReturnCode record( std::unique_ptr< T > obj, const std::string& key );
00083
00085 TReturnCode remove( const std::string& key );
00087 TReturnCode remove( void* ptr );
00088
00090 void clear();
00091
00093
00095 void print() const;
00096
00097 protected:
00099 ::Bool_t contains( const std::string& key,
00100 const std::type_info& ti ) const;
00102 ::Bool_t isConst( const std::string& key,
00103 const std::type_info& ti ) const;
00105 void* getObject( const std::string& key, const std::type_info& ti ) const;
00107 const void* getConstObject( const std::string& key,
00108 const std::type_info& ti ) const;
00110 TReturnCode record( void* obj, const std::string& key,
00111 const std::string& classname,
00112 ::Bool_t isOwner = kTRUE );
00114 TReturnCode record( void* obj, const std::string& key,
00115 const std::type_info& ti );
00116 #if !defined(__GCCXML__) and !defined(__CINT__)
00118 template< class T >
00119 TReturnCode record( ConstDataVector< T >* obj, const std::string& key,
00120 const std::type_info& ti );
00121 #endif // not __GCCXML__ or __CINT__
00123 TReturnCode record( THolder* hldr, const std::string& key );
00124
00127
00129 ::Bool_t contains( uint32_t hash ) const;
00131 ::Bool_t contains( const void* ptr ) const;
00133 const std::string& getName( uint32_t hash ) const;
00135 const std::string& getName( const void* ptr ) const;
00136
00138
00140 typedef std::map< std::string, THolder* > Objects_t;
00142 typedef std::map< uint32_t, std::string > HashedKeys_t;
00143
00145 Objects_t m_objects;
00147 HashedKeys_t m_keys;
00148
00149 };
00150
00151 }
00152
00153
00154 #if !defined(__GCCXML__) and !defined(__CINT__)
00155 # include "TStore.icc"
00156 #endif // not __GCCXML__ or __CINT__
00157
00158 #endif // XAODROOTACCESS_TSTORE_H