ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Friends | List of all members
SG::AuxTypeRegistry Class Reference

Handle mappings between names and auxid_t. More...

#include <AuxTypeRegistry.h>

Inheritance diagram for SG::AuxTypeRegistry:
Collaboration diagram for SG::AuxTypeRegistry:

Public Types

using Flags = SG::AuxVarFlags
 Additional flags to qualify an auxiliary variable. More...
 

Public Member Functions

size_t numVariables () const
 Return the total number of registered auxiliary variable. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
SG::auxid_t findAuxID (const std::string &name, const std::string &clsname="") const
 Look up a name -> auxid_t mapping. More...
 
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. More...
 
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. More...
 
std::unique_ptr< IAuxTypeVectormakeVector (SG::auxid_t auxid, size_t size, size_t capacity) const
 Construct a new vector to hold an aux item. More...
 
std::unique_ptr< IAuxTypeVectormakeVectorFromData (SG::auxid_t auxid, void *data, IAuxTypeVector *linkedVector, bool isPacked, bool ownFlag) const
 Construct an IAuxTypeVector object from a vector. More...
 
std::string getName (SG::auxid_t auxid) const
 Return the name of an aux data item. More...
 
std::string getClassName (SG::auxid_t auxid) const
 Return the class name associated with an aux data item (may be blank). More...
 
const std::type_info * getType (SG::auxid_t auxid) const
 Return the type of an aux data item. More...
 
std::string getTypeName (SG::auxid_t auxid) const
 Return the type name of an aux data item. More...
 
const std::type_info * getVecType (SG::auxid_t auxid) const
 Return the type of the STL vector used to hold an aux data item. More...
 
std::string getVecTypeName (SG::auxid_t auxid) const
 Return the type of the STL vector used to hold an aux data item. More...
 
const std::type_info * getAllocType (SG::auxid_t auxid) const
 Return the type of the vector allocator. More...
 
size_t getEltSize (SG::auxid_t auxid) const
 Return size of an element in the STL vector. More...
 
Flags getFlags (SG::auxid_t auxid) const
 Return flags associated with an auxiliary variable. More...
 
bool isLinked (SG::auxid_t auxid) const
 Test whether this is a linked variable. More...
 
SG::auxid_t linkedVariable (SG::auxid_t auxid) const
 Return the auxid if the linked variable, if there is one. More...
 
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. More...
 
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. More...
 
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. More...
 
