ATLAS Offline Software
AuxTypeRegistry.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef ATHCONTAINERS_AUXTYPEREGISTRY_H
14 #define ATHCONTAINERS_AUXTYPEREGISTRY_H
15 
16 
21 #ifndef XAOD_STANDALONE
24 #endif
25 #include <cstddef>
26 #include <typeinfo>
27 #include <vector>
28 #include <unordered_map>
29 #include <functional>
30 
31 
32 namespace SG {
33 
34 
35 class AuxTypeRegistryImpl;
36 
37 
61 {
62 public:
64  // Now in AuxTypes.h to avoid cyclic header dependencies.
66 
67 
71  static AuxTypeRegistry& instance();
72 
73 
79  size_t numVariables() const;
80 
81 
94  template <class T, class ALLOC = AuxAllocator_t<T> >
95  SG::auxid_t getAuxID (const std::string& name,
96  const std::string& clsname = "",
97  const Flags flags = Flags::None,
98  const SG::auxid_t linkedVariable = SG::null_auxid);
99 
100 
115  SG::auxid_t getAuxID (const std::type_info& ti,
116  const std::string& name,
117  const std::string& clsname = "",
118  const Flags flags = Flags::None,
119  const SG::auxid_t linkedVariable = SG::null_auxid);
120 
121 
139  SG::auxid_t getAuxID (const std::type_info& ti_alloc,
140  const std::type_info& ti,
141  const std::string& name,
142  const std::string& clsname = "",
143  const Flags flags = Flags::None,
144  const SG::auxid_t linkedVariable = SG::null_auxid,
145  std::unique_ptr<IAuxTypeVectorFactory> (AuxTypeRegistry::*makeFactory) () const = &AuxTypeRegistry::makeFactoryNull);
146 
147 
163  SG::auxid_t getAuxID (const std::string& alloc_type,
164  const std::type_info& ti,
165  const std::string& name,
166  const std::string& clsname = "",
167  const Flags flags = Flags::None,
168  const SG::auxid_t linkedVariable = SG::null_auxid);
169 
170 
180  SG::auxid_t findAuxID (const std::string& name,
181  const std::string& clsname = "") const;
182 
183 
193  template <class T, class ALLOC = AuxAllocator_t<T> >
194  void checkAuxID (const SG::auxid_t auxid,
195  const Flags flags = Flags::None);
196 
197 
209  void checkAuxID (const SG::auxid_t auxid,
210  const std::type_info& ti,
211  const std::type_info& ti_alloc,
212  const Flags flags);
213 
214 
223  std::unique_ptr<IAuxTypeVector> makeVector (SG::auxid_t auxid,
224  size_t size,
225  size_t capacity) const;
226 
227 
245  std::unique_ptr<IAuxTypeVector> makeVectorFromData (SG::auxid_t auxid,
246  void* data,
247  IAuxTypeVector* linkedVector,
248  bool isPacked,
249  bool ownFlag) const;
250 
251 
256  std::string getName (SG::auxid_t auxid) const;
257 
258 
264  std::string getClassName (SG::auxid_t auxid) const;
265 
266 
271  const std::type_info* getType (SG::auxid_t auxid) const;
272 
273 
280  std::string getTypeName (SG::auxid_t auxid) const;
281 
282 
287  const std::type_info* getVecType (SG::auxid_t auxid) const;
288 
289 
296  std::string getVecTypeName (SG::auxid_t auxid) const;
297 
298 
303  const std::type_info* getAllocType (SG::auxid_t auxid) const;
304 
305 
310  size_t getEltSize (SG::auxid_t auxid) const;
311 
312 
317  Flags getFlags (SG::auxid_t auxid) const;
318 
319 
324  bool isLinked (SG::auxid_t auxid) const;
325 
326 
334  SG::auxid_t linkedVariable (SG::auxid_t auxid) const;
335 
336 
348  void copy (SG::auxid_t auxid,
349  AuxVectorData& dst, size_t dst_index,
350  const AuxVectorData& src, size_t src_index,
351  size_t n) const;
352 
353 
367  void copy (SG::auxid_t auxid,
368  AuxVectorData&& dst, size_t dst_index,
369  const AuxVectorData& src, size_t src_index,
370  size_t n) const;
371 
372 
385  void copyForOutput (SG::auxid_t auxid,
386  AuxVectorData& dst, size_t dst_index,
387  const AuxVectorData& src, size_t src_index,
388  size_t n) const;
389 
390 
403  void swap (SG::auxid_t auxid,
404  AuxVectorData& a, size_t aindex,
405  AuxVectorData& b, size_t bindex,
406  size_t n) const;
407 
408 
416  void clear (SG::auxid_t auxid,
417  AuxVectorData& dst, size_t dst_index,
418  size_t n) const;
419 
420 
429  const IAuxTypeVectorFactory* getFactory (const std::type_info& ti,
430  const std::type_info& ti_alloc);
431 
432 
441  const IAuxTypeVectorFactory* getFactory (const std::type_info& ti,
442  const std::string& alloc_name);
443 
444 
452  const IAuxTypeVectorFactory* getFactory (SG::auxid_t auxid) const;
453 
454 
466  const IAuxTypeVectorFactory*
467  addFactory (const std::type_info& ti,
468  const std::type_info& ti_alloc,
469  std::unique_ptr<const IAuxTypeVectorFactory> factory);
470 
471 
483  const IAuxTypeVectorFactory*
484  addFactory (const std::type_info& ti,
485  const std::string& ti_alloc_name,
486  std::unique_ptr<const IAuxTypeVectorFactory> factory);
487 
488 
489 #ifndef XAOD_STANDALONE
490 
501  const IStringPool& pool);
502 #endif
503 
504 
513  const std::string& inputRename (const std::string& key,
514  const std::string& name) const;
515 
516 
520  static bool isLinkedName (const std::string& name);
521 
522 
527  static std::string linkedName (const std::string& name);
528 
529 
534  static bool classNameHasLink (const std::string& className);
535 
536 
537 private:
538  friend class AuxTypeRegistryImpl;
539 
541  typedef AthContainers_detail::lock_guard<mutex_t> lock_t;
542 
548  AuxTypeRegistry();
549 
550 
555 
556 
560 
561 
571  template <class T, class ALLOC = AuxAllocator_t<T> >
572  std::unique_ptr<IAuxTypeVectorFactory> makeFactory() const;
573 
574 
581  std::unique_ptr<IAuxTypeVectorFactory> makeFactoryNull() const;
582 
583 
589  static std::string makeKey (const std::string& name,
590  const std::string& clsname);
591 };
592 
593 
594 } // namespace SG
595 
596 
598 
599 
600 #endif // not ATHCONTAINERS_AUXTYPEREGISTRY_H
SG::AuxTypeRegistry::getFactory
const IAuxTypeVectorFactory * getFactory(const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
Definition: AuxTypeRegistry.cxx:1110
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
IStringPool
Abstract interface for looking up strings/CLIDs in a pool.
Definition: IStringPool.h:28
SG::AuxTypeRegistry::makeVectorFromData
std::unique_ptr< IAuxTypeVector > makeVectorFromData(SG::auxid_t auxid, void *data, IAuxTypeVector *linkedVector, bool isPacked, bool ownFlag) const
Construct an IAuxTypeVector object from a vector.
Definition: AuxTypeRegistry.cxx:845
SG::AuxTypeRegistry::addFactory
const IAuxTypeVectorFactory * addFactory(const std::type_info &ti, const std::type_info &ti_alloc, std::unique_ptr< const IAuxTypeVectorFactory > factory)
Add a new type -> factory mapping.
Definition: AuxTypeRegistry.cxx:1172
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
SG::AuxTypeRegistry::findAuxID
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
Definition: AuxTypeRegistry.cxx:756
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
SG::AuxTypeRegistry::lock_t
AthContainers_detail::lock_guard< mutex_t > lock_t
Definition: AuxTypeRegistry.h:541
SG::AuxTypeRegistry::makeKey
static std::string makeKey(const std::string &name, const std::string &clsname)
Return the key used to look up an entry in m_auxids.
Definition: AuxTypeRegistry.cxx:863
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:881
AuxTypeVectorFactory.h
Factory object that creates vectors using AuxTypeVector.
SG::AuxTypeRegistry::getVecTypeName
std::string getVecTypeName(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
Definition: AuxTypeRegistry.cxx:951
pool
pool namespace
Definition: libname.h:15
SG::AuxTypeRegistry::inputRename
const std::string & inputRename(const std::string &key, const std::string &name) const
Check for an input renaming of an auxiliary variable.
Definition: AuxTypeRegistry.cxx:1273
SG::AuxTypeRegistry::getAllocType
const std::type_info * getAllocType(SG::auxid_t auxid) const
Return the type of the vector allocator.
Definition: AuxTypeRegistry.cxx:964
SG::AuxTypeRegistry::linkedName
static std::string linkedName(const std::string &name)
Given a variable name, return the name of the corresponding linked variable.
Definition: AuxTypeRegistry.cxx:1302
SG::AuxTypeRegistry::classNameHasLink
static bool classNameHasLink(const std::string &className)
Test to see if a class name corresponds to a class with a linked variable.
Definition: AuxTypeRegistry.cxx:1312
SG::AuxTypeRegistry::AuxTypeRegistry
AuxTypeRegistry()
Constructor.
Definition: AuxTypeRegistry.cxx:1212
SG::AuxTypeRegistry::copyForOutput
void copyForOutput(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const
Copy elements between vectors.
Definition: AuxTypeRegistry.cxx:1049
IAuxTypeVector.h
Abstract interface for manipulating vectors of arbitrary types.
SG::AuxTypeRegistry::~AuxTypeRegistry
~AuxTypeRegistry()
Destructor.
Definition: AuxTypeRegistry.cxx:1220
SG::AuxTypeRegistry::copy
void copy(SG::auxid_t auxid, AuxVectorData &&dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const
Copy elements between vectors.
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
SG::AuxTypeRegistry::mutex_t
AthContainers_detail::mutex mutex_t
Definition: AuxTypeRegistry.h:540
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::AuxTypeRegistry::getType
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
Definition: AuxTypeRegistry.cxx:908
SG::AuxTypeRegistryImpl
@Brief Implementation class for AuxTypeRegistry.
Definition: AuxTypeRegistry.cxx:45
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
SG::AuxTypeRegistry::swap
void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const
Swap elements between vectors.
Definition: AuxTypeRegistry.cxx:1073
Athena::InputRenameMap_t
SG::SGKeyMap< InputRenameEntry > InputRenameMap_t
Definition: InputRenameMap.h:32
IStringPool.h
Abstract interface for looking up strings/CLIDs in a pool.
SG::AuxTypeRegistry::getTypeName
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
Definition: AuxTypeRegistry.cxx:923
beamspotman.n
n
Definition: beamspotman.py:731
SG::AuxTypeRegistry::getFlags
Flags getFlags(SG::auxid_t auxid) const
Return flags associated with an auxiliary variable.
Definition: AuxTypeRegistry.cxx:990
InputRenameMap.h
Map keeping track of requested input renames.
SG::IAuxTypeVectorFactory
Interface for factory objects that create vectors.
Definition: IAuxTypeVectorFactory.h:50
SG::AuxTypeRegistry::linkedVariable
SG::auxid_t linkedVariable(SG::auxid_t auxid) const
Return the auxid if the linked variable, if there is one.
Definition: AuxTypeRegistry.cxx:1006
AuxTypeRegistry.icc
SG::AuxTypeRegistry::getEltSize
size_t getEltSize(SG::auxid_t auxid) const
Return size of an element in the STL vector.
Definition: AuxTypeRegistry.cxx:977
SG::AuxTypeRegistry::makeFactory
std::unique_ptr< IAuxTypeVectorFactory > makeFactory() const
Create an AuxTypeVectorFactory instance.
SG::AuxTypeRegistry::isLinkedName
static bool isLinkedName(const std::string &name)
Test if a variable name corresponds to a linked variable.
Definition: AuxTypeRegistry.cxx:1292
SG::AuxTypeRegistry::getVecType
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
Definition: AuxTypeRegistry.cxx:936
SG::AuxTypeRegistry::numVariables
size_t numVariables() const
Return the total number of registered auxiliary variable.
Definition: AuxTypeRegistry.cxx:651
SG::AuxVarFlags
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition: AuxTypes.h:58
SG::AuxTypeRegistry::clear
void clear(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, size_t n) const
Clear a range of elements within a vector.
Definition: AuxTypeRegistry.cxx:1091
SG::AuxTypeRegistry::getClassName
std::string getClassName(SG::auxid_t auxid) const
Return the class name associated with an aux data item (may be blank).
Definition: AuxTypeRegistry.cxx:895
SG::AuxTypeRegistry::makeVector
std::unique_ptr< IAuxTypeVector > makeVector(SG::auxid_t auxid, size_t size, size_t capacity) const
Construct a new vector to hold an aux item.
Definition: AuxTypeRegistry.cxx:817
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SG::AuxTypeRegistry::isLinked
bool isLinked(SG::auxid_t auxid) const
Test whether this is a linked variable.
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SG::AuxTypeRegistry::setInputRenameMap
void setInputRenameMap(const Athena::InputRenameMap_t *map, const IStringPool &pool)
Declare input renaming requests.
Definition: AuxTypeRegistry.cxx:1237
SG::AuxTypeRegistry::checkAuxID
void checkAuxID(const SG::auxid_t auxid, const Flags flags=Flags::None)
Verify type for an aux variable.
AuxTypes.h
Basic definitions for auxiliary types.
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::AuxTypeRegistry::makeFactoryNull
std::unique_ptr< IAuxTypeVectorFactory > makeFactoryNull() const
makeFactory implementation that always returns nullptr.
IAuxTypeVectorFactory.h
Interface for factory objects that create vectors.
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
SG::AuxTypeRegistry::operator=
AuxTypeRegistry & operator=(const AuxTypeRegistry &)
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:168
SG::AuxTypeRegistry::AuxTypeRegistry
AuxTypeRegistry(const AuxTypeRegistry &)
Disallow copy construction and assignment.
SG::AuxTypeRegistry::copy
void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const
Copy elements between vectors.
Definition: AuxTypeRegistry.cxx:1026
LArL1Calo_ComputeHVCorr.className
className
Definition: LArL1Calo_ComputeHVCorr.py:135
SG::AuxTypeRegistry::getAuxID
SG::auxid_t getAuxID(const std::string &name, const std::string &clsname="", const Flags flags=Flags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
Look up a name -> auxid_t mapping.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37