 |
ATLAS Offline Software
|
Go to the documentation of this file.
94 const std::string& clsname,
97 const std::type_info& ti,
98 const std::type_info* ti_alloc,
99 const std::string* alloc_name,
117 const std::type_info& ti,
118 const std::type_info& ti_alloc,
136 const std::type_info& ti,
137 const std::string& ti_alloc_name,
138 std::unique_ptr<const IAuxTypeVectorFactory> factory);
148 static bool checkName (std::string_view
s) noexcept;
162 const std::type_info& ti,
163 const std::type_info& ti_alloc);
170 AthContainers_detail::atomic<const IAuxTypeVectorFactory*>
m_factory;
195 bool checkAlloc (
const std::type_info* ti_alloc,
196 const std::string* alloc_name)
const;
202 AthContainers_detail::concurrent_vector<typeinfo_t>
m_types;
205 using id_map_t = CxxUtils::ConcurrentStrMap<SG::auxid_t, CxxUtils::SimpleUpdater>;
209 using ti_map_t = CxxUtils::ConcurrentStrMap<const IAuxTypeVectorFactory*, CxxUtils::SimpleUpdater>;
223 using allocMap_t = CxxUtils::ConcurrentStrMap<const std::type_info*, CxxUtils::SimpleUpdater>;
243 m_factories (
ti_map_t::Updater_t()),
246 m_types.reserve (auxid_set_size_hint);
249 #define ADD_FACTORY(T) AuxTypeRegistry::addFactory(typeid(T), typeid(AuxAllocator_t<T>), std::make_unique<AuxTypeVectorFactory<T> >())
298 if (
p.first.find (
";TI;") == std::string::npos) {
333 const std::string& clsname,
336 const std::type_info& ti,
337 const std::type_info* ti_alloc,
338 const std::string* alloc_name,
339 std::unique_ptr<IAuxTypeVectorFactory> (
AuxTypeRegistry::*makeFactory) ()
const)
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())
390 if ((&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
391 m.checkAlloc (ti_alloc, alloc_name))
394 if ((*
m.m_factory).isDynamic()) {
395 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*
makeFactory)();
398 ti_alloc = fac2->tiAlloc();
400 std::string allocName = fac2->tiAllocName();
421 (!clsname.empty() && !
checkName (clsname))))
430 else if (alloc_name) {
435 if (def_alloc_name[def_alloc_name.size()-1] ==
'>') def_alloc_name +=
' ';
436 def_alloc_name +=
'>';
441 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*
makeFactory)();
444 ti_alloc = fac2->tiAlloc();
446 std::string allocName = fac2->tiAllocName();
453 if (!fac)
return null_auxid;
454 if (!ti_alloc) ti_alloc = fac->
tiAlloc();
459 t.m_clsname = clsname;
461 t.m_ti_alloc = ti_alloc;
490 const std::type_info& ti,
491 const std::type_info& ti_alloc,
494 std::string
key = std::string (ti.name()) +
";TI;" + ti_alloc.name();
497 if (
it->second->isDynamic() && !factory->
isDynamic()) {
503 factory =
it->second;
512 m_allocMap.insert_or_assign (ti.name(), &ti_alloc);
533 const std::type_info& ti,
534 const std::string& ti_alloc_name,
535 std::unique_ptr<const IAuxTypeVectorFactory> factory)
537 std::string
key = ti.name();
539 key += ti_alloc_name;
543 if (
it->second->isDynamic() && !factory->isDynamic()) {
549 fac =
m_factories.insert_or_assign (
key, factory.release()).first->second;
556 fac =
m_factories.insert_or_assign (
key, factory.release()).first->second;
571 if (
s.empty())
return false;
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 ==
'_';
592 const std::type_info& ti,
593 const std::type_info& ti_alloc)
595 std::string
key = ti.name();
597 key += ti_alloc.name();
618 const std::string* alloc_name)
const
622 return strcmp (ti_alloc->name(),
m_ti_alloc->name()) == 0;
643 return auxTypeRegistry;
655 return impl->m_types.size();
674 const std::string&
name,
675 const std::string& clsname ,
681 ti,
nullptr,
nullptr,
704 const std::type_info& ti,
705 const std::string&
name,
706 const std::string& clsname ,
713 ti, &ti_alloc,
nullptr,
734 const std::type_info& ti,
735 const std::string&
name,
736 const std::string& clsname ,
742 ti,
nullptr, &alloc_type,
758 const std::string& clsname)
const
765 AuxTypeRegistryImpl::id_map_t::const_iterator
i =
766 impl->m_auxids.find (clsname.empty() ?
769 if (
i !=
impl->m_auxids.end()) {
788 const std::type_info& ti,
789 const std::type_info& ti_alloc,
795 if ( ! ((&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
796 m.checkAlloc (&ti_alloc,
nullptr)))
817 std::unique_ptr<IAuxTypeVector>
820 size_t capacity)
const
823 assert (factory != 0);
845 std::unique_ptr<IAuxTypeVector>
853 assert (factory != 0);
855 isPacked, ownMode,
isLinked (auxid));
865 const std::string& clsname)
867 if (clsname.empty()) {
870 std::string output = clsname;
885 if (auxid >=
impl->m_types.size())
887 return impl->m_types[auxid].m_name;
899 if (auxid >=
impl->m_types.size())
901 return impl->m_types[auxid].m_clsname;
912 if (auxid >=
impl->m_types.size())
914 return impl->m_types[auxid].m_ti;
927 if (auxid >=
impl->m_types.size())
941 return factory->
tiVec();
968 if (auxid >=
impl->m_types.size())
970 return impl->m_types[auxid].m_ti_alloc;
994 if (auxid >=
impl->m_types.size())
996 return impl->m_types[auxid].m_flags;
1010 if (auxid >=
impl->m_types.size())
1012 return impl->m_types[auxid].m_linked;
1034 factory->
copy (auxid, dst, dst_index,
src, src_index,
n);
1081 factory->
swap (auxid,
a, aindex,
b, bindex,
n);
1098 factory->
clear (auxid, dst, dst_index,
n);
1112 const std::type_info& ti_alloc)
1116 return impl->getFactory (
lock, ti, ti_alloc);
1131 if (auxid >=
impl->m_types.size())
1133 return impl->m_types[auxid].m_factory;
1147 const std::string& alloc_name)
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()) {
1174 const std::type_info& ti_alloc,
1175 std::unique_ptr<const IAuxTypeVectorFactory> factory)
1182 return impl->addFactory (
lock, ti, ti_alloc, fac);
1199 const std::string& ti_alloc_name,
1200 std::unique_ptr<const IAuxTypeVectorFactory> factory)
1204 return impl->addFactory (
lock, ti, ti_alloc_name, std::move (factory));
1226 #ifndef XAOD_STANDALONE
1244 impl->m_renameMap.clear();
1246 for (
const auto&
p : *map) {
1248 sgkey_t to_sgkey =
p.second.m_sgkey;
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;
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;
1260 impl->m_renameMap[*from_str] = to_str->substr (to_dpos+1, std::string::npos);
1275 const std::string&
name)
const
1279 if (
impl->m_renameMap.empty())
1282 std::string fullkey =
key +
"." +
name;
1283 auto it =
impl->m_renameMap.find (fullkey);
1284 if (
it !=
impl->m_renameMap.end())
1295 return name.ends_with (
"_linked");
1305 return name +
"_linked";
1315 if (
className.find (
"SG::JaggedVecElt<") != std::string::npos) {
1318 if (
className.find (
"SG::PackedLink<") != std::string::npos) {
const IAuxTypeVectorFactory * getFactory(const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
char data[hepevt_bytes_allocation_ATLAS]
Abstract interface for looking up strings/CLIDs in a pool.
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.
std::unique_ptr< IAuxTypeVector > makeVectorFromData(SG::auxid_t auxid, void *data, IAuxTypeVector *linkedVector, bool isPacked, bool ownFlag) const
Construct an IAuxTypeVector object from a vector.
const IAuxTypeVectorFactory * addFactory(const std::type_info &ti, const std::type_info &ti_alloc, std::unique_ptr< const IAuxTypeVectorFactory > factory)
Add a new type -> factory mapping.
virtual size_t getEltSize() const =0
Return the size of an element of this vector type.
AthContainers_detail::atomic< const IAuxTypeVectorFactory * > m_factory
Factory object.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
std::unordered_map< std::string, std::string > renameMap_t
Save the information provided by setInputRenameMap.
~AuxTypeRegistryImpl()
Destructor.
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
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...
AthContainers_detail::lock_guard< mutex_t > lock_t
static std::string makeKey(const std::string &name, const std::string &clsname)
Return the key used to look up an entry in m_auxids.
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.
std::string getName(SG::auxid_t auxid) const
Return the name of 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.
Exceptions that can be thrown from AthContainers.
Hash map from strings allowing concurrent, lockless reads.
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.
const std::string & inputRename(const std::string &key, const std::string &name) const
Check for an input renaming of an auxiliary variable.
CxxUtils::ConcurrentStrMap< const IAuxTypeVectorFactory *, CxxUtils::SimpleUpdater > ti_map_t
Map from type_info name + allocator ti name -> IAuxTypeVectorFactory.
const std::type_info * getAllocType(SG::auxid_t auxid) const
Return the type of the vector allocator.
CxxUtils::ConcurrentStrMap< const std::type_info *, CxxUtils::SimpleUpdater > allocMap_t
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.
AuxTypeRegistry()
Constructor.
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 fence_seq_cst()
A sequentially-consistent fence.
~AuxTypeRegistry()
Destructor.
virtual std::string tiAllocName() const =0
Return the (demangled) name of the vector allocator.
Handle mappings between names and auxid_t.
static bool checkName(std::string_view s) noexcept
Check for valid variable name.
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.
AthContainers_detail::mutex mutex_t
@ Linked
Mark that this variable is linked to another one.
size_t auxid_t
Identifier for a particular aux data item.
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
mutex_t m_mutex
Mutex controlling access to the registry.
@Brief Implementation class for AuxTypeRegistry.
void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const
Swap elements between vectors.
SG::SGKeyMap< InputRenameEntry > InputRenameMap_t
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
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.
Flags getFlags(SG::auxid_t auxid) const
Return flags associated with an auxiliary variable.
AthContainers_detail::concurrent_vector< typeinfo_t > m_types
Table of aux data items, indexed by auxid.
Interface for factory objects that create vectors.
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.
virtual const std::type_info * tiAlloc() const =0
Return the type_info of the vector allocator.
SG::auxid_t linkedVariable(SG::auxid_t auxid) const
Return the auxid if the linked variable, if there is one.
size_t getEltSize(SG::auxid_t auxid) const
Return size of an element in the STL vector.
std::unique_ptr< IAuxTypeVectorFactory > makeFactory() const
Create an AuxTypeVectorFactory instance.
Helper for emitting error messages.
Used as type_info when we read an aux data item but it doesn't exist in the registry.
static bool isLinkedName(const std::string &name)
Test if a variable name corresponds to a linked variable.
std::string m_alloc_name
Name of the vector allocator.
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.
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
size_t numVariables() const
Return the total number of registered auxiliary variable.
bool checkAlloc(const std::type_info *ti_alloc, const std::string *alloc_name) const
Check that the allocator type for this entry matches the requested type.
Hold information about one aux data item.
std::string m_clsname
Class name associated with this aux data item. May be blank.
AuxVarFlags
Additional flags to qualify an auxiliary variable.
void clear(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, size_t n) const
Clear a range of elements within a vector.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
std::string getClassName(SG::auxid_t auxid) const
Return the class name associated with an aux data item (may be blank).
Exception — Flag mismatch for aux variable.
Implementation of IAuxTypeVector for specific types.
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.
virtual bool isDynamic() const =0
True if the vectors created by this factory work by dynamic emulation (via TVirtualCollectionProxy or...
const std::type_info * m_ti_alloc
Type of the vector allocator. May be null for a dynamic type;.
std::unique_ptr< IAuxTypeVector > makeVector(SG::auxid_t auxid, size_t size, size_t capacity) const
Construct a new vector to hold an aux item.
std::vector< const IAuxTypeVectorFactory * > m_oldFactories
Hold additional factory instances we need to delete.
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.
bool isLinked(SG::auxid_t auxid) const
Test whether this is a linked variable.
void setInputRenameMap(const Athena::InputRenameMap_t *map, const IStringPool &pool)
Declare input renaming requests.
auxid_t m_linked
auxid of a linked variable, or null_auxid.
virtual const std::type_info * tiVec() const =0
Return the type_info of the vector.
Auxiliary variable type allowing storage as a jagged vector. That is, the payloads for all the DataVe...
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
void checkAuxID(const SG::auxid_t auxid, const Flags flags=Flags::None)
Verify type for an aux variable.
@ Atomic
Mark that this variable should only be accessed atomically.
std::string m_name
Aux data name.
std::unique_ptr< IAuxTypeVectorFactory > makeFactoryNull() const
makeFactory implementation that always returns nullptr.
Simple (non-deleting) Updater implementation.
Abstract interface for manipulating vectors of arbitrary types.
Describe one element of a jagged vector.
Exception — Linked variable mismatch.
Handle mappings between names and auxid_t.
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.
Manage lookup of vectors of auxiliary data.
#define ATLAS_THREAD_SAFE
Flags m_flags
Additional type flags.
Define macros for attributes used to control the static checker.
void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const
Copy elements between vectors.
const std::type_info * m_ti
Type of the aux data item.
CxxUtils::ConcurrentStrMap< SG::auxid_t, CxxUtils::SimpleUpdater > id_map_t
Map from name -> auxid.
Exception — Type mismatch for aux variable.
AuxTypeRegistryImpl()
Constructor.
Exception — Bad name for auxiliary variable.
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.
constexpr const char * auxAllocatorNamePrefix