void swap (SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const
 Swap elements between vectors. More...
 
void clear (SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, size_t n) const
 Clear a range of elements within a vector. More...
 
const IAuxTypeVectorFactorygetFactory (const std::type_info &ti, const std::type_info &ti_alloc)
 Return the vector factory for a given vector element type. More...
 
const IAuxTypeVectorFactorygetFactory (const std::type_info &ti, const std::string &alloc_name)
 Return the vector factory for a given vector element type. More...
 
const IAuxTypeVectorFactorygetFactory (SG::auxid_t auxid) const
 Return the vector factory for a given auxid. More...
 
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. More...
 
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. More...
 
void setInputRenameMap (const Athena::InputRenameMap_t *map, const IStringPool &pool)
 Declare input renaming requests. More...
 
const std::string & inputRename (const std::string &key, const std::string &name) const
 Check for an input renaming of an auxiliary variable. More...
 

Static Public Member Functions

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

Private Types

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

Private Member Functions

 AuxTypeRegistry ()
 Constructor. More...
 
 ~AuxTypeRegistry ()
 Destructor. More...
 
 AuxTypeRegistry (const AuxTypeRegistry &)
 Disallow copy construction and assignment. More...
 
AuxTypeRegistryoperator= (const AuxTypeRegistry &)
 
template<class T , class ALLOC = AuxAllocator_t<T>>
std::unique_ptr< IAuxTypeVectorFactorymakeFactory () const
 Create an AuxTypeVectorFactory instance. More...
 
std::unique_ptr< IAuxTypeVectorFactorymakeFactoryNull () const
 makeFactory implementation that always returns nullptr. More...
 

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. More...
 

Friends

class AuxTypeRegistryImpl
 

Detailed Description

Handle mappings between names and auxid_t.

Each auxiliary data item associated with a container has a name. Internally, they are identified by small integers of type auxid_t. This class handles the mapping between names and auxid_t's. It also keeps track of the type of each aux data item, and provides some generic methods for operating on this data.

The auxid_t namespace is global, shared among all classes. It's no problem for two classes to use aux data with the same auxid_t, as long as the type is the same. If they want to define them as different types, though, that's a problem. To help with this, an optional class name may be supplied; this qualifies the aux data name to make it unique across classes.

This class is meant to be used as a singleton. Use the instance method to get the singleton instance.

Methods are locked internally as needed, so access is thread-safe. Thread-safety is however not supported in standalone builds.

Definition at line 60 of file AuxTypeRegistry.h.

Member Typedef Documentation

◆ Flags

Additional flags to qualify an auxiliary variable.

Definition at line 65 of file AuxTypeRegistry.h.

◆ lock_t

typedef AthContainers_detail::lock_guard<mutex_t> SG::AuxTypeRegistry::lock_t
private

Definition at line 541 of file AuxTypeRegistry.h.

◆ mutex_t

typedef AthContainers_detail::mutex SG::AuxTypeRegistry::mutex_t
private

Definition at line 540 of file AuxTypeRegistry.h.

Constructor & Destructor Documentation

◆ AuxTypeRegistry() [1/2]

SG::AuxTypeRegistry::AuxTypeRegistry ( )
private

Constructor.

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

Definition at line 1212 of file AuxTypeRegistry.cxx.

1213 {
1214 }

◆ ~AuxTypeRegistry()

SG::AuxTypeRegistry::~AuxTypeRegistry ( )
private

Destructor.

Definition at line 1220 of file AuxTypeRegistry.cxx.

1221 {
1222 }

◆ AuxTypeRegistry() [2/2]

SG::AuxTypeRegistry::AuxTypeRegistry ( const AuxTypeRegistry )
private

Disallow copy construction and assignment.

Member Function Documentation

◆ addFactory() [1/2]

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 1197 of file AuxTypeRegistry.cxx.

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

◆ addFactory() [2/2]

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 1172 of file AuxTypeRegistry.cxx.

1175 {
1176  auto impl = static_cast<AuxTypeRegistryImpl*> (this);
1177  lock_t lock (impl->m_mutex);
1178  std::string name = SG::normalizedTypeinfoName (ti_alloc);
1179  const IAuxTypeVectorFactory* fac =
1180  impl->addFactory (lock, ti, name, std::move(factory));
1181  return impl->addFactory (lock, ti, ti_alloc, fac);
1182 }

◆ 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 
)

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 
)

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 786 of file AuxTypeRegistry.cxx.

790 {
791  auto impl = static_cast<AuxTypeRegistryImpl*> (this);
792  AuxTypeRegistryImpl::typeinfo_t& m = impl->m_types.at (auxid);
793 
794  if ( ! ((&ti == m.m_ti || strcmp(ti.name(), m.m_ti->name()) == 0) &&
795  m.checkAlloc (&ti_alloc, nullptr)))
796  {
797  throw SG::ExcAuxTypeMismatch (auxid, ti, *m.m_ti,
798  SG::normalizedTypeinfoName (ti_alloc),
799  m.m_alloc_name);
800  }
801  if ((CxxUtils::test (m.m_flags, Flags::Atomic) &&
804  {
805  throw SG::ExcFlagMismatch (auxid, ti, m.m_flags, flags);
806  }
807 }

◆ classNameHasLink()

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

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

Definition at line 1312 of file AuxTypeRegistry.cxx.

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

◆ clear()

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

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 1091 of file AuxTypeRegistry.cxx.

1094 {
1095  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1096  if (factory)
1097  factory->clear (auxid, dst, dst_index, n);
1098 }

◆ 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

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

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 1026 of file AuxTypeRegistry.cxx.

1030 {
1031  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1032  if (factory)
1033  factory->copy (auxid, dst, dst_index, src, src_index, n);
1034 }

◆ 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

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 1049 of file AuxTypeRegistry.cxx.

1053 {
1054  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1055  if (factory) {
1056  factory->copyForOutput (auxid, dst, dst_index, src, src_index, n);
1057  }
1058 }

◆ findAuxID()

SG::auxid_t SG::AuxTypeRegistry::findAuxID ( const std::string &  name,
const std::string &  clsname = "" 
) 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.

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 756 of file AuxTypeRegistry.cxx.

758 {
759  auto impl = static_cast<const AuxTypeRegistryImpl*> (this);
760 
761  // No locking needed here.
762  // The extra test here is to avoid having to copy a string
763  // in the common case where clsname is blank.
764  AuxTypeRegistryImpl::id_map_t::const_iterator i =
765  impl->m_auxids.find (clsname.empty() ?
766  name :
767  makeKey (name, clsname));
768  if (i != impl->m_auxids.end()) {
769  return i->second;
770  }
771  return null_auxid;
772 }

◆ getAllocType()

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

Return the type of the vector allocator.

Parameters
auxidThe desired aux data item.

Definition at line 964 of file AuxTypeRegistry.cxx.

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

◆ 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 
)

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 732 of file AuxTypeRegistry.cxx.

738 {
739  auto impl = static_cast<AuxTypeRegistryImpl*> (this);
740  return impl->findAuxID (name, clsname, flags, linkedVariable,
741  ti, nullptr, &alloc_type,
743 }

◆ 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 
)

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 
)

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 672 of file AuxTypeRegistry.cxx.

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

