|
ATLAS Offline Software
|
Go to the documentation of this file.
30 const std::string* alloc_name)
const
34 return strcmp (ti_alloc->name(),
m_ti_alloc->name()) == 0;
52 return auxTypeRegistry;
81 const std::string&
name,
82 const std::string& clsname ,
105 const std::type_info& ti,
106 const std::string&
name,
107 const std::string& clsname ,
130 const std::type_info& ti,
131 const std::string&
name,
132 const std::string& clsname ,
151 const std::string& clsname )
const
156 id_map_t::const_iterator
i =
m_auxids.find (clsname.empty() ?
178 const std::type_info& ti,
179 const std::type_info& ti_alloc,
184 if ( ! ((&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
185 m.checkAlloc (&ti_alloc,
nullptr)))
205 std::unique_ptr<IAuxTypeVector>
208 size_t capacity)
const
211 assert (factory != 0);
212 return factory->
create (auxid,
size, capacity);
230 std::unique_ptr<IAuxTypeVector>
237 assert (factory != 0);
248 const std::string& clsname)
250 if (clsname.empty()) {
253 return clsname +
"::" +
name;
279 return m_types[auxid].m_clsname;
317 return factory->
tiVec();
345 return m_types[auxid].m_ti_alloc;
380 factory->
copy (auxid, dst, dst_index,
src, src_index,
n);
427 factory->
swap (auxid,
a, aindex,
b, bindex,
n);
444 factory->
clear (auxid, dst, dst_index,
n);
458 const std::type_info& ti_alloc)
477 const std::type_info& ti,
478 const std::type_info& ti_alloc)
480 std::string
key = std::string (ti.name()) +
";TI;" + ti_alloc.name();
506 const std::string& alloc_name)
508 std::string
key = std::string (ti.name()) +
";" + alloc_name;
531 const std::type_info& ti_alloc,
532 std::unique_ptr<const IAuxTypeVectorFactory> factory)
555 const std::string& ti_alloc_name,
556 std::unique_ptr<const IAuxTypeVectorFactory> factory)
559 return addFactory (lock, ti, ti_alloc_name, std::move (factory));
577 const std::type_info& ti,
578 const std::type_info& ti_alloc,
581 std::string
key = std::string (ti.name()) +
";TI;" + ti_alloc.name();
584 if (
it->second->isDynamic() && !factory->
isDynamic()) {
590 factory =
it->second;
599 m_allocMap.insert_or_assign (ti.name(), &ti_alloc);
620 const std::type_info& ti,
621 const std::string& ti_alloc_name,
622 std::unique_ptr<const IAuxTypeVectorFactory> factory)
624 std::string
key = std::string (ti.name()) +
";" + ti_alloc_name;
628 if (
it->second->isDynamic() && !factory->isDynamic()) {
658 m_types.reserve (auxid_set_size_hint);
661 #define ADD_FACTORY(T) addFactory(typeid(T), typeid(AuxAllocator_t<T>), std::make_unique<AuxTypeVectorFactory<T> >())
696 if (
p.first.find (
";TI;") == std::string::npos) {
730 const std::string& clsname,
732 const std::type_info& ti,
733 const std::type_info* ti_alloc,
734 const std::string* alloc_name,
735 std::unique_ptr<IAuxTypeVectorFactory> (
AuxTypeRegistry::*makeFactory) ()
const)
750 (&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
751 m.checkAlloc (ti_alloc, alloc_name) &&
752 !(*
m.m_factory).isDynamic())
779 if ((&ti ==
m.m_ti || strcmp(ti.name(),
m.m_ti->name()) == 0) &&
780 m.checkAlloc (ti_alloc, alloc_name))
783 if ((*
m.m_factory).isDynamic()) {
784 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*
makeFactory)();
787 ti_alloc = fac2->tiAlloc();
789 std::string allocName = fac2->tiAllocName();
790 m.m_factory =
addFactory (lock, ti, allocName, std::move (fac2));
792 m.m_factory =
addFactory (lock, ti, *ti_alloc,
m.m_factory);
810 (!clsname.empty() && !
checkName (clsname))))
819 else if (alloc_name) {
824 if (def_alloc_name[def_alloc_name.size()-1] ==
'>') def_alloc_name +=
" ";
825 def_alloc_name +=
">";
830 std::unique_ptr<IAuxTypeVectorFactory> fac2 = (*this.*
makeFactory)();
833 ti_alloc = fac2->tiAlloc();
835 std::string allocName = fac2->tiAllocName();
836 fac =
addFactory (lock, ti, allocName, std::move (fac2));
842 if (!fac)
return null_auxid;
843 if (!ti_alloc) ti_alloc = fac->
tiAlloc();
848 t.m_clsname = clsname;
850 t.m_ti_alloc = ti_alloc;
861 #ifndef XAOD_STANDALONE
879 for (
const auto&
p : *map) {
881 sgkey_t to_sgkey =
p.second.m_sgkey;
883 const std::string* from_str =
pool.keyToString (from_sgkey);
884 if (!from_str)
continue;
885 std::string::size_type from_dpos = from_str->find (
".");
886 if (from_dpos == std::string::npos || from_dpos == from_str->size()-1)
continue;
888 const std::string* to_str =
pool.keyToString (to_sgkey);
889 if (!to_str)
continue;
890 std::string::size_type to_dpos = to_str->find (
".");
891 if (to_dpos == std::string::npos || to_dpos == to_str->size()-1)
continue;
893 m_renameMap[*from_str] = to_str->substr (to_dpos+1, std::string::npos);
908 const std::string&
name)
const
914 std::string fullkey =
key +
"." +
name;
931 static const std::string chars1 =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
932 static const std::string chars2 = chars1 +
"0123456789";
934 if (
s.empty())
return false;
935 if (chars1.find (
s[0]) == std::string::npos)
return false;
936 return s.find_first_not_of (chars2, 1) == 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.
CxxUtils::ConcurrentStrMap< const std::type_info *, CxxUtils::SimpleUpdater > allocMap_t
char data[hepevt_bytes_allocation_ATLAS]
Abstract interface for looking up strings/CLIDs in a pool.
std::unique_ptr< IAuxTypeVector > makeVectorFromData(SG::auxid_t auxid, void *data, bool isPacked, bool ownFlag) const
Construct an IAuxTypeVector object from a vector.
bool starts_with(const char *s, const char *prefix)
Test whether one null-terminated byte string starts with another.
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.
const std::type_info * m_ti_alloc
Type of the vector allocator. May be null for a dynamic type;.
SG::auxid_t getAuxID(const std::string &name, const std::string &clsname="", const Flags flags=Flags::None)
Look up a name -> auxid_t mapping.
std::vector< const IAuxTypeVectorFactory * > m_oldFactories
Hold additional factory instances we need to delete.
virtual size_t getEltSize() const =0
Return the size of an element of this vector type.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
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...
void setInputRenameMap(const Athena::IInputRename::InputRenameMap_t *map, const IStringPool &pool)
Declare input renaming requests.
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.
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.
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.
const std::type_info * getAllocType(SG::auxid_t auxid) const
Return the type of the vector allocator.
virtual std::unique_ptr< IAuxTypeVector > create(SG::auxid_t auxid, size_t size, size_t capacity) const =0
Create a vector object of this type.
CxxUtils::ConcurrentStrMap< const IAuxTypeVectorFactory *, CxxUtils::SimpleUpdater > ti_map_t
Map from type_info name + allocator ti name -> IAuxTypeVectorFactory.
AthContainers_detail::concurrent_vector< typeinfo_t > m_types
Table of aux data items, indexed by auxid.
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.
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.
void swap(SG::auxid_t auxid, AuxVectorData &a, size_t aindex, AuxVectorData &b, size_t bindex, size_t n) const
Swap elements between vectors.
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
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.
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.
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.
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).
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...
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.
virtual const std::type_info * tiVec() const =0
Return the type_info of the vector.
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.
Hold information about one aux data item.
mutex_t m_mutex
Mutex controlling access to the registry.
@ Atomic
Mark that this variable should only be accessed atomically.
static bool checkName(const std::string &s)
Check for valid variable name.
std::unique_ptr< IAuxTypeVectorFactory > makeFactoryNull() const
makeFactory implementation that always returns nullptr.
virtual std::unique_ptr< IAuxTypeVector > createFromData(SG::auxid_t auxid, void *data, bool isPacked, bool ownFlag) const =0
Create a vector object of this type from a data blob.
CxxUtils::ConcurrentStrMap< SG::auxid_t, CxxUtils::SimpleUpdater > id_map_t
Map from name -> auxid.
Exception — Non-atomic access to atomic aux variable.
Handle mappings between names and auxid_t.
std::string m_alloc_name
Name of the vector allocator.
Manage lookup of vectors of auxiliary data.
#define ATLAS_THREAD_SAFE
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.
Exception — Type mismatch for aux variable.
Exception — Bad name for auxiliary variable.
constexpr const char * auxAllocatorNamePrefix
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.