ATLAS Offline Software
Loading...
Searching...
No Matches
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*/
11
12
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
32namespace SG {
33
34
36
37
61{
62public:
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,
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,
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,
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,
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> >
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,
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
318
319
325
326
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
368 AuxVectorData&& dst, size_t dst_index,
369 const AuxVectorData& src, size_t src_index,
370 size_t n) const;
371
372
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
453
454
467 addFactory (const std::type_info& ti,
468 const std::type_info& ti_alloc,
469 std::unique_ptr<const IAuxTypeVectorFactory> factory);
470
471
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
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
537private:
539
540 typedef AthContainers_detail::mutex mutex_t;
541 typedef AthContainers_detail::lock_guard<mutex_t> lock_t;
542
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
Factory object that creates vectors using AuxTypeVector.
Basic definitions for auxiliary types.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Interface for factory objects that create vectors.
Abstract interface for manipulating vectors of arbitrary types.
Abstract interface for looking up strings/CLIDs in a pool.
Map keeping track of requested input renames.
static Double_t a
void clear()
Empty the pool.
Abstract interface for looking up strings/CLIDs in a pool.
Definition IStringPool.h:28
@Brief Implementation class for AuxTypeRegistry.
Flags getFlags(SG::auxid_t auxid) const
Return flags associated with an auxiliary variable.
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
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.
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
static bool isLinkedName(const std::string &name)
Test if a variable name corresponds to a linked variable.
size_t getEltSize(SG::auxid_t auxid) const
Return size of an element in the STL vector.
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.
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
const std::string & inputRename(const std::string &key, const std::string &name) const
Check for an input renaming of an auxiliary variable.
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
static std::string linkedName(const std::string &name)
Given a variable name, return the name of the corresponding linked variable.
friend class AuxTypeRegistryImpl
AuxTypeRegistry()
Constructor.
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.
const std::type_info * getAllocType(SG::auxid_t auxid) const
Return the type of the vector allocator.
void checkAuxID(const SG::auxid_t auxid, const Flags flags=Flags::None)
Verify type for an aux variable.
std::unique_ptr< IAuxTypeVectorFactory > makeFactoryNull() const
makeFactory implementation that always returns nullptr.
void setInputRenameMap(const Athena::InputRenameMap_t *map, const IStringPool &pool)
Declare input renaming requests.
AthContainers_detail::mutex mutex_t
const IAuxTypeVectorFactory * getFactory(const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
std::string getVecTypeName(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
AuxTypeRegistry & operator=(const AuxTypeRegistry &)
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
size_t numVariables() const
Return the total number of registered auxiliary variable.
SG::auxid_t linkedVariable(SG::auxid_t auxid) const
Return the auxid if the linked variable, if there is one.
static bool classNameHasLink(const std::string &className)
Test to see if a class name corresponds to a class with a linked variable.
AuxTypeRegistry(const AuxTypeRegistry &)
Disallow copy construction and assignment.
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.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
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.
std::unique_ptr< IAuxTypeVectorFactory > makeFactory() const
Create an AuxTypeVectorFactory instance.
AthContainers_detail::lock_guard< mutex_t > lock_t
SG::AuxVarFlags Flags
Additional flags to qualify an auxiliary variable.
void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const
Swap elements between vectors.
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.
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.
std::string getClassName(SG::auxid_t auxid) const
Return the class name associated with an aux data item (may be blank).
bool isLinked(SG::auxid_t auxid) const
Test whether this is a linked variable.
static std::string makeKey(const std::string &name, const std::string &clsname)
Return the key used to look up an entry in m_auxids.
Manage lookup of vectors of auxiliary data.
Interface for factory objects that create vectors.
Abstract interface for manipulating vectors of arbitrary types.
STL class.
SG::SGKeyMap< InputRenameEntry > InputRenameMap_t
Forward declaration.
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition AuxTypes.h:58
static const auxid_t null_auxid
To signal no aux data item.
Definition AuxTypes.h:30
SG::auxid_t auxid() const
Return the aux id for this variable.
virtual IAuxTypeVector * linkedVector(SG::auxid_t auxid) override
Return interface for a linked variable.
virtual size_t size() const override
Return the number of elements in the store.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Framework include files.
Definition libname.h:15