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;
76 return StatusCode::SUCCESS;
82 Objects_t::iterator itr =
m_objects.begin();
83 Objects_t::iterator end =
m_objects.end();
84 for( ; itr != end; ++itr ) {
87 if( itr->second->get() != ptr ) {
95 return StatusCode::SUCCESS;
99 ::Warning(
"xAOD::TStore::remove",
100 "Couldn't find object with pointer %p",
102 return StatusCode::RECOVERABLE;
108 Objects_t::iterator itr =
m_objects.begin();
109 Objects_t::iterator end =
m_objects.end();
110 for( ; itr != end; ++itr ) {
126 ::Info(
"xAOD::TStore::print",
"Contents of transient store:" );
127 Objects_t::const_iterator itr =
m_objects.begin();
128 Objects_t::const_iterator end =
m_objects.end();
129 for( ; itr != end; ++itr ) {
130 ::Info(
"xAOD::TStore::print",
"-----------------------------------" );
131 ::Info(
"xAOD::TStore::print",
" Name: %s", itr->first.c_str() );
132 const ::TClass* cl = itr->second->getClass();
133 const std::type_info* ti = itr->second->getTypeInfo();
134 ::Info(
"xAOD::TStore::print",
" Type: %s",
135 ( cl ? cl->GetName() :
138 ::Info(
"xAOD::TStore::print",
" Pointer: %p",
139 itr->second->get() );
140 ::Info(
"xAOD::TStore::print",
" IsOwner: %s",
141 ( itr->second->isOwner() ?
"Yes" :
"No" ) );
142 ::Info(
"xAOD::TStore::print",
" IsConst: %s",
143 ( itr->second->isConst() ?
"Yes" :
"No" ) );
144 ::Info(
"xAOD::TStore::print",
" HasDictionary: %s",
145 ( cl ?
"Yes" :
"No" ) );
147 ::Info(
"xAOD::TStore::print",
"-----------------------------------" );
153 const std::type_info& ti )
const {
156 Objects_t::const_iterator itr =
m_objects.find( key );
162 return itr->second->getAsConst( ti, kTRUE );
166 const std::type_info& ti )
const {
169 Objects_t::const_iterator itr =
m_objects.find( key );
171 ::Warning(
"xAOD::TStore::isConst",
172 "Object with key \"%s\" not available in store",
178 if( ! itr->second->getAsConst( ti, kTRUE ) ) {
180 ::Warning(
"xAOD::TStore::isConst",
181 "Object with key \"%s\" can't be retrieved as type: %s",
182 key.c_str(), typeName.c_str() );
188 return ( ! itr->second->getAs( ti, kTRUE ) );
192 const std::type_info& ti )
const {
195 Objects_t::const_iterator itr =
m_objects.find( key );
200 if( itr->second->isConst() ) {
201 ::Error(
"xAOD::TStore::getObject",
202 XAOD_MESSAGE(
"Cannot retrieve object with key \"%s\" of type %s as non-const" ),
208 return itr->second->getAs( ti );
212 const std::type_info& ti )
const {
215 Objects_t::const_iterator itr =
m_objects.find( key );
221 return itr->second->getAsConst( ti );
235 const std::string& classname,
236 ::Bool_t isOwner, ::Bool_t
isConst ) {
244 auto clItr = clMap.find( classname );
245 if( clItr != clMap.end() ) {
247 if( ( ! clItr->second ) || ( ! clItr->second->IsLoaded() ) ) {
248 return StatusCode::RECOVERABLE;
256 cl = ::TClass::GetClass( classname.c_str(), kTRUE, kTRUE );
257 clMap.emplace( classname, cl );
259 if( ( ! cl ) || ( ! cl->IsLoaded() ) ) {
260 return StatusCode::RECOVERABLE;
265 ::Error(
"xAOD::TStore::record",
266 XAOD_MESSAGE(
"Trying to overwrite object with key \"%s\"" ),
268 return StatusCode::FAILURE;
273 m_objects[ key ] =
new THolder(
const_cast<const void*
>(obj), cl, isOwner );
278 return StatusCode::SUCCESS;
282 const std::type_info& ti,
283 ::Bool_t isOwner, ::Bool_t
isConst ) {
287 ::Error(
"xAOD::TStore::record",
288 XAOD_MESSAGE(
"Trying to overwrite object with key \"%s\"" ),
290 return StatusCode::FAILURE;
295 m_objects[ key ] =
new THolder(
const_cast<const void*
>(obj), ti, isOwner );
300 return StatusCode::SUCCESS;
307 ::Error(
"xAOD::TStore::record",
308 XAOD_MESSAGE(
"Trying to overwrite object with key \"%s\"" ),
314 return StatusCode::FAILURE;
320 return StatusCode::SUCCESS;
346 Objects_t::const_iterator itr =
m_objects.begin();
347 Objects_t::const_iterator end =
m_objects.end();
348 for( ; itr != end; ++itr ) {
350 if( itr->second->get() == ptr ) {
369 HashedKeys_t::const_iterator itr =
m_keys.find( hash );
370 if( itr !=
m_keys.end() ) {
376 ::Warning(
"xAOD::TStore::getName",
"Key 0x%08x not known by the store",
378 static const std::string dummy(
"" );
393 Objects_t::const_iterator itr =
m_objects.begin();
394 Objects_t::const_iterator end =
m_objects.end();
395 for( ; itr != end; ++itr ) {
397 if( itr->second->get() == ptr ) {
403 ::Warning(
"xAOD::TStore::getName",
"Object %p is not held by the store",
405 static const std::string dummy(
"" );
410 std::vector< std::string >& vkeys )
const {
411 std::set< std::string >
keys;
414 const std::string& key =
pair.first;
415 const ::TClass* cl =
pair.second->getClass();
416 const std::type_info* ti =
pair.second->getTypeInfo();
417 std::string typeName;
419 typeName = cl->GetName();
423 if (!typeName.empty() && typeName == targetTypeName)
427 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.
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.
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...