ATLAS Offline Software
Loading...
Searching...
No Matches
SG::AuxTypeRegistryImpl Class Reference

@Brief Implementation class for AuxTypeRegistry. More...

Inheritance diagram for SG::AuxTypeRegistryImpl:
Collaboration diagram for SG::AuxTypeRegistryImpl:

Classes

struct  typeinfo_t
 Hold information about one aux data item. More...

Public Types

using id_map_t = CxxUtils::ConcurrentStrMap<SG::auxid_t, CxxUtils::SimpleUpdater>
 Map from name -> auxid.
using ti_map_t = CxxUtils::ConcurrentStrMap<const IAuxTypeVectorFactory*, CxxUtils::SimpleUpdater>
 Map from type_info name + allocator ti name -> IAuxTypeVectorFactory.
typedef std::unordered_map< std::string, std::string > renameMap_t
 Save the information provided by setInputRenameMap.
using allocMap_t = CxxUtils::ConcurrentStrMap<const std::type_info*, CxxUtils::SimpleUpdater>
using Flags = SG::AuxVarFlags
 Additional flags to qualify an auxiliary variable.

Public Member Functions

 AuxTypeRegistryImpl ()
 Constructor.
 ~AuxTypeRegistryImpl ()
 Destructor.
SG::auxid_t findAuxID (const std::string &name, const std::string &clsname, const Flags flags, const SG::auxid_t linkedVariable, const std::type_info &ti, const std::type_info *ti_alloc, const std::string *alloc_name, std::unique_ptr< IAuxTypeVectorFactory >(AuxTypeRegistry::*makeFactory)() const)
 Look up a name -> auxid_t mapping.
const IAuxTypeVectorFactoryaddFactory (lock_t &lock, const std::type_info &ti, const std::type_info &ti_alloc, const IAuxTypeVectorFactory *factory)
 Add a new type -> factory mapping.
const IAuxTypeVectorFactoryaddFactory (lock_t &, const std::type_info &ti, const std::string &ti_alloc_name, std::unique_ptr< const IAuxTypeVectorFactory > factory)
 Add a new type -> factory mapping.
const IAuxTypeVectorFactorygetFactory (lock_t &lock, const std::type_info &ti, const std::type_info &ti_alloc)
 Return the vector factory for a given vector element type.
const IAuxTypeVectorFactoryaddFactory (const std::type_info &ti, const std::type_info &ti_alloc, std::unique_ptr< const IAuxTypeVectorFactory > factory)
 Add a new type -> factory mapping.
const IAuxTypeVectorFactoryaddFactory (const std::type_info &ti, const std::string &ti_alloc_name, std::unique_ptr< const IAuxTypeVectorFactory > factory)
 Add a new type -> factory mapping.
const IAuxTypeVectorFactorygetFactory (const std::type_info &ti, const std::type_info &ti_alloc)
 Return the vector factory for a given vector element type.
const IAuxTypeVectorFactorygetFactory (const std::type_info &ti, const std::string &alloc_name)
 Return the vector factory for a given vector element type.
const IAuxTypeVectorFactorygetFactory (SG::auxid_t auxid) const
 Return the vector factory for a given auxid.
size_t numVariables () const
 Return the total number of registered auxiliary variable.
