 |
ATLAS Offline Software
|
Go to the documentation of this file.
93 const std::string& clsname,
96 const std::type_info& ti,
97 const std::type_info* ti_alloc,
98 const std::string* alloc_name,
116 const std::type_info& ti,
117 const std::type_info& ti_alloc,
135 const std::type_info& ti,
136 const std::string& ti_alloc_name,
137 std::unique_ptr<const IAuxTypeVectorFactory> factory);
161 const std::type_info& ti,
162 const std::type_info& ti_alloc);
169 AthContainers_detail::atomic<const IAuxTypeVectorFactory*>
m_factory;
194 bool checkAlloc (
const std::type_info* ti_alloc,
195 const std::string* alloc_name)
const;
201 AthContainers_detail::concurrent_vector<typeinfo_t>
m_types;
204 using id_map_t = CxxUtils::ConcurrentStrMap<SG::auxid_t, CxxUtils::SimpleUpdater>;
208 using ti_map_t = CxxUtils::ConcurrentStrMap<const IAuxTypeVectorFactory*, CxxUtils::SimpleUpdater>;
222 using allocMap_t = CxxUtils::ConcurrentStrMap<const std::type_info*, CxxUtils::SimpleUpdater>;
242 m_factories (
ti_map_t::Updater_t()),
245 m_types.reserve (auxid_set_size_hint);
248 #define ADD_FACTORY(T) AuxTypeRegistry::addFactory(typeid(T), typeid(AuxAllocator_t<T>), std::make_unique<AuxTypeVectorFactory<T> >())
297 if (
p.first.find (
";TI;") == std::string::npos) {
332 const std::string& clsname,
335 const std::type_info& ti,
336 const std::type_info* ti_alloc,
337 const std::string* alloc_name,
338 std::unique_ptr<IAuxTypeVectorFactory> (
AuxTypeRegistry::*makeFactory) ()
const)
354 (&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
355 m.checkAlloc (ti_alloc, alloc_name) &&
356 !(*
m.m_factory).isDynamic())
389 if ((&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
390 m.checkAlloc (ti_alloc, alloc_name))
393 if ((*
m.m_factory).isDynamic()) {
394 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*
makeFactory)();
397 ti_alloc = fac2->tiAlloc();
399 std::string allocName = fac2->tiAllocName();
400 m.m_factory =
addFactory (lock, ti, allocName, std::move (fac2));
402 m.m_factory =
addFactory (lock, ti, *ti_alloc,
m.m_factory);
420 (!clsname.empty() && !
checkName (clsname))))
429 else if (alloc_name) {
434 if (def_alloc_name[def_alloc_name.size()-1] ==
'>') def_alloc_name +=
' ';
435 def_alloc_name +=
'>';
440 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*
makeFactory)();
443 ti_alloc = fac2->tiAlloc();
445 std::string allocName = fac2->tiAllocName();
446 fac =
addFactory (lock, ti, allocName, std::move (fac2));
452 if (!fac)
return null_auxid;
453 if (!ti_alloc) ti_alloc = fac->
tiAlloc();
458 t.m_clsname = clsname;
460 t.m_ti_alloc = ti_alloc;
489 const std::type_info& ti,
490 const std::type_info& ti_alloc,
493 std::string
key = std::string (ti.name()) +
";TI;" + ti_alloc.name();
496 if (
it->second->isDynamic() && !factory->
isDynamic()) {
502 factory =
it->second;
511 m_allocMap.insert_or_assign (ti.name(), &ti_alloc);
532 const std::type_info& ti,
533 const std::string& ti_alloc_name,
534 std::unique_ptr<const IAuxTypeVectorFactory> factory)
536 std::string
key = ti.name();
538 key += ti_alloc_name;
542 if (
it->second->isDynamic() && !factory->isDynamic()) {
570 static const std::string chars1 =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
571 static const std::string chars2 = chars1 +
"0123456789";
573 if (
s.empty())
return false;
574 if (chars1.find (
s[0]) == std::string::npos)
return false;
575 return s.find_first_not_of (chars2, 1) == std::string::npos;
591 const std::type_info& ti,
592 const std::type_info& ti_alloc)
594 std::string
key = ti.name();
596 key += ti_alloc.name();
617 const std::string* alloc_name)
const
621 return strcmp (ti_alloc->name(),
m_ti_alloc->name()) == 0;
642 return auxTypeRegistry;
654 return impl->m_types.size();
673 const std::string&
name,
674 const std::string& clsname ,
680 ti,
nullptr,
nullptr,
703 const std::type_info& ti,
704 const std::string&
name,
705 const std::string& clsname ,
712 ti, &ti_alloc,
nullptr,
733 const std::type_info& ti,
734 const std::string&
name,
735 const std::string& clsname ,
741 ti,
nullptr, &alloc_type,
757 const std::string& clsname)
const
764 AuxTypeRegistryImpl::id_map_t::const_iterator
i =
765 impl->m_auxids.find (clsname.empty() ?
768 if (
i !=
impl->m_auxids.end()) {
787 const std::type_info& ti,
788 const std::type_info& ti_alloc,
794 if ( ! ((&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
795 m.checkAlloc (&ti_alloc,
nullptr)))
816 std::unique_ptr<IAuxTypeVector>
819 size_t capacity)
const
822 assert (factory != 0);
844 std::unique_ptr<IAuxTypeVector>
852 assert (factory != 0);
854 isPacked, ownMode,
isLinked (auxid));
864 const std::string& clsname)
866 if (clsname.empty()) {
869 std::string output = clsname;
884 if (auxid >=
impl->m_types.size())
886 return impl->m_types[auxid].m_name;
898 if (auxid >=
impl->m_types.size())
900 return impl->m_types[auxid].m_clsname;
911 if (auxid >=
impl->m_types.size())
913 return impl->m_types[auxid].m_ti;
926 if (auxid >=
impl->m_types.size())
940 return factory->
tiVec();
967 if (auxid >=
impl->m_types.size())
969 return impl->m_types[auxid].m_ti_alloc;
993 if (auxid >=
impl->m_types.size())
995 return impl->m_types[auxid].m_flags;
1009 if (auxid >=
impl->m_types.size())
1011 return impl->m_types[auxid].m_linked;
1033 factory->
copy (auxid, dst, dst_index,
src, src_index,
n);
1080 factory->
swap (auxid,
a, aindex,
b, bindex,
n);
1097 factory->
clear (auxid, dst, dst_index,
n);
1111 const std::type_info& ti_alloc)
1115 return impl->getFactory (lock, ti, ti_alloc);
1130 if (auxid >=
impl->m_types.size())
1132 return impl->m_types[auxid].m_factory;
1146 const std::string& alloc_name)
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()) {
1173 const std::type_info& ti_alloc,
1174 std::unique_ptr<const IAuxTypeVectorFactory> factory)
1180 impl->addFactory (lock, ti,
name, std::move(factory));
1181 return impl->addFactory (lock, ti, ti_alloc, fac);
1198 const std::string& ti_alloc_name,
1199 std::unique_ptr<const IAuxTypeVectorFactory> factory)
1203 return impl->addFactory (lock, ti, ti_alloc_name, std::move (factory));
1225 #ifndef XAOD_STANDALONE
1243 impl->m_renameMap.clear();
1245 for (
const auto&
p : *map) {
1247 sgkey_t to_sgkey =
p.second.m_sgkey;
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;
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;
1259 impl->m_renameMap[*from_str] = to_str->substr (to_dpos+1, std::string::npos);
1274 const std::string&
name)
const
1278 if (
impl->m_renameMap.empty())
1281 std::string fullkey =
key +
"." +
name;
1282 auto it =
impl->m_renameMap.find (fullkey);
1283 if (
it !=
impl->m_renameMap.end())
1294 return name.ends_with (
"_linked");
1304 return name +
"_linked";
1314 if (
className.find (
"SG::JaggedVecElt<") != std::string::npos) {
1317 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.
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.
static bool checkName(const std::string &s)
Check for valid variable name.
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