ATLAS Offline Software
AuxContainerBase.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
5 #ifndef XAODCORE_AUXCONTAINERBASE_H
6 #define XAODCORE_AUXCONTAINERBASE_H
7 
8 // STL include(s):
9 #include <vector>
10 #include <string>
11 #include <memory>
12 
13 // EDM include(s):
20 #include "CxxUtils/CachedPointer.h"
22 #ifndef XAOD_STANDALONE
23 # include "AthenaKernel/ILockable.h"
24 #endif // not XAOD_STANDALONE
25 
26 // Local include(s):
27 #include "xAODCore/AuxSelection.h"
28 
29 // Forward declaration(s):
30 namespace SG {
31  class IAuxTypeVector;
32 }
34 namespace std { namespace pmr {
35 class memory_resource;
36 }}
37 
39 namespace xAOD {
40 
54  public SG::IAuxStoreIO,
55  public SG::IAuxStoreHolder
56 #ifndef XAOD_STANDALONE
57  , public ILockable
58 #endif // not XAOD_STANDALONE
59  {
60 
61  public:
66 
68  AuxContainerBase( bool allowDynamicVars = true );
70  AuxContainerBase( std::pmr::memory_resource* memResource,
71  bool allowDynamicVars = true );
76  std::pmr::memory_resource* memResource = nullptr );
79 
82 
85 
87  virtual SG::IAuxStore* getStore() override;
88  virtual const SG::IAuxStore* getStore() const override;
90  virtual void setStore( SG::IAuxStore* store ) override;
92  virtual AuxStoreType getStoreType() const override { return AST_ContainerStore; }
93 
95  std::pmr::memory_resource* memResource();
96 
98 
101 
103  virtual const void* getData( auxid_t auxid ) const override;
104 
106  virtual const SG::IAuxTypeVector* getVector (SG::auxid_t auxid) const override final;
107 
109  virtual const auxid_set_t& getAuxIDs() const override;
110 
112  virtual const auxid_set_t& getDecorIDs() const override;
113 
115  virtual bool isDecoration (auxid_t auxid) const override;
116 
118  virtual void* getDecoration( auxid_t auxid, size_t size,
119  size_t capacity ) override;
120 
122  virtual void lock() override;
123 
125  virtual bool clearDecorations() override;
126 
128  virtual size_t size() const override;
129 
131  virtual void lockDecoration (SG::auxid_t auxid) override;
132 
134  virtual const SG::IAuxTypeVector* linkedVector (SG::auxid_t auxid) const override;
135 
137 
140 
142  virtual void* getData( auxid_t auxid, size_t size,
143  size_t capacity ) override;
144 
146  virtual const auxid_set_t& getWritableAuxIDs() const override;
147 
149  virtual bool resize( size_t size ) override;
151  virtual void reserve( size_t size ) override;
153  virtual void shift( size_t pos, ptrdiff_t offs ) override;
155  virtual bool insertMove (size_t pos,
156  IAuxStore& other,
157  const SG::auxid_set_t& ignore) override;
159  virtual bool setOption( auxid_t id, const SG::AuxDataOption& option ) override;
160 
162  virtual SG::IAuxTypeVector* linkedVector (SG::auxid_t auxid) override;
163 
165 
168 
170  virtual const void* getIOData( auxid_t auxid ) const override;
171 
173  virtual const std::type_info* getIOType( auxid_t auxid ) const override;
174 
176  virtual const auxid_set_t& getDynamicAuxIDs() const override;
177 
179  virtual SG::auxid_set_t getSelectedAuxIDs() const override;
180 
182 
185 
187  const char* name() const;
189  void setName( const char* name );
190 
192 
194  template <class T, class ALLOC = std::allocator<T> >
195  using AuxVariable_t = std::vector<T, ALLOC>;
196  template <class T, class ALLOC = std::allocator<T> >
198 
200  template< typename T, typename ALLOC >
201  auxid_t getAuxID( const std::string& name,
202  std::vector< T, ALLOC >& /*vec*/,
205  const SG::auxid_t linkedVariable = SG::null_auxid );
207  template< typename T >
208  auxid_t getAuxID( const std::string& name,
209  SG::PackedContainer< T >& /*vec*/,
212  const SG::auxid_t linkedVariable = SG::null_auxid );
214  template< typename T, typename ALLOC >
215  void regAuxVar( auxid_t auxid, const std::string& name,
216  std::vector< T, ALLOC >& vec );
217 
219  template< typename T >
220  void regAuxVar( auxid_t auxid, const std::string& name,
222 
223  private:
224  friend class ::xAODAuxContainerBaseCnv;
225 
227  template< typename ELT, typename CONT >
228  void regAuxVar1( auxid_t auxid, const std::string& name,
229  CONT& vec );
230 
234  std::vector< SG::IAuxTypeVector* > m_vecs;
235 
243  bool m_locked;
244 
247  typedef AthContainers_detail::lock_guard< mutex_t > guard_t;
248  mutable mutex_t m_mutex;
249 
251  std::string m_name;
252 
255 
256  }; // class AuxContainerBase
257 
258 } // namespace xAOD
259 
260 // Declare a class ID for the class:
261 #include "xAODCore/CLASS_DEF.h"
262 CLASS_DEF( xAOD::AuxContainerBase, 1225080690, 3 )
263 
264 // Describe the inheritance of the class:
265 #include "xAODCore/BaseInfo.h"
268 
269 // Include the template implementation:
270 #include "AuxContainerBase.icc"
271 
272 #endif // XAODCORE_AUXCONTAINERBASE_H
xAOD::AuxContainerBase::m_name
std::string m_name
Name of the container in memory. Set externally.
Definition: AuxContainerBase.h:251
xAOD::AuxContainerBase::lock
virtual void lock() override
Lock the container.
Definition: AuxContainerBase.cxx:342
xAOD::AuxContainerBase::setStore
virtual void setStore(SG::IAuxStore *store) override
Set a different internal store object.
Definition: AuxContainerBase.cxx:194
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
SG_BASES3
SG_BASES3(xAOD::AuxContainerBase, SG::IAuxStore, SG::IAuxStoreIO, SG::IAuxStoreHolder)
xAOD::AuxContainerBase::getIOType
virtual const std::type_info * getIOType(auxid_t auxid) const override
Return the type of the data to be stored for one aux data item.
Definition: AuxContainerBase.cxx:683
xAOD::AuxContainerBase::name
const char * name() const
Get the name of the container instance.
Definition: AuxContainerBase.cxx:742
PackedContainer.h
Container to hold aux data to be stored in a packed form.
IAuxStoreHolder.h
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
xAOD::AuxContainerBase::clearDecorations
virtual bool clearDecorations() override
Clear all decorations.
Definition: AuxContainerBase.cxx:356
xAOD::AuxContainerBase::m_store
SG::IAuxStore * m_store
Internal dynamic auxiliary store object.
Definition: AuxContainerBase.h:237
xAOD::AuxContainerBase::memResource
std::pmr::memory_resource * memResource()
Return the memory resource to use.
Definition: AuxContainerBase.cxx:158
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
xAOD::AuxContainerBase::linkedVector
virtual const SG::IAuxTypeVector * linkedVector(SG::auxid_t auxid) const override
Return interface for a linked variable.
Definition: AuxContainerBase.cxx:395
xAOD::AuxContainerBase::operator=
AuxContainerBase & operator=(const AuxContainerBase &rhs)
Assignment operator.
Definition: AuxContainerBase.cxx:118
xAOD::AuxContainerBase::guard_t
AthContainers_detail::lock_guard< mutex_t > guard_t
Definition: AuxContainerBase.h:247
xAOD::AuxContainerBase::getAuxIDs
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
Definition: AuxContainerBase.cxx:274
xAOD::AuxContainerBase::setOption
virtual bool setOption(auxid_t id, const SG::AuxDataOption &option) override
Make an option setting on an aux variable.
Definition: AuxContainerBase.cxx:637
xAOD::AuxContainerBase::isDecoration
virtual bool isDecoration(auxid_t auxid) const override
Test if a variable is a decoration.
Definition: AuxContainerBase.cxx:290
ILockable.h
Interface to allow an object to lock itself when made const in SG.
xAOD::AuxContainerBase
Common base class for the auxiliary containers.
Definition: AuxContainerBase.h:59
xAOD::other
@ other
Definition: TrackingPrimitives.h:509
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
xAODAuxContainerBaseCnv
POOL converter for the xAOD::AuxContainerBase class.
Definition: xAODAuxContainerBaseCnv.h:32
xAOD::AuxContainerBase::getStoreType
virtual AuxStoreType getStoreType() const override
Return the type of the store object.
Definition: AuxContainerBase.h:92
xAOD::AuxContainerBase::m_mutex
mutex_t m_mutex
Definition: AuxContainerBase.h:248
xAOD::AuxContainerBase::resize
virtual bool resize(size_t size) override
Resize the arrays to a given size.
Definition: AuxContainerBase.cxx:504
AuxContainerBase.icc
xAOD::AuxContainerBase::~AuxContainerBase
~AuxContainerBase()
Destructor.
Definition: AuxContainerBase.cxx:99
CachedPointer.h
Cached pointer with atomic update.
SG::IAuxStoreIO
Interface providing I/O for a generic auxiliary store.
Definition: IAuxStoreIO.h:44
xAOD::AuxContainerBase::getStore
virtual SG::IAuxStore * getStore() override
Get the currently used internal store object.
Definition: AuxContainerBase.cxx:153
xAOD::AuxContainerBase::size
virtual size_t size() const override
Get the size of the container.
Definition: AuxContainerBase.cxx:429
SG::IAuxStoreHolder::AuxStoreType
AuxStoreType
Type of the auxiliary store.
Definition: IAuxStoreHolder.h:66
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
xAOD::AuxContainerBase::regAuxVar1
void regAuxVar1(auxid_t auxid, const std::string &name, CONT &vec)
Common code between regAuxVar cases.
xAOD::AuxContainerBase::getDynamicAuxIDs
virtual const auxid_set_t & getDynamicAuxIDs() const override
Get the types(names) of variables created dynamically.
Definition: AuxContainerBase.cxx:700
xAOD::AuxContainerBase::reserve
virtual void reserve(size_t size) override
Reserve a given size for the arrays.
Definition: AuxContainerBase.cxx:532
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
xAOD::AuxContainerBase::regAuxVar
void regAuxVar(auxid_t auxid, const std::string &name, SG::PackedContainer< T > &vec)
Register one of the persistent variables internally.
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
xAOD::AuxContainerBase::auxid_set_t
SG::auxid_set_t auxid_set_t
The aux ID set type definition.
Definition: AuxContainerBase.h:65
xAOD::AuxContainerBase::m_auxids
auxid_set_t m_auxids
Internal list of all available variables.
Definition: AuxContainerBase.h:232
xAOD::AuxContainerBase::m_vecs
std::vector< SG::IAuxTypeVector * > m_vecs
Internal list of all managed variables.
Definition: AuxContainerBase.h:234
xAOD::AuxContainerBase::regAuxVar
void regAuxVar(auxid_t auxid, const std::string &name, std::vector< T, ALLOC > &vec)
Register one of the persistent variables internally.
IAuxStoreIO.h
Interface providing I/O for a generic auxiliary store.
xAOD::AuxContainerBase::shift
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the contents of the stored arrays.
Definition: AuxContainerBase.cxx:557
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::AuxContainerBase::getDecorIDs
virtual const auxid_set_t & getDecorIDs() const override
Get the types(names) of decorations handled by this container.
Definition: AuxContainerBase.cxx:281
xAOD::AuxContainerBase::getDecoration
virtual void * getDecoration(auxid_t auxid, size_t size, size_t capacity) override
Get a pointer to a given array, as a decoration.
Definition: AuxContainerBase.cxx:299
SG::AuxVarFlags
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition: AuxTypes.h:58
SG::AuxDataOption
Hold information about an option setting request.
Definition: AuxDataOption.h:37
xAOD::AuxContainerBase::getSelectedAuxIDs
virtual SG::auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected dynamic Aux variables (for writing)
Definition: AuxContainerBase.cxx:720
xAOD::AuxContainerBase::getVector
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override final
Return vector interface for one aux data item.
Definition: AuxContainerBase.cxx:238
xAOD::AuxContainerBase::getWritableAuxIDs
virtual const auxid_set_t & getWritableAuxIDs() const override
Return a set of writable data identifiers.
Definition: AuxContainerBase.cxx:497
xAOD::AuxContainerBase::getData
virtual const void * getData(auxid_t auxid) const override
Get a pointer to a given array.
Definition: AuxContainerBase.cxx:229
threading.h
Threading definitions.
CLASS_DEF.h
File providing the different SG_BASE macros.
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
xAOD::AuxContainerBase::auxid_t
SG::auxid_t auxid_t
The aux ID type definition.
Definition: AuxContainerBase.h:63
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
xAOD::AuxContainerBase::ATLAS_THREAD_SAFE
CxxUtils::CachedPointer< std::pmr::memory_resource > m_memResource ATLAS_THREAD_SAFE
Memory resource to use for this container.
Definition: AuxContainerBase.h:254
AuxSelection.h
SG::PackedContainer
Container to hold aux data to be stored in a packed form.
Definition: PackedContainer.h:50
xAOD::AuxContainerBase::mutex_t
AthContainers_detail::mutex mutex_t
Mutex for multithread synchronization.
Definition: AuxContainerBase.h:246
CxxUtils::CachedPointer< std::pmr::memory_resource >
xAOD::AuxContainerBase::insertMove
virtual bool insertMove(size_t pos, IAuxStore &other, const SG::auxid_set_t &ignore) override
Insert contents of another store via move.
Definition: AuxContainerBase.cxx:583
xAOD::AuxContainerBase::m_locked
bool m_locked
Has the container been locked?
Definition: AuxContainerBase.h:243
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
xAOD::AuxContainerBase::lockDecoration
virtual void lockDecoration(SG::auxid_t auxid) override
Lock a decoration.
Definition: AuxContainerBase.cxx:386
xAOD::AuxContainerBase::m_ownsStore
bool m_ownsStore
Flag deciding if the object owns the dynamic store or not.
Definition: AuxContainerBase.h:241
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
IAuxStore.h
Interface for non-const operations on an auxiliary store.
ILockable
Interface to allow an object to lock itself when made const in SG.
Definition: ILockable.h:32
xAOD::AuxContainerBase::m_storeIO
SG::IAuxStoreIO * m_storeIO
The IO interface to the internal auxiliary store.
Definition: AuxContainerBase.h:239
xAOD::AuxContainerBase::AuxContainerBase
AuxContainerBase(bool allowDynamicVars=true)
Default constructor.
Definition: AuxContainerBase.cxx:30
xAOD::AuxContainerBase::getIOData
virtual const void * getIOData(auxid_t auxid) const override
Get a pointer to the data being stored for one aux data item.
Definition: AuxContainerBase.cxx:658
xAOD::AuxContainerBase::getAuxID
auxid_t getAuxID(const std::string &name, std::vector< T, ALLOC > &, SG::AuxVarFlags flags=SG::AuxVarFlags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
Get the auxiliary ID for one of the persistent variables.
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
xAOD::AuxContainerBase::getAuxID
auxid_t getAuxID(const std::string &name, SG::PackedContainer< T > &, SG::AuxVarFlags flags=SG::AuxVarFlags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
Get the auxiliary ID for one of the persistent variables.
xAOD::AuxContainerBase::setName
void setName(const char *name)
Set the name of the container instance.
Definition: AuxContainerBase.cxx:747
checker_macros.h
Define macros for attributes used to control the static checker.
SG::IAuxStoreHolder
Interface for objects taking part in direct ROOT I/O.
Definition: IAuxStoreHolder.h:36
xAOD::AuxContainerBase::LinkedVariable_t
AuxVariable_t< T, ALLOC > LinkedVariable_t
Definition: AuxContainerBase.h:197
xAOD::AuxContainerBase::AuxVariable_t
std::vector< T, ALLOC > AuxVariable_t
Declare how to wrap variables for this sort of base.
Definition: AuxContainerBase.h:195
SG::IAuxStoreHolder::AST_ContainerStore
@ AST_ContainerStore
The store describes a container.
Definition: IAuxStoreHolder.h:68