52 Objects_t::const_iterator itr =
m_objects.find( key );
53 return (itr !=
m_objects.end() ? itr->second :
nullptr);
60 Objects_t::iterator itr =
m_objects.find( key );
62 ::Warning(
"xAOD::TStore::remove",
63 "Couldn't find object with key \"%s\"",
65 return StatusCode::RECOVERABLE;
69 m_names.erase( itr->second->get() );
77 return StatusCode::SUCCESS;
85 ::Warning(
"xAOD::TStore::remove",
86 "Couldn't find object with pointer %p",
88 return StatusCode::RECOVERABLE;
92 return remove( std::string( *itr->second ) );
98 Objects_t::iterator itr =
m_objects.begin();
99 Objects_t::iterator end =
m_objects.end();
100 for( ; itr != end; ++itr ) {
117 ::Info(
"xAOD::TStore::print",
"Contents of transient store:" );
118 Objects_t::const_iterator itr =
m_objects.begin();
119 Objects_t::const_iterator end =
m_objects.end();
120 for( ; itr != end; ++itr ) {
121 ::Info(
"xAOD::TStore::print",
"-----------------------------------" );
122 ::Info(
"xAOD::TStore::print",
" Name: %s", itr->first.c_str() );
123 const ::TClass* cl = itr->second->getClass();
124 const std::type_info* ti = itr->second->getTypeInfo();
125 ::Info(
"xAOD::TStore::print",
" Type: %s",
126 ( cl ? cl->GetName() :
129 ::Info(
"xAOD::TStore::print",
" Pointer: %p",
130 itr->second->get() );
131 ::Info(
"xAOD::TStore::print",
" IsOwner: %s",
132 ( itr->second->isOwner() ?
"Yes" :
"No" ) );
133 ::Info(
"xAOD::TStore::print",
" IsConst: %s",
134 ( itr->second->isConst() ?
"Yes" :
"No" ) );
135 ::Info(
"xAOD::TStore::print",
" HasDictionary: %s",
136 ( cl ?
"Yes" :
"No" ) );
138 ::Info(
"xAOD::TStore::print",
"-----------------------------------" );
144 const std::type_info& ti )
const {
147 Objects_t::const_iterator itr =
m_objects.find( key );
153 return itr->second->getAsConst( ti, kTRUE );
157 const std::type_info& ti )
const {
160 Objects_t::const_iterator itr =
m_objects.find( key );
162 ::Warning(
"xAOD::TStore::isConst",
163 "Object with key \"%s\" not available in store",
169 if( ! itr->second->getAsConst( ti, kTRUE ) ) {
171 ::Warning(
"xAOD::TStore::isConst",
172 "Object with key \"%s\" can't be retrieved as type: %s",
173 key.c_str(), typeName.c_str() );
179 return ( ! itr->second->getAs( ti, kTRUE ) );
183 const std::type_info& ti )
const {
186 Objects_t::const_iterator itr =
m_objects.find( key );
191 if( itr->second->isConst() ) {
192 ::Error(
"xAOD::TStore::getObject",
193 XAOD_MESSAGE(
"Cannot retrieve object with key \"%s\" of type %s as non-const" ),
199 return itr->second->getAs( ti );
203 const std::type_info& ti )
const {
206 Objects_t::const_iterator itr =
m_objects.find( key );
212 return itr->second->getAsConst( ti );
226 const std::string& classname,
227 ::Bool_t isOwner, ::Bool_t
isConst ) {
235 auto clItr = clMap.find( classname );
236 if( clItr != clMap.end() ) {
238 if( ( ! clItr->second ) || ( ! clItr->second->IsLoaded() ) ) {
239 return StatusCode::RECOVERABLE;
247 cl = ::TClass::GetClass( classname.c_str(), kTRUE, kTRUE );
248 clMap.emplace( classname, cl );
250 if( ( ! cl ) || ( ! cl->IsLoaded() ) ) {
251 return StatusCode::RECOVERABLE;
256 ::Error(
"xAOD::TStore::record",
257 XAOD_MESSAGE(
"Trying to overwrite object with key \"%s\"" ),
259 return StatusCode::FAILURE;
264 return record(
new THolder(
const_cast<const void*
>(obj), cl, isOwner ), key );
269 const std::type_info& ti,
270 ::Bool_t isOwner, ::Bool_t
isConst ) {
274 ::Error(
"xAOD::TStore::record",
275 XAOD_MESSAGE(
"Trying to overwrite object with key \"%s\"" ),
277 return StatusCode::FAILURE;
282 return record(
new THolder(
const_cast<const void*
>(obj), ti, isOwner ), key );
290 ::Error(
"xAOD::TStore::record",
291 XAOD_MESSAGE(
"Trying to overwrite object with key \"%s\"" ),
297 return StatusCode::FAILURE;
301 const auto itr =
m_objects.emplace( key, hldr ).first;
305 return StatusCode::SUCCESS;
327 return m_names.contains( ptr );
340 HashedKeys_t::const_iterator itr =
m_keys.find( hash );
341 if( itr !=
m_keys.end() ) {
347 ::Warning(
"xAOD::TStore::getName",
"Key 0x%08x not known by the store",
349 static const std::string dummy(
"" );
359 auto itr =
m_names.find( ptr );
365 ::Warning(
"xAOD::TStore::getName",
"Object %p is not held by the store",
367 static const std::string dummy(
"" );
372 std::vector< std::string >& vkeys )
const {
373 std::set< std::string >
keys;
376 const std::string& key =
pair.first;
377 const ::TClass* cl =
pair.second->getClass();
378 const std::type_info* ti =
pair.second->getTypeInfo();
379 std::string typeName;
381 typeName = cl->GetName();
385 if (!typeName.empty() && typeName == targetTypeName)
389 vkeys.insert( vkeys.end(),
keys.begin(),
keys.end() );
Hash map from strings allowing concurrent, lockless reads.
Simple (non-deleting) Updater implementation.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Hash map from strings allowing concurrent, lockless reads.
static TStore * store()
Access the currently active TStore object.
static void setStore(TStore *ptr)
Set the active store pointer.
This class takes care of holding EDM objects in memory.
const void * get() const
Return a typeless const pointer to the held object.
void keys(std::vector< std::string > &vkeys) const
provide a list of keys associated with a type
StatusCode remove(const std::string &key)
Remove an object from the store by name.
void setActive()
Set this as the active transient store in the application.
void print() const
Print the current contents of the transient store.
const void * getConstObject(const std::string &key, const std::type_info &ti) const
Function retrieving a const object in a non-template way.
void clear()
Clear the store of all of its contents.
virtual ~TStore()
Destructor.
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
void getNames(const std::string &targetClassName, std::vector< std::string > &vkeys) const
Function determining the list keys associated with a type name.
const std::string & getName(SG::sgkey_t hash) const
Get the name corresponding to a hashed key.
HashedKeys_t m_keys
The key map.
void * getObject(const std::string &key, const std::type_info &ti) const
Function retrieving a non-const object in a non-template way.
std::unordered_map< const void *, const std::string * > m_names
Key of each managed object, by object pointer (points into m_objects).
const THolder * holder(const std::string &key) const
return holder for key
::Bool_t contains(const std::string &key) const
Function checking if an object is available from the store.
Objects_t m_objects
The object storage.
TStore()
Default constructor.
::Bool_t isConst(const std::string &key) const
Function checking if an object with a given type is constant.
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...
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
SG::sgkey_t hash(const std::string &name)
This function provides a hashed version of the key (branch) names used in the xAOD file,...
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...