template<class T, class ALLOC = AuxAllocator_t<T>>
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 getAuxID (const std::type_info &ti, 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 getAuxID (const std::type_info &ti_alloc, const std::type_info &ti, const std::string &name, const std::string &clsname="", const Flags flags=Flags::None, const SG::auxid_t linkedVariable=SG::null_auxid, std::unique_ptr< IAuxTypeVectorFactory >(AuxTypeRegistry::*makeFactory)() const =&AuxTypeRegistry::makeFactoryNull)
 Look up a name -> auxid_t mapping, specifying allocator.
SG::auxid_t getAuxID (const std::string &alloc_type, const std::type_info &ti, 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, specifying allocator.
SG::auxid_t findAuxID (const std::string &name, const std::string &clsname="") const
 Look up a name -> auxid_t mapping.
template<class T, class ALLOC = AuxAllocator_t<T>>
void checkAuxID (const SG::auxid_t auxid, const Flags flags=Flags::None)
 Verify type for an aux variable.
void checkAuxID (const SG::auxid_t auxid, const std::type_info &ti, const std::type_info &ti_alloc, const Flags flags)
 Verify type for an aux variable.
std::unique_ptr< IAuxTypeVectormakeVector (SG::auxid_t auxid, size_t size, size_t capacity) const
 Construct a new vector to hold an aux item.
std::unique_ptr< IAuxTypeVectormakeVectorFromData (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.
std::string getClassName (SG::auxid_t auxid) const
 Return the class name associated with an aux data item (may be blank).
const std::type_info * getType (SG::auxid_t auxid) const
 Return the type of an aux data item.
std::string getTypeName (SG::auxid_t auxid) const
 Return the type name of an aux data item.
const std::type_info * getVecType (SG::auxid_t auxid) const
 Return the type of the STL vector used to hold an aux data item.
std::string getVecTypeName (SG::auxid_t auxid) const
 Return the type of the STL vector used to hold an aux data item.
const std::type_info * getAllocType (SG::auxid_t auxid) const
 Return the type of the vector allocator.
size_t getEltSize (SG::auxid_t auxid) const
 Return size of an element in the STL vector.
Flags getFlags (SG::auxid_t auxid) const
 Return flags associated with an auxiliary variable.
bool isLinked (SG::auxid_t auxid) const
 Test whether this is a linked variable.
SG::auxid_t linkedVariable (SG::auxid_t auxid) const
 Return the auxid if the linked variable, if there is one.
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.
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.
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.
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 clear (SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, size_t n) const
 Clear a range of elements within a vector.
void setInputRenameMap (const Athena::InputRenameMap_t *map, const IStringPool &pool)
 Declare input renaming requests.
const std::string & inputRename (const std::string &key, const std::string &name) const
 Check for an input renaming of an auxiliary variable.

Static Public Member Functions

static bool checkName (std::string_view s) noexcept
 Check for valid variable name.
static AuxTypeRegistryinstance ()
 Return the singleton registry instance.
static bool isLinkedName (const std::string &name)
 Test if a variable name corresponds to a linked variable.
static std::string linkedName (const std::string &name)
 Given a variable name, return the name of the corresponding linked variable.
static bool classNameHasLink (const std::string &className)
 Test to see if a class name corresponds to a class with a linked variable.

Public Attributes

AthContainers_detail::concurrent_vector< typeinfo_tm_types
 Table of aux data items, indexed by auxid.
id_map_t m_auxids
ti_map_t m_factories
std::vector< const IAuxTypeVectorFactory * > m_oldFactories
 Hold additional factory instances we need to delete.
renameMap_t m_renameMap
allocMap_t m_allocMap
mutex_t m_mutex
 Mutex controlling access to the registry.

Private Types

typedef AthContainers_detail::mutex mutex_t
typedef AthContainers_detail::lock_guard< mutex_tlock_t

Private Member Functions

template<class T, class ALLOC = AuxAllocator_t<T>>
std::unique_ptr< IAuxTypeVectorFactorymakeFactory () const
 Create an AuxTypeVectorFactory instance.
std::unique_ptr< IAuxTypeVectorFactorymakeFactoryNull () const
 makeFactory implementation that always returns nullptr.

Static Private Member Functions

static std::string makeKey (const std::string &name, const std::string &clsname)
 Return the key used to look up an entry in m_auxids.

Detailed Description

@Brief Implementation class for AuxTypeRegistry.

We split this off in order to reduce compile-time dependencies on tbb and ConcurrentStrMap. Since this can get accessed frequently, but is a singleton, we don't use the more commom pimpl idiom. Instead, we put the implementation stuff in a derived class. The function that creates the singleton actually makes an instance of the derived class, and we static_cast to the derived class where needed. Since instances of this cannot be created anywhere else, this is safe.

Definition at line 44 of file AuxTypeRegistry.cxx.

Member Typedef Documentation

◆ allocMap_t

◆ Flags

Additional flags to qualify an auxiliary variable.

Definition at line 65 of file AuxTypeRegistry.h.

◆ id_map_t

◆ lock_t

Definition at line 541 of file AuxTypeRegistry.h.

◆ mutex_t

Definition at line 540 of file AuxTypeRegistry.h.

◆ renameMap_t

typedef std::unordered_map<std::string, std::string> SG::AuxTypeRegistryImpl::renameMap_t

Save the information provided by setInputRenameMap.

Each entry is of the form KEY.DECOR -> DECOR_RENAMED

Definition at line 217 of file AuxTypeRegistry.cxx.

◆ ti_map_t

Map from type_info name + allocator ti name -> IAuxTypeVectorFactory.

Definition at line 209 of file AuxTypeRegistry.cxx.

Constructor & Destructor Documentation

◆ AuxTypeRegistryImpl()

SG::AuxTypeRegistryImpl::AuxTypeRegistryImpl ( )

Constructor.

Populates the type -> factory mappings for standard C++ types.

Definition at line 241 of file AuxTypeRegistry.cxx.

245{
247
248 // Make sure we have factories registered for common C++ types.
249#define ADD_FACTORY(T) AuxTypeRegistry::addFactory(typeid(T), typeid(AuxAllocator_t<T>), std::make_unique<AuxTypeVectorFactory<T> >())
250 ADD_FACTORY (bool);
251 ADD_FACTORY (char);
252 ADD_FACTORY (unsigned char);
253 ADD_FACTORY (short);
254 ADD_FACTORY (unsigned short);
255 ADD_FACTORY (int);
256 ADD_FACTORY (unsigned int);
257 ADD_FACTORY (long);
258 ADD_FACTORY (unsigned long);
259 ADD_FACTORY (long long);
260 ADD_FACTORY (unsigned long long);
261 ADD_FACTORY (float);
262 ADD_FACTORY (double);
263 ADD_FACTORY (std::string);
264
265 ADD_FACTORY (std::vector<char>);
266 ADD_FACTORY (std::vector<unsigned char>);
267 ADD_FACTORY (std::vector<int>);
268 ADD_FACTORY (std::vector<unsigned int>);
269 ADD_FACTORY (std::vector<float>);
270 ADD_FACTORY (std::vector<double>);
271
272 ADD_FACTORY (SG::JaggedVecElt<char>);
273 ADD_FACTORY (SG::JaggedVecElt<unsigned char>);
274 ADD_FACTORY (SG::JaggedVecElt<short>);
275 ADD_FACTORY (SG::JaggedVecElt<unsigned short>);
276 ADD_FACTORY (SG::JaggedVecElt<int>);
277 ADD_FACTORY (SG::JaggedVecElt<unsigned int>);
278 ADD_FACTORY (SG::JaggedVecElt<long>);
279 ADD_FACTORY (SG::JaggedVecElt<unsigned long>);
280 ADD_FACTORY (SG::JaggedVecElt<long long>);
281 ADD_FACTORY (SG::JaggedVecElt<unsigned long long>);
282 ADD_FACTORY (SG::JaggedVecElt<float>);
283 ADD_FACTORY (SG::JaggedVecElt<double>);
284 ADD_FACTORY (SG::JaggedVecElt<std::string>);
285#undef ADD_FACTORY
286}
#define ADD_FACTORY(T)
AthContainers_detail::concurrent_vector< typeinfo_t > m_types
Table of aux data items, indexed by auxid.
static const auxid_t auxid_set_size_hint
A hint for how large we should make the auxid bitsets.
Definition AuxTypes.h:40

◆ ~AuxTypeRegistryImpl()

SG::AuxTypeRegistryImpl::~AuxTypeRegistryImpl ( )

Destructor.

Delete factory instances.

Definition at line 294 of file AuxTypeRegistry.cxx.

295{
296 // not using reference, because our iterator doesn't return a reference
297 for (auto p : m_factories) {
298 if (p.first.find (";TI;") == std::string::npos) {
299 delete p.second;
300 }
301 }
302 for (const IAuxTypeVectorFactory* p : m_oldFactories)
303 delete p;
304}
std::vector< const IAuxTypeVectorFactory * > m_oldFactories
Hold additional factory instances we need to delete.

Member Function Documentation

◆ addFactory() [1/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistry::addFactory ( const std::type_info & ti,
const std::string & ti_alloc_name,
std::unique_ptr< const IAuxTypeVectorFactory > factory )

Add a new type -> factory mapping.

Parameters
tiType of the vector element.
ti_alloc_nameThe name of the vector allocator type.
factoryThe factory instance.

This records that factory can be used to construct vectors with an element type of ti. If a mapping already exists, the new factory is discarded, unless the old one is a dynamic factory and the new one isn't, in which case the new replaces the old one.

Definition at line 484 of file AuxTypeRegistry.cxx.

1201{
1202 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
1203 lock_t lock (impl->m_mutex);
1204 return impl->addFactory (lock, ti, ti_alloc_name, std::move (factory));
1205}
AthContainers_detail::lock_guard< mutex_t > lock_t

◆ addFactory() [2/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistry::addFactory ( const std::type_info & ti,
const std::type_info & ti_alloc,
std::unique_ptr< const IAuxTypeVectorFactory > factory )

Add a new type -> factory mapping.

Parameters
tiType of the vector element.
ti_allocThe type of the vector allocator
factoryThe factory instance.

This records that factory can be used to construct vectors with an element type of ti. If a mapping already exists, the new factory is discarded, unless the old one is a dynamic factory and the new one isn't, in which case the new replaces the old one.

Definition at line 467 of file AuxTypeRegistry.cxx.

1176{
1177 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
1178 lock_t lock (impl->m_mutex);
1179 std::string name = SG::normalizedTypeinfoName (ti_alloc);
1180 const IAuxTypeVectorFactory* fac =
1181 impl->addFactory (lock, ti, name, std::move(factory));
1182 return impl->addFactory (lock, ti, ti_alloc, fac);
1183}
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...

◆ addFactory() [3/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistryImpl::addFactory ( lock_t & ,
const std::type_info & ti,
const std::string & ti_alloc_name,
std::unique_ptr< const IAuxTypeVectorFactory > factory )

Add a new type -> factory mapping.

(external locking)

Parameters
lockThe registry lock.
tiType of the vector element.
ti_alloc_nameThe name of the vector allocator type.
factoryThe factory instance.

This records that factory can be used to construct vectors with an element type of ti. If a mapping already exists, the new factory is discarded, unless the old one is a dynamic factory and the new one isn't, in which case the new replaces the old one.

Definition at line 532 of file AuxTypeRegistry.cxx.

536{
537 std::string key = ti.name();
538 key += ';';
539 key += ti_alloc_name;
540 ti_map_t::const_iterator it = m_factories.find (key);
541 const IAuxTypeVectorFactory* fac = factory.get();
542 if (it != m_factories.end()) {
543 if (it->second->isDynamic() && !factory->isDynamic()) {
544 // Replacing a dynamic factory with a non-dynamic one.
545 // But don't delete the old one, since it might still be referenced.
546 // Instead, push it on a vector to remember it so we can delete
547 // it later.
548 m_oldFactories.push_back (it->second);
549 fac = m_factories.insert_or_assign (key, factory.release()).first->second;
550 }
551 else {
552 fac = it->second;
553 }
554 }
555 else
556 fac = m_factories.insert_or_assign (key, factory.release()).first->second;
557
558 return fac;
559}

◆ addFactory() [4/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistryImpl::addFactory ( lock_t & lock,
const std::type_info & ti,
const std::type_info & ti_alloc,
const IAuxTypeVectorFactory * factory )

Add a new type -> factory mapping.

(external locking)

Parameters
lockThe registry lock.
tiType of the vector element.
ti_allocThe type of the vector allocator
factoryThe factory instance. Ownership is not taken.

This records that factory can be used to construct vectors with an element type of ti. If a mapping already exists, the new factory is discarded, unless the old one is a dynamic factory and the new one isn't, in which case the new replaces the old one.

Definition at line 489 of file AuxTypeRegistry.cxx.

493{
494 std::string key = std::string (ti.name()) + ";TI;" + ti_alloc.name();
495 ti_map_t::const_iterator it = m_factories.find (key);
496 if (it != m_factories.end()) {
497 if (it->second->isDynamic() && !factory->isDynamic()) {
498 // Replacing a dynamic factory with a non-dynamic one.
499 // The string version should put it to m_oldFactories.
500 m_factories.insert_or_assign (key, factory);
501 }
502 else {
503 factory = it->second;
504 }
505 }
506 else
507 m_factories.insert_or_assign (key, factory);
508
509 if (SG::normalizedTypeinfoName (ti_alloc).starts_with(
511 {
512 m_allocMap.insert_or_assign (ti.name(), &ti_alloc);
513 }
514
515 return factory;
516}
constexpr const char * auxAllocatorNamePrefix

◆ checkAuxID() [1/2]

template<class T, class ALLOC = AuxAllocator_t<T>>
void SG::AuxTypeRegistry::checkAuxID ( const SG::auxid_t auxid,
const Flags flags = Flags::None )
inherited

Verify type for an aux variable.

Parameters
auxidThe ID of the variable to check.
flagsOptional flags qualifying the type. See above.

If the type of auxid is not compatible with the supplied types T / ALLOC, then throw a SG::ExcAuxTypeMismatch exception. Also may throw SG::ExcFlagMismatch.

◆ checkAuxID() [2/2]

void SG::AuxTypeRegistry::checkAuxID ( const SG::auxid_t auxid,
const std::type_info & ti,
const std::type_info & ti_alloc,
const Flags flags )
inherited

Verify type for an aux variable.

Parameters
auxidThe ID of the variable to check.
tiType of the aux data item.
ti_allocType of the vector allocator.
flagsOptional flags qualifying the type. See above.

If the type of auxid is not compatible with the supplied types ti / ti_alloc, then throw a SG::ExcAuxTypeMismatch exception. Also may throw SG::ExcFlagMismatch.

Definition at line 787 of file AuxTypeRegistry.cxx.

791{
792 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
793 AuxTypeRegistryImpl::typeinfo_t& m = impl->m_types.at (auxid);
794
795 if ( ! ((&ti == m.m_ti || strcmp(ti.name(), m.m_ti->name()) == 0) &&
796 m.checkAlloc (&ti_alloc, nullptr)))
797 {
798 throw SG::ExcAuxTypeMismatch (auxid, ti, *m.m_ti,
800 m.m_alloc_name);
801 }
802 if ((CxxUtils::test (m.m_flags, Flags::Atomic) &&
803 !CxxUtils::test (flags, Flags::Atomic)) ||
804 (CxxUtils::test (m.m_flags, Flags::Linked) != CxxUtils::test (flags, Flags::Linked)))
805 {
806 throw SG::ExcFlagMismatch (auxid, ti, m.m_flags, flags);
807 }
808}
friend class AuxTypeRegistryImpl
constexpr std::enable_if_t< is_bitmask_v< E >, bool > test(E lhs, E rhs)
Convenience function to test bits in a class enum bitmask.
Definition bitmask.h:270

◆ checkName()

bool SG::AuxTypeRegistryImpl::checkName ( std::string_view s)
staticnoexcept

Check for valid variable name.

Parameters
nameName to check.

Require that NAME be not empty, contains only alphanumeric characters plus underscore, and first character is not a digit.

Definition at line 569 of file AuxTypeRegistry.cxx.

570{
571 if (s.empty()) return false;
572 char first = s[0];
573 if (!std::isalpha(static_cast<unsigned char>(first)) && first != '_') return false;
574 return std::all_of(s.begin() + 1, s.end(), [](char c) {
575 return std::isalnum(static_cast<unsigned char>(c)) || c == '_';
576 });
577}
bool first
Definition DeMoScan.py:534

◆ classNameHasLink()

bool SG::AuxTypeRegistry::classNameHasLink ( const std::string & className)
staticinherited

Test to see if a class name corresponds to a class with a linked variable.

Definition at line 1313 of file AuxTypeRegistry.cxx.

1314{
1315 if (className.find ("SG::JaggedVecElt<") != std::string::npos) {
1316 return true;
1317 }
1318 if (className.find ("SG::PackedLink<") != std::string::npos) {
1319 return true;
1320 }
1321 return false;
1322}

◆ clear()

void SG::AuxTypeRegistry::clear ( SG::auxid_t auxid,
AuxVectorData & dst,
size_t dst_index,
size_t n ) const
inherited

Clear a range of elements within a vector.

Parameters
auxidThe aux data item being operated on.
dstContainer holding the element
dst_indexIndex of the first element in the vector.
nNumber of elements to clear.

Definition at line 1092 of file AuxTypeRegistry.cxx.

1095{
1096 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1097 if (factory)
1098 factory->clear (auxid, dst, dst_index, n);
1099}
const IAuxTypeVectorFactory * getFactory(const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
virtual void clear(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, size_t n) const =0
Clear a range of elements within a vector.

◆ copy() [1/2]

void SG::AuxTypeRegistry::copy ( SG::auxid_t auxid,
AuxVectorData && dst,
size_t dst_index,
const AuxVectorData & src,
size_t src_index,
size_t n ) const
inherited

Copy elements between vectors.

Parameters
auxidThe aux data item being operated on.
dstContainer for the destination vector. Declared as a rvalue reference to allow passing a temporary here (such as from AuxVectorInterface).
dst_indexIndex of the first destination element in the vector.
srcContainer for the source vector.
src_indexIndex of the first source element in the vector.
nNumber of elements to copy.

dst and @ src can be either the same or different.

◆ copy() [2/2]

void SG::AuxTypeRegistry::copy ( SG::auxid_t auxid,
AuxVectorData & dst,
size_t dst_index,
const AuxVectorData & src,
size_t src_index,
size_t n ) const
inherited

Copy elements between vectors.

Parameters
auxidThe aux data item being operated on.
dstContainer for the destination vector.
dst_indexIndex of the first destination element in the vector.
srcContainer for the source vector.
src_indexIndex of the first source element in the vector.
nNumber of elements to copy.

dst and @ src can be either the same or different.

Definition at line 1027 of file AuxTypeRegistry.cxx.

1031{
1032 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1033 if (factory)
1034 factory->copy (auxid, dst, dst_index, src, src_index, n);
1035}
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors.

◆ copyForOutput()

void SG::AuxTypeRegistry::copyForOutput ( SG::auxid_t auxid,
AuxVectorData & dst,
size_t dst_index,
const AuxVectorData & src,
size_t src_index,
size_t n ) const
inherited

Copy elements between vectors.

Apply any transformations needed for output.

Parameters
auxidThe aux data item being operated on.
dstContainer for the destination vector.
dst_indexIndex of the first destination element in the vector.
srcContainer for the source vector.
src_indexIndex of the first source element in the vector.
nNumber of elements to copy.

dst and @ src can be either the same or different.

Definition at line 1050 of file AuxTypeRegistry.cxx.

1054{
1055 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1056 if (factory) {
1057 factory->copyForOutput (auxid, dst, dst_index, src, src_index, n);
1058 }
1059}
virtual void copyForOutput(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors, possibly applying thinning.

◆ findAuxID() [1/2]

SG::auxid_t SG::AuxTypeRegistry::findAuxID ( const std::string & name,
const std::string & clsname = "" ) const
inherited

Look up a name -> auxid_t mapping.

Parameters
nameThe name of the aux data item.
clsnameThe name of its associated class. May be blank.

Will only find an existing auxid_t; unlike getAuxID, this won't make a new one. If the item isn't found, this returns null_auxid.

Definition at line 757 of file AuxTypeRegistry.cxx.

759{
760 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
761
762 // No locking needed here.
763 // The extra test here is to avoid having to copy a string
764 // in the common case where clsname is blank.
765 AuxTypeRegistryImpl::id_map_t::const_iterator i =
766 impl->m_auxids.find (clsname.empty() ?
767 name :
768 makeKey (name, clsname));
769 if (i != impl->m_auxids.end()) {
770 return i->second;
771 }
772 return null_auxid;
773}
static std::string makeKey(const std::string &name, const std::string &clsname)
Return the key used to look up an entry in m_auxids.
static const auxid_t null_auxid
To signal no aux data item.
Definition AuxTypes.h:30

◆ findAuxID() [2/2]

SG::auxid_t SG::AuxTypeRegistryImpl::findAuxID ( const std::string & name,
const std::string & clsname,
const Flags flags,
const SG::auxid_t linkedVariable,
const std::type_info & ti,
const std::type_info * ti_alloc,
const std::string * alloc_name,
std::unique_ptr< IAuxTypeVectorFactory >(AuxTypeRegistry::* makeFactory )() const )

Look up a name -> auxid_t mapping.

Parameters
nameThe name of the aux data item.
clsnameThe name of its associated class. May be blank.
flagsOptional flags qualifying the type. See above.
linkedVariableauxid of a linked variable, or null_auxid.
tiThe type of this aux data item.
ti_allocThe type of the vector allocator.
alloc_nameThe name of the vector allocator. Used only if ti_alloc is null.
makeFactoryFunction to create a factory for this type, if needed. May return 0 if the type is unknown.

If the aux data item already exists, check to see if the provided type matches the type that was used before. If so, then set return the auxid; otherwise, throw SG::ExcAuxTypeMismatch.

If the aux data item does not already exist, then see if we have a factory registered for this type_info. If not, then call makeFactory and use what it returns. If that returns 0, then fail and return null_auxid. Otherwise, assign a new auxid and return it.

Definition at line 332 of file AuxTypeRegistry.cxx.

340{
341 // The extra test here is to avoid having to copy a string
342 // in the common case where clsname is blank.
343 const std::string& key = clsname.empty() ? name : makeKey (name, clsname);
344
345
346 // Fast path --- try without acquiring the lock.
347 {
348 id_map_t::const_iterator i = m_auxids.find (key);
349 if (i != m_auxids.end()) {
350 typeinfo_t& m = m_types[i->second];
351 if (!(CxxUtils::test (m.m_flags, Flags::Atomic) &&
352 !CxxUtils::test (flags, Flags::Atomic)) &&
353 (CxxUtils::test (m.m_flags, Flags::Linked) == CxxUtils::test (flags, Flags::Linked)) &&
354 (linkedVariable == m.m_linked) &&
355 (&ti == m.m_ti || strcmp(ti.name(), m.m_ti->name()) == 0) &&
356 m.checkAlloc (ti_alloc, alloc_name) &&
357 !(*m.m_factory).isDynamic())
358 {
359 return i->second;
360 }
361 }
362 }
363
364 // Something went wrong. Acquire the lock and try again.
365 lock_t lock (m_mutex);
366 id_map_t::const_iterator i = m_auxids.find (key);
367 if (i != m_auxids.end()) {
368 typeinfo_t& m = m_types[i->second];
369
370 if ((CxxUtils::test (m.m_flags, Flags::Atomic) &&
371 !CxxUtils::test (flags, Flags::Atomic)) ||
372 (CxxUtils::test (m.m_flags, Flags::Linked) != CxxUtils::test (flags, Flags::Linked)))
373 {
374 throw SG::ExcFlagMismatch (i->second, ti, m.m_flags, flags);
375 }
376
377 if (linkedVariable != m.m_linked)
378 {
379 throw SG::ExcLinkMismatch (i->second, ti, m.m_linked, linkedVariable);
380 }
381
382 // By all rights, these two tests should be redundant.
383 // However, there are cases where we see distinct @c type_info objects
384 // for the same type. This is usually associated with dictionaries
385 // being loaded `too early,' during python configuration processing.
386 // It's a C++ standard violation for this to ever happen, but it's
387 // not clear that it's feasible to actually eliminate the possibility
388 // of this happening. So if the @c type_info instances differ,
389 // we still accept the match as long as the names are the same.
390 if ((&ti == m.m_ti || strcmp(ti.name(), m.m_ti->name()) == 0) &&
391 m.checkAlloc (ti_alloc, alloc_name))
392 {
393 // Try to upgrade a dynamic factory.
394 if ((*m.m_factory).isDynamic()) {
395 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*makeFactory)();
396 if (fac2) {
397 if (!ti_alloc) {
398 ti_alloc = fac2->tiAlloc();
399 }
400 std::string allocName = fac2->tiAllocName();
401 m.m_factory = addFactory (lock, ti, allocName, std::move (fac2));
402 if (ti_alloc) {
403 m.m_factory = addFactory (lock, ti, *ti_alloc, m.m_factory);
404 }
405 }
406 }
407 return i->second;
408 }
409 if( *m.m_ti != typeid(SG::AuxTypePlaceholder) ) {
410 throw SG::ExcAuxTypeMismatch (i->second, ti, *m.m_ti,
411 ti_alloc ? SG::normalizedTypeinfoName (*ti_alloc) : (alloc_name ? *alloc_name : ""),
412 m.m_alloc_name);
413 }
414 // fall through, get a new auxid and real type info
415 // new auxid needed so a new data vector is created in the AuxStore
416 }
417
418 // Verify now that the variable names are ok.
419 if (!(flags & Flags::SkipNameCheck) &&
420 (!checkName (name) ||
421 (!clsname.empty() && !checkName (clsname))))
422 {
423 throw ExcBadVarName (key);
424 }
425
426 const IAuxTypeVectorFactory* fac = nullptr;
427 if (ti_alloc) {
428 fac = getFactory (lock, ti, *ti_alloc);
429 }
430 else if (alloc_name) {
431 fac = getFactory (ti, *alloc_name);
432 }
433 else {
434 std::string def_alloc_name = SG::auxAllocatorNamePrefix + SG::normalizedTypeinfoName (ti);
435 if (def_alloc_name[def_alloc_name.size()-1] == '>') def_alloc_name += ' ';
436 def_alloc_name += '>';
437 fac = getFactory (ti,def_alloc_name);
438 }
439
440 if (!fac || fac->isDynamic()) {
441 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*makeFactory)();
442 if (fac2) {
443 if (!ti_alloc) {
444 ti_alloc = fac2->tiAlloc();
445 }
446 std::string allocName = fac2->tiAllocName();
447 fac = addFactory (lock, ti, allocName, std::move (fac2));
448 if (ti_alloc) {
449 fac = addFactory (lock, ti, *ti_alloc, fac);
450 }
451 }
452 }
453 if (!fac) return null_auxid;
454 if (!ti_alloc) ti_alloc = fac->tiAlloc();
455 SG::auxid_t auxid = m_types.size();
456 m_types.resize (auxid+1);
457 typeinfo_t& t = m_types[auxid];
458 t.m_name = name;
459 t.m_clsname = clsname;
460 t.m_ti = &ti;
461 t.m_ti_alloc = ti_alloc;
462 t.m_alloc_name = fac->tiAllocName();
463 t.m_factory = fac;
464 t.m_flags = (flags & ~Flags::SkipNameCheck);
465 t.m_linked = linkedVariable;
467 if (!isLinked (linkedVariable)) std::abort();
468 }
470 m_auxids.insert_or_assign (key, auxid);
471
472 return auxid;
473}
mutex_t m_mutex
Mutex controlling access to the registry.
static bool checkName(std::string_view s) noexcept
Check for valid variable name.
const IAuxTypeVectorFactory * getFactory(lock_t &lock, const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
const IAuxTypeVectorFactory * addFactory(lock_t &lock, const std::type_info &ti, const std::type_info &ti_alloc, const IAuxTypeVectorFactory *factory)
Add a new type -> factory mapping.
SG::auxid_t linkedVariable(SG::auxid_t auxid) const
Return the auxid if the linked variable, if there is one.
std::unique_ptr< IAuxTypeVectorFactory > makeFactory() const
Create an AuxTypeVectorFactory instance.
SG::AuxVarFlags Flags
Additional flags to qualify an auxiliary variable.
bool isLinked(SG::auxid_t auxid) const
Test whether this is a linked variable.
void fence_seq_cst()
A sequentially-consistent fence.
@ SkipNameCheck
Definition AuxTypes.h:81
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Hold information about one aux data item.

◆ getAllocType()

const std::type_info * SG::AuxTypeRegistry::getAllocType ( SG::auxid_t auxid) const
inherited

Return the type of the vector allocator.

Parameters
auxidThe desired aux data item.

Definition at line 965 of file AuxTypeRegistry.cxx.

966{
967 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
968 if (auxid >= impl->m_types.size())
969 return 0;
970 return impl->m_types[auxid].m_ti_alloc;
971}

◆ getAuxID() [1/4]

SG::auxid_t SG::AuxTypeRegistry::getAuxID ( const std::string & alloc_type,
const std::type_info & ti,
const std::string & name,
const std::string & clsname = "",
const Flags flags = Flags::None,
const SG::auxid_t linkedVariable = SG::null_auxid )
inherited

Look up a name -> auxid_t mapping, specifying allocator.

Parameters
alloc_nameName of the vector allocator type.
tiType of the aux data item.
nameThe name of the aux data item.
clsnameThe name of its associated class. May be blank.
flagsOptional flags qualifying the type. See above.
linkedVariableauxid of a linked variable, or null_auxid.

The type of the item is given by ti. Return null_auxid if we don't know how to make vectors of ti. (Use addFactory to register additional types.) If an item with the same name was previously requested with a different type, then throw SG::ExcAuxTypeMismatch.

Definition at line 733 of file AuxTypeRegistry.cxx.

739{
740 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
741 return impl->findAuxID (name, clsname, flags, linkedVariable,
742 ti, nullptr, &alloc_type,
744}
std::unique_ptr< IAuxTypeVectorFactory > makeFactoryNull() const
makeFactory implementation that always returns nullptr.

◆ getAuxID() [2/4]

template<class T, class ALLOC = AuxAllocator_t<T>>
SG::auxid_t SG::AuxTypeRegistry::getAuxID ( const std::string & name,
const std::string & clsname = "",
const Flags flags = Flags::None,
const SG::auxid_t linkedVariable = SG::null_auxid )
inherited

Look up a name -> auxid_t mapping.

Parameters
nameThe name of the aux data item.
clsnameThe name of its associated class. May be blank.
flagsOptional flags qualifying the type. See above.
linkedVariableauxid of a linked variable, or null_auxid.

The type of the item is given by the template parameter T, and the ALLOC gives the type of the vector allocator. If an item with the same name was previously requested with a different type, then throw SG::ExcAuxTypeMismatch.

◆ getAuxID() [3/4]

SG::auxid_t SG::AuxTypeRegistry::getAuxID ( const std::type_info & ti,
const std::string & name,
const std::string & clsname = "",
const Flags flags = Flags::None,
const SG::auxid_t linkedVariable = SG::null_auxid )
inherited

Look up a name -> auxid_t mapping.

Parameters
tiType of the aux data item.
nameThe name of the aux data item.
clsnameThe name of its associated class. May be blank.
flagsOptional flags qualifying the type. See above.
linkedVariableauxid of a linked variable, or null_auxid.

The type of the item is given by ti. Return null_auxid if we don't know how to make vectors of ti. (Use addFactory to register additional types.) If an item with the same name was previously requested with a different type, then throw SG::ExcAuxTypeMismatch.

Definition at line 673 of file AuxTypeRegistry.cxx.

678{
679 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
680 return impl->findAuxID (name, clsname, flags, linkedVariable,
681 ti, nullptr, nullptr,
683}

◆ getAuxID() [4/4]

SG::auxid_t SG::AuxTypeRegistry::getAuxID ( const std::type_info & ti_alloc,
const std::type_info & ti,
const std::string & name,
const std::string & clsname = "",
const Flags flags = Flags::None,
const SG::auxid_t linkedVariable = SG::null_auxid,
std::unique_ptr< IAuxTypeVectorFactory >(AuxTypeRegistry::* makeFactory )() const = &AuxTypeRegistry::makeFactoryNull )
inherited

Look up a name -> auxid_t mapping, specifying allocator.

Parameters
ti_allocType of the vector allocator.
tiType of the aux data item.
nameThe name of the aux data item.
clsnameThe name of its associated class. May be blank.
flagsOptional flags qualifying the type. See above.
linkedVariableauxid of a linked variable, or null_auxid.
makeFactoryFunction to create a factory for this type, if needed. May return 0 if the type is unknown.

The type of the item is given by ti. Return null_auxid if we don't know how to make vectors of ti. (Use addFactory to register additional types.) If an item with the same name was previously requested with a different type, then throw SG::ExcAuxTypeMismatch.

Definition at line 703 of file AuxTypeRegistry.cxx.

710{
711 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
712 return impl->findAuxID (name, clsname, flags, linkedVariable,
713 ti, &ti_alloc, nullptr,
715}

◆ getClassName()

std::string SG::AuxTypeRegistry::getClassName ( SG::auxid_t auxid) const
inherited

Return the class name associated with an aux data item (may be blank).

Parameters
auxidThe desired aux data item.

Definition at line 896 of file AuxTypeRegistry.cxx.

897{
898 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
899 if (auxid >= impl->m_types.size())
900 return "";
901 return impl->m_types[auxid].m_clsname;
902}

◆ getEltSize()

size_t SG::AuxTypeRegistry::getEltSize ( SG::auxid_t auxid) const
inherited

Return size of an element in the STL vector.

Parameters
auxidThe desired aux data item.

Definition at line 978 of file AuxTypeRegistry.cxx.

979{
980 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
981 if (factory)
982 return factory->getEltSize();
983 return 0;
984}
virtual size_t getEltSize() const =0
Return the size of an element of this vector type.

◆ getFactory() [1/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistry::getFactory ( const std::type_info & ti,
const std::string & alloc_name )

Return the vector factory for a given vector element type.

Parameters
tiThe type of the vector element.
alloc_nameThe name of the vector allocator type.

Returns nullptr if the type is not known. (Use addFactory to add new mappings.)

Definition at line 441 of file AuxTypeRegistry.cxx.

1148{
1149 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
1150
1151 std::string key = std::string (ti.name()) + ";" + alloc_name;
1152 AuxTypeRegistryImpl::ti_map_t::const_iterator it = impl->m_factories.find (key);
1153 if (it != impl->m_factories.end()) {
1154 return it->second;
1155 }
1156
1157 return nullptr;
1158}

◆ getFactory() [2/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistry::getFactory ( const std::type_info & ti,
const std::type_info & ti_alloc )

Return the vector factory for a given vector element type.

Parameters
tiThe type of the vector element.
ti_allocThe type of the vector allocator.

Returns nullptr if the type is not known. (Use addFactory to add new mappings.)

Parameters
tiThe type of the vector element.
ti_allocThe type of the vector allocator

Returns nullptr if the type is not known. (Use addFactory to add new mappings.)

Definition at line 429 of file AuxTypeRegistry.cxx.

1113{
1114 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
1115 lock_t lock (impl->m_mutex);
1116 return impl->getFactory (lock, ti, ti_alloc);
1117}

◆ getFactory() [3/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistryImpl::getFactory ( lock_t & lock,
const std::type_info & ti,
const std::type_info & ti_alloc )

Return the vector factory for a given vector element type.

(External locking.)

Parameters
lockThe registry lock.
tiThe type of the vector element.
ti_allocThe type of the vector allocator

Returns nullptr if the type is not known. (Use addFactory to add new mappings.)

Definition at line 591 of file AuxTypeRegistry.cxx.

594{
595 std::string key = ti.name();
596 key += ";TI;";
597 key += ti_alloc.name();
598 ti_map_t::const_iterator it = m_factories.find (key);
599 if (it != m_factories.end())
600 return it->second;
601
602 std::string name = SG::normalizedTypeinfoName (ti_alloc);
603 const IAuxTypeVectorFactory* fac = getFactory (ti, name);
604 if (fac) {
605 // We only really need to be holding the lock here, but doing things
606 // otherwise would require some code duplication.
607 addFactory (lock, ti, ti_alloc, fac);
608 }
609 return fac;
610}

◆ getFactory() [4/4]

const IAuxTypeVectorFactory * SG::AuxTypeRegistry::getFactory ( SG::auxid_t auxid) const

Return the vector factory for a given auxid.

Parameters
auxidThe desired aux data item.

Returns nullptr if the type is not known. (Use addFactory to add new mappings.)

Definition at line 452 of file AuxTypeRegistry.cxx.

1129{
1130 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
1131 if (auxid >= impl->m_types.size())
1132 return 0;
1133 return impl->m_types[auxid].m_factory;
1134}

◆ getFlags()

AuxVarFlags SG::AuxTypeRegistry::getFlags ( SG::auxid_t auxid) const
inherited

Return flags associated with an auxiliary variable.

Parameters
auxidThe desired aux data item.

Definition at line 991 of file AuxTypeRegistry.cxx.

992{
993 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
994 if (auxid >= impl->m_types.size())
995 return Flags::None;
996 return impl->m_types[auxid].m_flags;
997}

◆ getName()

std::string SG::AuxTypeRegistry::getName ( SG::auxid_t auxid) const
inherited

Return the name of an aux data item.

Parameters
auxidThe desired aux data item.

Definition at line 882 of file AuxTypeRegistry.cxx.

883{
884 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
885 if (auxid >= impl->m_types.size())
886 return "";
887 return impl->m_types[auxid].m_name;
888}

◆ getType()

const std::type_info * SG::AuxTypeRegistry::getType ( SG::auxid_t auxid) const
inherited

Return the type of an aux data item.

Parameters
auxidThe desired aux data item.

Definition at line 909 of file AuxTypeRegistry.cxx.

910{
911 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
912 if (auxid >= impl->m_types.size())
913 return 0;
914 return impl->m_types[auxid].m_ti;
915}

◆ getTypeName()

std::string SG::AuxTypeRegistry::getTypeName ( SG::auxid_t auxid) const
inherited

Return the type name of an aux data item.

Parameters
auxidThe desired aux data item.

Returns an empty string if the type is not known.

Definition at line 924 of file AuxTypeRegistry.cxx.

925{
926 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
927 if (auxid >= impl->m_types.size())
928 return "";
929 return normalizedTypeinfoName (*impl->m_types[auxid].m_ti);
930}

◆ getVecType()

const std::type_info * SG::AuxTypeRegistry::getVecType ( SG::auxid_t auxid) const
inherited

Return the type of the STL vector used to hold an aux data item.

Parameters
auxidThe desired aux data item.

Definition at line 937 of file AuxTypeRegistry.cxx.

938{
939 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
940 if (factory)
941 return factory->tiVec();
942 return 0;
943}
virtual const std::type_info * tiVec() const =0
Return the type_info of the vector.

◆ getVecTypeName()

std::string SG::AuxTypeRegistry::getVecTypeName ( SG::auxid_t auxid) const
inherited

Return the type of the STL vector used to hold an aux data item.

Return the type name of the STL vector used to hold an aux data item.

Parameters
auxidThe desired aux data item.

Returns an empty string if the type is not known.

Definition at line 952 of file AuxTypeRegistry.cxx.

953{
954 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
955 if (factory)
956 return normalizedTypeinfoName (*factory->tiVec());
957 return "";
958}

◆ inputRename()

const std::string & SG::AuxTypeRegistry::inputRename ( const std::string & key,
const std::string & name ) const
inherited

Check for an input renaming of an auxiliary variable.

key The SG key of the object to which the variable is attached.

name The name of the variable on the input file.

Returns
The variable name to use in the transient representation. Will usually be name, but may be different if there was a renaming request.

Definition at line 1274 of file AuxTypeRegistry.cxx.

1276{
1277 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
1278 lock_t lock (impl->m_mutex);
1279 if (impl->m_renameMap.empty())
1280 return name;
1281
1282 std::string fullkey = key + "." + name;
1283 auto it = impl->m_renameMap.find (fullkey);
1284 if (it != impl->m_renameMap.end())
1285 return it->second;
1286 return name;
1287}

◆ instance()

AuxTypeRegistry & SG::AuxTypeRegistry::instance ( )
staticinherited

Return the singleton registry instance.

Definition at line 640 of file AuxTypeRegistry.cxx.

641{
642 static AuxTypeRegistryImpl auxTypeRegistry ATLAS_THREAD_SAFE;
643 return auxTypeRegistry;
644}
#define ATLAS_THREAD_SAFE

◆ isLinked()

bool SG::AuxTypeRegistry::isLinked ( SG::auxid_t auxid) const
inherited

Test whether this is a linked variable.

Parameters
auxidThe aux data item to test.

◆ isLinkedName()

bool SG::AuxTypeRegistry::isLinkedName ( const std::string & name)
staticinherited

Test if a variable name corresponds to a linked variable.

Definition at line 1293 of file AuxTypeRegistry.cxx.

1294{
1295 return name.ends_with ("_linked");
1296}

◆ linkedName()

std::string SG::AuxTypeRegistry::linkedName ( const std::string & name)
staticinherited

Given a variable name, return the name of the corresponding linked variable.

Definition at line 1303 of file AuxTypeRegistry.cxx.

1304{
1305 return name + "_linked";
1306}

◆ linkedVariable()

SG::auxid_t SG::AuxTypeRegistry::linkedVariable ( SG::auxid_t auxid) const
inherited

Return the auxid if the linked variable, if there is one.

Parameters
auxidThe aux data item to test.

Returns null_auxid if auxid is invalid or it doesn't have a linked variable.

Definition at line 1007 of file AuxTypeRegistry.cxx.

1008{
1009 auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
1010 if (auxid >= impl->m_types.size())
1011 return null_auxid;
1012 return impl->m_types[auxid].m_linked;
1013}

◆ makeFactory()

template<class T, class ALLOC = AuxAllocator_t<T>>
std::unique_ptr< IAuxTypeVectorFactory > SG::AuxTypeRegistry::makeFactory ( ) const
privateinherited

Create an AuxTypeVectorFactory instance.

This is passed to findAuxID when we're looking up an item for which we know the type at compile-time.

The ALLOC template parameter is the allocator to use for the resulting vector.

◆ makeFactoryNull()

std::unique_ptr< IAuxTypeVectorFactory > SG::AuxTypeRegistry::makeFactoryNull ( ) const
privateinherited

makeFactory implementation that always returns nullptr.

This is passed to findAuxID when we're looking up an item for which we do not know the type at compile-time.

◆ makeKey()

std::string SG::AuxTypeRegistry::makeKey ( const std::string & name,
const std::string & clsname )
staticprivateinherited

Return the key used to look up an entry in m_auxids.

Parameters
nameThe name of the aux data item.
clsnameThe name of its associated class. May be blank.

Definition at line 864 of file AuxTypeRegistry.cxx.

866{
867 if (clsname.empty()) {
868 return name;
869 }
870 std::string output = clsname;
871 output += "::";
872 output += name;
873 return output;
874}
output
Definition merge.py:16

◆ makeVector()

std::unique_ptr< IAuxTypeVector > SG::AuxTypeRegistry::makeVector ( SG::auxid_t auxid,
size_t size,
size_t capacity ) const
inherited

Construct a new vector to hold an aux item.

Parameters
auxidThe desired aux data item.
sizeInitial size of the new vector.
capacityInitial capacity of the new vector.

Returns a newly-allocated object.

Parameters
auxidThe desired aux data item.
sizeInitial size of the new vector.
capacityInitial capacity of the new vector.

Definition at line 818 of file AuxTypeRegistry.cxx.

821{
822 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
823 assert (factory != 0);
824 return factory->create (auxid, size, capacity, isLinked (auxid));
825}
virtual std::unique_ptr< IAuxTypeVector > create(SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked) const =0
Create a vector object of this type.

◆ makeVectorFromData()

std::unique_ptr< IAuxTypeVector > SG::AuxTypeRegistry::makeVectorFromData ( SG::auxid_t auxid,
void * data,
IAuxTypeVector * linkedVector,
bool isPacked,
bool ownMode ) const
inherited

Construct an IAuxTypeVector object from a vector.

Parameters
dataThe vector object.
linkedVectorThe interface for another variable linked to this one, or nullptr if there isn't one. (We do not take ownership.)
isPackedIf true, data is a PackedContainer.
ownFlagIf true, the newly-created IAuxTypeVector object will take ownership of data.

If the element type is T, then data should be a pointer to a std::vector<T> object, which was obtained with new. But if isPacked is true, then data should instead point at an object of type SG::PackedContainer<T>.

Returns a newly-allocated object.

Definition at line 846 of file AuxTypeRegistry.cxx.

851{
852 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
853 assert (factory != 0);
854 return factory->createFromData (auxid, data, linkedVector,
855 isPacked, ownMode, isLinked (auxid));
856}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual std::unique_ptr< IAuxTypeVector > createFromData(SG::auxid_t auxid, void *data, IAuxTypeVector *linkedVector, bool isPacked, bool ownFlag, bool isLinked) const =0
Create a vector object of this type from a data blob.

◆ numVariables()

size_t SG::AuxTypeRegistry::numVariables ( ) const
inherited

Return the total number of registered auxiliary variable.

(This will be one more than the current largest auxid.)

Definition at line 652 of file AuxTypeRegistry.cxx.

653{
654 auto* impl = static_cast<const AuxTypeRegistryImpl*> (this);
655 return impl->m_types.size();
656}

◆ setInputRenameMap()

void SG::AuxTypeRegistry::setInputRenameMap ( const Athena::InputRenameMap_t * map,
const IStringPool & pool )
inherited

Declare input renaming requests.

Parameters
mapMap of (hashed) sgkey -> sgkey for renaming requests.
poolString pool in which the hashed keys are defined.

This is called by AddressRemappingSvc when there is a request to rename input objects. It saves any requests involving renaming of auxiliary variables and makes that information available via inputRename.

Definition at line 1238 of file AuxTypeRegistry.cxx.

1240{
1241 auto impl = static_cast<AuxTypeRegistryImpl*> (this);
1242
1243 lock_t lock (impl->m_mutex);
1244 impl->m_renameMap.clear();
1245 if (!map) return;
1246 for (const auto& p : *map) {
1247 sgkey_t from_sgkey = p.first;
1248 sgkey_t to_sgkey = p.second.m_sgkey;
1249
1250 const std::string* from_str = pool.keyToString (from_sgkey);
1251 if (!from_str) continue;
1252 std::string::size_type from_dpos = from_str->find ('.');
1253 if (from_dpos == std::string::npos || from_dpos == from_str->size()-1) continue;
1254
1255 const std::string* to_str = pool.keyToString (to_sgkey);
1256 if (!to_str) continue;
1257 std::string::size_type to_dpos = to_str->find ('.');
1258 if (to_dpos == std::string::npos || to_dpos == to_str->size()-1) continue;
1259
1260 impl->m_renameMap[*from_str] = to_str->substr (to_dpos+1, std::string::npos);
1261 }
1262}
virtual const std::string * keyToString(sgkey_t key) const =0
Find the string corresponding to a given key.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32

◆ swap()

void SG::AuxTypeRegistry::swap ( SG::auxid_t auxid,
AuxVectorData & a,
size_t aindex,
AuxVectorData & b,
size_t bindex,
size_t n ) const
inherited

Swap elements between vectors.

Parameters
auxidThe aux data item being operated on.
aContainer for the first vector.
aindexIndex of the first element in the first vector.
bContainer for the second vector.
bindexIndex of the first element in the second vector.
nNumber of elements to swap.

a and @ b can be either the same or different. However, the ranges should not overlap.

Definition at line 1074 of file AuxTypeRegistry.cxx.

1078{
1079 const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1080 if (factory)
1081 factory->swap (auxid, a, aindex, b, bindex, n);
1082}
static Double_t a
virtual void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const =0
Swap elements between vectors.

Member Data Documentation

◆ m_allocMap

allocMap_t SG::AuxTypeRegistryImpl::m_allocMap

Definition at line 224 of file AuxTypeRegistry.cxx.

◆ m_auxids

id_map_t SG::AuxTypeRegistryImpl::m_auxids

Definition at line 206 of file AuxTypeRegistry.cxx.

◆ m_factories

ti_map_t SG::AuxTypeRegistryImpl::m_factories

Definition at line 210 of file AuxTypeRegistry.cxx.

◆ m_mutex

mutex_t SG::AuxTypeRegistryImpl::m_mutex
mutable

Mutex controlling access to the registry.

Definition at line 232 of file AuxTypeRegistry.cxx.

◆ m_oldFactories

std::vector<const IAuxTypeVectorFactory*> SG::AuxTypeRegistryImpl::m_oldFactories

Hold additional factory instances we need to delete.

Definition at line 213 of file AuxTypeRegistry.cxx.

◆ m_renameMap

renameMap_t SG::AuxTypeRegistryImpl::m_renameMap

Definition at line 218 of file AuxTypeRegistry.cxx.

◆ m_types

AthContainers_detail::concurrent_vector<typeinfo_t> SG::AuxTypeRegistryImpl::m_types

Table of aux data items, indexed by auxid.

Definition at line 202 of file AuxTypeRegistry.cxx.


The documentation for this class was generated from the following file: