00001
00002
00003 #ifndef XAODCORE_AUXCONTAINERBASE_H
00004 #define XAODCORE_AUXCONTAINERBASE_H
00005
00006
00007 #include <vector>
00008 #include <string>
00009
00010
00011 #include "AthContainersInterfaces/IAuxStore.h"
00012 #include "AthContainersInterfaces/IAuxStoreIO.h"
00013 #include "AthContainersInterfaces/IAuxStoreHolder.h"
00014 #include "AthContainers/tools/threading.h"
00015 #include "AthContainers/PackedContainer.h"
00016 #ifndef XAOD_STANDALONE
00017 # include "AthenaKernel/ILockable.h"
00018 #endif // not XAOD_STANDALONE
00019
00020
00021 #include "xAODCore/AuxSelection.h"
00022
00023
00024 namespace SG {
00025 class IAuxTypeVector;
00026 }
00027
00029 namespace xAOD {
00030
00043 class AuxContainerBase : public SG::IAuxStore,
00044 public SG::IAuxStoreIO,
00045 public SG::IAuxStoreHolder
00046 #ifndef XAOD_STANDALONE
00047 , public ILockable
00048 #endif // not XAOD_STANDALONE
00049 {
00050
00051 public:
00053 typedef SG::auxid_t auxid_t;
00055 typedef SG::auxid_set_t auxid_set_t;
00056
00058 AuxContainerBase( bool allowDynamicVars = true );
00060 AuxContainerBase( const AuxContainerBase& parent );
00062 AuxContainerBase( const SG::IAuxStore* store );
00064 ~AuxContainerBase();
00065
00067 AuxContainerBase& operator=( const AuxContainerBase& rhs );
00068
00071
00073 virtual SG::IAuxStore* getStore() const;
00075 virtual void setStore( SG::IAuxStore* store );
00077 virtual AuxStoreType getStoreType() const { return AST_ContainerStore; }
00078
00080
00083
00085 virtual const void* getData( auxid_t auxid ) const;
00086
00088 virtual const auxid_set_t& getAuxIDs() const;
00089
00091 virtual void* getDecoration( auxid_t auxid, size_t size,
00092 size_t capacity );
00093
00095 virtual void lock();
00096
00098 virtual void clearDecorations();
00099
00101 virtual size_t size() const;
00102
00104
00107
00109 virtual void* getData( auxid_t auxid, size_t size,
00110 size_t capacity );
00111
00113 virtual const auxid_set_t& getWritableAuxIDs() const;
00114
00116 virtual void resize( size_t size );
00118 virtual void reserve( size_t size );
00120 virtual void shift( size_t pos, ptrdiff_t offs );
00122 virtual bool setOption( auxid_t id, const SG::AuxDataOption& option );
00123
00125
00128
00130 virtual const void* getIOData( auxid_t auxid ) const;
00131
00133 virtual const std::type_info* getIOType( auxid_t auxid ) const;
00134
00136 virtual const auxid_set_t& getDynamicAuxIDs() const;
00137
00139 virtual void selectAux( const std::set< std::string >& attributes );
00140
00142 virtual const SG::auxid_set_t& getSelectedAuxIDs() const;
00143
00145
00148
00150 const char* name() const;
00152 void setName( const char* name );
00153
00155
00156 protected:
00158 template< typename T >
00159 void regAuxVar( const std::string& name,
00160 std::vector< T >& vec );
00161
00163 template< typename T >
00164 void regAuxVar( const std::string& name,
00165 SG::PackedContainer< T >& vec );
00166
00167 private:
00169 template< typename ELT, typename CONT >
00170 void regAuxVar1( const std::string& name,
00171 CONT& vec );
00172
00174 AuxSelection m_selection;
00176 mutable auxid_set_t m_auxids;
00178 std::vector< SG::IAuxTypeVector* > m_vecs;
00179
00181 SG::IAuxStore* m_store;
00183 SG::IAuxStoreIO* m_storeIO;
00185 bool m_ownsStore;
00187 bool m_locked;
00188
00190 mutable size_t m_tick;
00191
00193 typedef AthContainers_detail::mutex mutex_t;
00194 typedef AthContainers_detail::lock_guard< mutex_t > guard_t;
00195 mutable mutex_t m_mutex;
00196
00198 struct TSAuxidSet {
00199 size_t m_tick;
00200 auxid_set_t m_set;
00201 TSAuxidSet( size_t tick, const auxid_set_t& set )
00202 : m_tick( tick ), m_set( set ) { }
00203 };
00205 mutable AthContainers_detail::thread_specific_ptr< TSAuxidSet > m_tsAuxids;
00206
00208 std::string m_name;
00209
00210 };
00211
00212 }
00213
00214
00215 #include "xAODCore/CLASS_DEF.h"
00216 CLASS_DEF( xAOD::AuxContainerBase, 1225080690, 1 )
00217
00218
00219 #include "xAODCore/BaseInfo.h"
00220 SG_BASES3( xAOD::AuxContainerBase, SG::IAuxStore, SG::IAuxStoreIO,
00221 SG::IAuxStoreHolder );
00222
00223
00224 #include "AuxContainerBase.icc"
00225
00226 #endif // XAODCORE_AUXCONTAINERBASE_H