◆ 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::*)() const  makeFactory = &AuxTypeRegistry::makeFactoryNull 
)

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 702 of file AuxTypeRegistry.cxx.

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

◆ getClassName()

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

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

Parameters
auxidThe desired aux data item.

Definition at line 895 of file AuxTypeRegistry.cxx.

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

◆ getEltSize()

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

Return size of an element in the STL vector.

Parameters
auxidThe desired aux data item.

Definition at line 977 of file AuxTypeRegistry.cxx.

978 {
979  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
980  if (factory)
981  return factory->getEltSize();
982  return 0;
983 }

◆ getFactory() [1/3]

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 1145 of file AuxTypeRegistry.cxx.

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

◆ getFactory() [2/3]

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 1110 of file AuxTypeRegistry.cxx.

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

◆ getFactory() [3/3]

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 1127 of file AuxTypeRegistry.cxx.

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

◆ getFlags()

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

Return flags associated with an auxiliary variable.

Parameters
auxidThe desired aux data item.

Definition at line 990 of file AuxTypeRegistry.cxx.

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

◆ getName()

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

Return the name of an aux data item.

Parameters
auxidThe desired aux data item.

Definition at line 881 of file AuxTypeRegistry.cxx.

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

◆ getType()

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

Return the type of an aux data item.

Parameters
auxidThe desired aux data item.

Definition at line 908 of file AuxTypeRegistry.cxx.

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

◆ getTypeName()

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

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 923 of file AuxTypeRegistry.cxx.

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

◆ getVecType()

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

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

Parameters
auxidThe desired aux data item.

Definition at line 936 of file AuxTypeRegistry.cxx.

937 {
938  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
939  if (factory)
940  return factory->tiVec();
941  return 0;
942 }

◆ getVecTypeName()

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

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 951 of file AuxTypeRegistry.cxx.

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

◆ inputRename()

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

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 1273 of file AuxTypeRegistry.cxx.

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

◆ instance()

AuxTypeRegistry & SG::AuxTypeRegistry::instance ( )
static

Return the singleton registry instance.

Definition at line 639 of file AuxTypeRegistry.cxx.

640 {
641  static AuxTypeRegistryImpl auxTypeRegistry ATLAS_THREAD_SAFE;
642  return auxTypeRegistry;
643 }

◆ isLinked()

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

Test whether this is a linked variable.

Parameters
auxidThe aux data item to test.

◆ isLinkedName()

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

Test if a variable name corresponds to a linked variable.

Definition at line 1292 of file AuxTypeRegistry.cxx.

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

◆ linkedName()

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

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

Definition at line 1302 of file AuxTypeRegistry.cxx.

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

◆ linkedVariable()

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

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 1006 of file AuxTypeRegistry.cxx.

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

◆ makeFactory()

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

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
private

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 
)
staticprivate

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 863 of file AuxTypeRegistry.cxx.

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

◆ makeVector()

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

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 817 of file AuxTypeRegistry.cxx.

820 {
821  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
822  assert (factory != 0);
823  return factory->create (auxid, size, capacity, isLinked (auxid));
824 }

◆ makeVectorFromData()

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

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 845 of file AuxTypeRegistry.cxx.

850 {
851  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
852  assert (factory != 0);
853  return factory->createFromData (auxid, data, linkedVector,
854  isPacked, ownMode, isLinked (auxid));
855 }

◆ numVariables()

size_t SG::AuxTypeRegistry::numVariables ( ) const

Return the total number of registered auxiliary variable.

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

Definition at line 651 of file AuxTypeRegistry.cxx.

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

◆ operator=()

AuxTypeRegistry& SG::AuxTypeRegistry::operator= ( const AuxTypeRegistry )
private

◆ setInputRenameMap()

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

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 1237 of file AuxTypeRegistry.cxx.

1239 {
1240  auto impl = static_cast<AuxTypeRegistryImpl*> (this);
1241 
1242  lock_t lock (impl->m_mutex);
1243  impl->m_renameMap.clear();
1244  if (!map) return;
1245  for (const auto& p : *map) {
1246  sgkey_t from_sgkey = p.first;
1247  sgkey_t to_sgkey = p.second.m_sgkey;
1248 
1249  const std::string* from_str = pool.keyToString (from_sgkey);
1250  if (!from_str) continue;
1251  std::string::size_type from_dpos = from_str->find (".");
1252  if (from_dpos == std::string::npos || from_dpos == from_str->size()-1) continue;
1253 
1254  const std::string* to_str = pool.keyToString (to_sgkey);
1255  if (!to_str) continue;
1256  std::string::size_type to_dpos = to_str->find (".");
1257  if (to_dpos == std::string::npos || to_dpos == to_str->size()-1) continue;
1258 
1259  impl->m_renameMap[*from_str] = to_str->substr (to_dpos+1, std::string::npos);
1260  }
1261 }

◆ swap()

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

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 1073 of file AuxTypeRegistry.cxx.

1077 {
1078  const SG::IAuxTypeVectorFactory* factory = getFactory (auxid);
1079  if (factory)
1080  factory->swap (auxid, a, aindex, b, bindex, n);
1081 }

Friends And Related Function Documentation

◆ AuxTypeRegistryImpl

friend class AuxTypeRegistryImpl
friend

Definition at line 538 of file AuxTypeRegistry.h.


The documentation for this class was generated from the following files:
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
SG::IAuxTypeVectorFactory::createFromData
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.
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
SG::IAuxTypeVectorFactory::getEltSize
virtual size_t getEltSize() const =0
Return the size of an element of this vector type.
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
SG::normalizedTypeinfoName
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...
Definition: normalizedTypeinfoName.cxx:120
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
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::IAuxTypeVectorFactory::create
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.
pool
pool namespace
Definition: libname.h:15
skel.it
it
Definition: skel.GENtoEVGEN.py:407
SG::IAuxTypeVectorFactory::clear
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.
SG::IAuxTypeVectorFactory::swap
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.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
SG::Linked
@ Linked
Mark that this variable is linked to another one.
Definition: AuxTypes.h:77
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::AuxTypeRegistry::AuxTypeRegistryImpl
friend class AuxTypeRegistryImpl
Definition: AuxTypeRegistry.h:538
beamspotman.n
n
Definition: beamspotman.py:731
SG::IAuxTypeVectorFactory
Interface for factory objects that create vectors.
Definition: IAuxTypeVectorFactory.h:50
SG::IAuxTypeVectorFactory::copyForOutput
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.
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
SG::AuxTypeRegistry::makeFactory
std::unique_ptr< IAuxTypeVectorFactory > makeFactory() const
Create an AuxTypeVectorFactory instance.
SG::IAuxTypeVectorFactory::copy
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.
SG::ExcFlagMismatch
Exception — Flag mismatch for aux variable.
Definition: Control/AthContainers/AthContainers/exceptions.h:376
merge.output
output
Definition: merge.py:17
CxxUtils::test
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
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::IAuxTypeVectorFactory::tiVec
virtual const std::type_info * tiVec() const =0
Return the type_info of the vector.
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
SG::Atomic
@ Atomic
Mark that this variable should only be accessed atomically.
Definition: AuxTypes.h:70
impl
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:46
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::AuxTypeRegistry::makeFactoryNull
std::unique_ptr< IAuxTypeVectorFactory > makeFactoryNull() const
makeFactory implementation that always returns nullptr.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
LArL1Calo_ComputeHVCorr.className
className
Definition: LArL1Calo_ComputeHVCorr.py:135
SG::ExcAuxTypeMismatch
Exception — Type mismatch for aux variable.
Definition: Control/AthContainers/AthContainers/exceptions.h:132
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37