ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::TPyStore Class Reference

Python interface to xAOD::TStore. More...

#include <TPyStore.h>

Inheritance diagram for xAOD::TPyStore:
Collaboration diagram for xAOD::TPyStore:

Public Member Functions

bool pyContains (const std::string &key, const std::string &type) const
 Function checking if an object with a given key and type is available.
bool pyIsConst (const std::string &key, const std::string &type) const
 Function checking if an object with a given key and type is constant.
StatusCode pyRecord (void *obj, const std::string &key, const std::string &type)
 Record an object into the store in a typeless way.
void dump () const
 Print the contents of the store using a Python friendly function.
 TStore ()
 Inherit the constructor(s) of xAOD::TStore.
 TStore (const TStore &)=delete
 Inherit the constructor(s) of xAOD::TStore.
void setActive ()
 Set this as the active transient store in the application.
void print () const
 Print the current contents of the transient store.
Transient data accessor/modifier functions
template<typename T>
::Bool_t contains (const std::string &key) const
 Function checking if an object is available from the store.
template<typename T>
::Bool_t isConst (const std::string &key) const
 Function checking if an object with a given type is constant.
template<typename T>
StatusCode retrieve (const T *&obj, const std::string &key) const
 Retrieve either a constant or non-constant object from the store.
template<typename T>
StatusCode retrieve (T *&obj, const std::string &key) const
 Retrieve a non-constant object from the store.
template<typename T>
StatusCode record (T *obj, const std::string &key)
 Add an object to the store.
template<typename T>
StatusCode record (std::unique_ptr< T > obj, const std::string &key)
 Add an object to the store, explicitly taking ownership of it.
template<typename T>
StatusCode record (const T *obj, const std::string &key)
 Add a const object to the store.
template<typename T>
StatusCode record (std::unique_ptr< const T > obj, const std::string &key)
 Add a const object to the store, explicitly taking ownership of it.
template<typename T>
void keys (std::vector< std::string > &vkeys) const
 provide a list of keys associated with a type
const THolder * holder (const std::string &key) const
 return holder for key
StatusCode remove (const std::string &key)
 Remove an object from the store by name.
StatusCode remove (void *ptr)
 Remove an object from the store by pointer.
void clear ()
 Clear the store of all of its contents.

Protected Types

typedef std::unordered_map< std::string, THolder * > Objects_t
 Type of the internal container storing all the objects.
typedef SG::SGKeyMap< std::string > HashedKeys_t
 Type of the internal storage for the hashed keys of the object names.

Protected Member Functions

::Bool_t contains (const std::string &key, const std::type_info &ti) const
 Non-templated function implementing the containment check.
::Bool_t isConst (const std::string &key, const std::type_info &ti) const
 Non-templated function implementing the const-ness check.
StatusCode record (void *obj, const std::string &key, const std::string &classname, ::Bool_t isOwner, ::Bool_t isConst)
 Function recording an object that has a dictionary available.
StatusCode record (void *obj, const std::string &key, const std::type_info &ti, ::Bool_t isOwner, ::Bool_t isConst)
 Function recording an object that has no dictionary.
template<class T>
StatusCode record (ConstDataVector< T > *obj, const std::string &key, const std::type_info &ti, ::Bool_t isOwner, ::Bool_t isConst)
 Function doing the first step of recording a ConstDataVector object.
StatusCode record (THolder *hldr, const std::string &key)
 Function doing the second step of recording a ConstDataVector object.
void * getObject (const std::string &key, const std::type_info &ti) const
 Function retrieving a non-const object in a non-template way.
const void * getConstObject (const std::string &key, const std::type_info &ti) const
 Function retrieving a const object in a non-template way.
Functions mostly used by TEvent in the TVirtualEvent functions
::Bool_t contains (SG::sgkey_t hash) const
 Check if an object with a given hash is managed by the store.
::Bool_t contains (const void *ptr) const
 Check if an object with a given pointer is managed by the store.
const std::string & getName (SG::sgkey_t hash) const
 Get the name corresponding to a hashed key.
const std::string & getName (const void *ptr) const
 Get the name of a managed object.
void getNames (const std::string &targetClassName, std::vector< std::string > &vkeys) const
 Function determining the list keys associated with a type name.

Protected Attributes

Objects_t m_objects
 The object storage.
HashedKeys_t m_keys
 The key map.
std::unordered_map< const void *, const std::string * > m_names
 Key of each managed object, by object pointer (points into m_objects).

Private Member Functions

template<typename T>
StatusCode record_impl (T *obj, const std::string &key, ::Bool_t isOwner, ::Bool_t isConst)
 Internal implementation of the templated record method.

Detailed Description

Python interface to xAOD::TStore.

In order to make it possible to record objects that are created in Python, into an xAOD::TStore object (to be able to pass it to some tools that expect the object to be in the event for instance), this class extends the xAOD::TStore object with some non-template functions. Functions that are inconvenient to use from C++, but which allow for much more flexibility in PyROOT.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 27 of file TPyStore.h.

Member Typedef Documentation

◆ HashedKeys_t

typedef SG::SGKeyMap< std::string > xAOD::TStore::HashedKeys_t
protectedinherited

Type of the internal storage for the hashed keys of the object names.

Definition at line 167 of file TStore.h.

◆ Objects_t

typedef std::unordered_map< std::string, THolder* > xAOD::TStore::Objects_t
protectedinherited

Type of the internal container storing all the objects.

Definition at line 165 of file TStore.h.

Member Function Documentation

◆ clear()

void xAOD::TStore::clear ( )
inherited

Clear the store of all of its contents.

Definition at line 95 of file TStore.cxx.

95 {
96
97 // Delete all the managed objects:
98 Objects_t::iterator itr = m_objects.begin();
99 Objects_t::iterator end = m_objects.end();
100 for( ; itr != end; ++itr ) {
101 delete itr->second;
102 }
103
104 // And clear the maps:
105 m_objects.clear();
106 m_keys.clear();
107 m_names.clear();
108
109 return;
110 }
HashedKeys_t m_keys
The key map.
Definition TStore.h:172
std::unordered_map< const void *, const std::string * > m_names
Key of each managed object, by object pointer (points into m_objects).
Definition TStore.h:174
Objects_t m_objects
The object storage.
Definition TStore.h:170

◆ contains() [1/4]

template<typename T>
::Bool_t xAOD::TStore::contains ( const std::string & key) const
inherited

Function checking if an object is available from the store.

◆ contains() [2/4]

Bool_t xAOD::TStore::contains ( const std::string & key,
const std::type_info & ti ) const
protectedinherited

Non-templated function implementing the containment check.

Definition at line 143 of file TStore.cxx.

144 {
145
146 // Look up this object:
147 Objects_t::const_iterator itr = m_objects.find( key );
148 if( itr == m_objects.end() ) {
149 return kFALSE;
150 }
151
152 // Check if the object is of the right type:
153 return itr->second->getAsConst( ti, kTRUE );
154 }

◆ contains() [3/4]

Bool_t xAOD::TStore::contains ( const void * ptr) const
protectedinherited

Check if an object with a given pointer is managed by the store.

Parameters
ptrPointer to the object that may or may not be in the store
Returns
kTRUE if the object is managed by the store, or kFALSE if it isn't

Definition at line 325 of file TStore.cxx.

325 {
326
327 return m_names.contains( ptr );
328 }

◆ contains() [4/4]

Bool_t xAOD::TStore::contains ( SG::sgkey_t hash) const
protectedinherited

Check if an object with a given hash is managed by the store.

This is a reasonably fast function.

It checks whether an object with the specified hashed key is managed by the store.

Parameters
hashThe hashed key of the object that we are looking for
Returns
kTRUE if the object is managed by the store, or kFALSE if it is not

Definition at line 315 of file TStore.cxx.

315 {
316
317 // Do the check quickly:
318 return ( m_keys.find( hash ) != m_keys.end() );
319 }

◆ dump()

void xAOD::TPyStore::dump ( ) const

Print the contents of the store using a Python friendly function.

This is just a convenience function, to make it easier to print the contents of such objects in Python.

Since the base class's print() function has a special meaning in Python.

Definition at line 121 of file TPyStore.cxx.

121 {
122
123 print();
124 return;
125}
void print() const
Print the current contents of the transient store.
Definition TStore.cxx:115

◆ getConstObject()

const void * xAOD::TStore::getConstObject ( const std::string & key,
const std::type_info & ti ) const
protectedinherited

Function retrieving a const object in a non-template way.

Definition at line 202 of file TStore.cxx.

203 {
204
205 // Look up this object:
206 Objects_t::const_iterator itr = m_objects.find( key );
207 if( itr == m_objects.end() ) {
208 return 0;
209 }
210
211 // Try to retrieve it as the requested type:
212 return itr->second->getAsConst( ti );
213 }

◆ getName() [1/2]

const std::string & xAOD::TStore::getName ( const void * ptr) const
protectedinherited

Get the name of a managed object.

Parameters
ptrPointer to the object that we want to know the name of
Returns
The name with which this object was recorded into the store. Or an empty string of the object is not known to the store.

Definition at line 357 of file TStore.cxx.

357 {
358
359 auto itr = m_names.find( ptr );
360 if( itr != m_names.end() ) {
361 return *itr->second;
362 }
363
364 // We didn't find the object:
365 ::Warning( "xAOD::TStore::getName", "Object %p is not held by the store",
366 ptr );
367 static const std::string dummy( "" );
368 return dummy;
369 }

◆ getName() [2/2]

const std::string & xAOD::TStore::getName ( SG::sgkey_t hash) const
protectedinherited

Get the name corresponding to a hashed key.

This is a fairly fast function.

Used by ElementLinks that point to objects in this store.

Parameters
hashThe hashed key for which we want to find the string key
Returns
The name corresponding to this hashed key if the hashed key is known, or an empty string if it isn't.

Definition at line 337 of file TStore.cxx.

337 {
338
339 // Try to find the name associated with this key:
340 HashedKeys_t::const_iterator itr = m_keys.find( hash );
341 if( itr != m_keys.end() ) {
342 // We found it:
343 return itr->second;
344 }
345
346 // We didn't find it:
347 ::Warning( "xAOD::TStore::getName", "Key 0x%08x not known by the store",
348 hash );
349 static const std::string dummy( "" );
350 return dummy;
351 }

◆ getNames()

void xAOD::TStore::getNames ( const std::string & targetClassName,
std::vector< std::string > & vkeys ) const
protectedinherited

Function determining the list keys associated with a type name.

Definition at line 371 of file TStore.cxx.

372 {
373 std::set< std::string > keys;
374
375 for ( const auto& pair : m_objects ) {
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;
380 if (cl)
381 typeName = cl->GetName();
382 else if (ti)
384
385 if (!typeName.empty() && typeName == targetTypeName)
386 keys.insert( key );
387 }
388
389 vkeys.insert( vkeys.end(), keys.begin(), keys.end() );
390 }
void keys(std::vector< std::string > &vkeys) const
provide a list of keys associated with a type
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...
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]

◆ getObject()

void * xAOD::TStore::getObject ( const std::string & key,
const std::type_info & ti ) const
protectedinherited

Function retrieving a non-const object in a non-template way.

Definition at line 182 of file TStore.cxx.

183 {
184
185 // Look up this object:
186 Objects_t::const_iterator itr = m_objects.find( key );
187 if( itr == m_objects.end() ) {
188 return 0;
189 }
190
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" ),
194 key.c_str(), SG::normalizedTypeinfoName( ti ).c_str() );
195 return nullptr;
196 }
197
198 // Try to retrieve it as the requested type:
199 return itr->second->getAs( ti );
200 }
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.

◆ holder()

const THolder * xAOD::TStore::holder ( const std::string & key) const
inherited

return holder for key

Definition at line 50 of file TStore.cxx.

50 {
51 // Look up this object:
52 Objects_t::const_iterator itr = m_objects.find( key );
53 return (itr != m_objects.end() ? itr->second : nullptr);
54 }

◆ isConst() [1/2]

template<typename T>
::Bool_t xAOD::TStore::isConst ( const std::string & key) const
inherited

Function checking if an object with a given type is constant.

◆ isConst() [2/2]

Bool_t xAOD::TStore::isConst ( const std::string & key,
const std::type_info & ti ) const
protectedinherited

Non-templated function implementing the const-ness check.

Definition at line 156 of file TStore.cxx.

157 {
158
159 // Look up this object:
160 Objects_t::const_iterator itr = m_objects.find( key );
161 if( itr == m_objects.end() ) {
162 ::Warning( "xAOD::TStore::isConst",
163 "Object with key \"%s\" not available in store",
164 key.c_str() );
165 return kFALSE;
166 }
167
168 // Check if it can even be retrieved as a constant object of this type:
169 if( ! itr->second->getAsConst( ti, kTRUE ) ) {
170 const std::string typeName = SG::normalizedTypeinfoName( ti );
171 ::Warning( "xAOD::TStore::isConst",
172 "Object with key \"%s\" can't be retrieved as type: %s",
173 key.c_str(), typeName.c_str() );
174 return kFALSE;
175 }
176
177 // Now the question is just whether it can be retrieved as a non-const
178 // object as well:
179 return ( ! itr->second->getAs( ti, kTRUE ) );
180 }

◆ keys()

template<typename T>
void xAOD::TStore::keys ( std::vector< std::string > & vkeys) const
inherited

provide a list of keys associated with a type

◆ print()

void xAOD::TStore::print ( ) const
inherited

Print the current contents of the transient store.

This is really just meant for debugging an analysis code, to see what's going on in it.

Behaves a bit similar to StoreGateSvc::dump().

Definition at line 115 of file TStore.cxx.

115 {
116
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() :
127 ( ti ? SG::normalizedTypeinfoName( *ti ).c_str() :
128 "Unknown" ) ) );
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" ) );
137 }
138 ::Info( "xAOD::TStore::print", "-----------------------------------" );
139
140 return;
141 }

◆ pyContains()

bool xAOD::TPyStore::pyContains ( const std::string & key,
const std::string & type ) const

Function checking if an object with a given key and type is available.

This function can be used in the same manner as TStore::contains<...>(...), but instead of providing a type, one gives it a type name.

Note that only types that have a proper ROOT dictionary can be used. Unlike C++, which allows one to insert any type of object into TStore.

Parameters
keyThe key of the object that we're looking for
typeThe type name of the object we're trying to access
Returns
true if the object is acessible, false otherwise

Definition at line 28 of file TPyStore.cxx.

29 {
30
31 // Try to access the dictionary of this type.
32 ::TClass* cl = ::TClass::GetClass(type.c_str());
33 if (cl == nullptr) {
34 ::Warning("xAOD::TPyStore::pyContains", "Type name \"%s\" not known",
35 type.c_str());
36 return false;
37 }
38
39 // Check if the dictionary can return a type_info.
40 const std::type_info* ti = cl->GetTypeInfo();
41 if (!ti) {
42 ::Warning("xAOD::TPyStore::pyContains",
43 "Type \"%s\" doesn't have a proper dictionary", type.c_str());
44 return false;
45 }
46
47 // Use the base class to answer the question.
48 return TStore::contains(key, *ti);
49}
::Bool_t contains(const std::string &key) const
Function checking if an object is available from the store.

◆ pyIsConst()

bool xAOD::TPyStore::pyIsConst ( const std::string & key,
const std::string & type ) const

Function checking if an object with a given key and type is constant.

This function can be used in the same manner as TStore::isConst<...>(...), but instead of providing a type, one gives it a type name.

Note that only types that have a proper ROOT dictionary can be used. Unlike C++, which allows one to insert any type of object into TStore.

Parameters
keyThe key of the object that we're looking for
typeThe type name of the object we're trying to access
Returns
true if the object is acessible, false otherwise

Definition at line 63 of file TPyStore.cxx.

64 {
65
66 // Try to access the dictionary of this type.
67 ::TClass* cl = ::TClass::GetClass(type.c_str());
68 if (cl == nullptr) {
69 ::Warning("xAOD::TPyStore::pyIsConst", "Type name \"%s\" not known",
70 type.c_str());
71 return false;
72 }
73
74 // Check if the dictionary can return a type_info.
75 const std::type_info* ti = cl->GetTypeInfo();
76 if (ti == nullptr) {
77 ::Warning("xAOD::TPyStore::pyIsConst",
78 "Type \"%s\" doesn't have a proper dictionary", type.c_str());
79 return false;
80 }
81
82 // Use the base class to answer the question.
83 return TStore::isConst(key, *ti);
84}
::Bool_t isConst(const std::string &key) const
Function checking if an object with a given type is constant.

◆ pyRecord()

StatusCode xAOD::TPyStore::pyRecord ( void * obj,
const std::string & key,
const std::string & type )

Record an object into the store in a typeless way.

This function can be used in the same manner as TStore::record<...>(...), but instead of providing a type, one gives it a type name and a typeless pointer.

Note that only types that have a proper ROOT dictionary can be used. Unlike C++, which allows one to insert any type of object into TStore.

Also note that this function doesn't take ownership of the recorded object. In Python all the objects created by the interpreter are managed by the interpreter. So this code is not supposed to delete them, otherwise all hell breaks loose.

Parameters
objPointer to the object to be put into the store
keyKey of the object in the store
typeThe type name of the object we are inserting
Returns
The usual StatusCode types

Definition at line 103 of file TPyStore.cxx.

104 {
105
106 // Simply forward the call to the appropriate function from the base
107 // class.
108 static constexpr bool IS_OWNER = false;
109 static constexpr bool IS_CONST = false;
110 RETURN_CHECK("xAOD::TPyStore::pyRecord",
111 TStore::record(obj, key, type, IS_OWNER, IS_CONST));
112
113 // Return gracefully:
114 return StatusCode::SUCCESS;
115}
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition ReturnCheck.h:26
StatusCode record(T *obj, const std::string &key)
Add an object to the store.

◆ record() [1/8]

template<typename T>
StatusCode xAOD::TStore::record ( const T * obj,
const std::string & key )
inherited

Add a const object to the store.

◆ record() [2/8]

template<class T>
StatusCode xAOD::TStore::record ( ConstDataVector< T > * obj,
const std::string & key,
const std::type_info & ti,
::Bool_t isOwner,
::Bool_t isConst )
protectedinherited

Function doing the first step of recording a ConstDataVector object.

◆ record() [3/8]

template<typename T>
StatusCode xAOD::TStore::record ( std::unique_ptr< const T > obj,
const std::string & key )
inherited

Add a const object to the store, explicitly taking ownership of it.

◆ record() [4/8]

template<typename T>
StatusCode xAOD::TStore::record ( std::unique_ptr< T > obj,
const std::string & key )
inherited

Add an object to the store, explicitly taking ownership of it.

◆ record() [5/8]

template<typename T>
StatusCode xAOD::TStore::record ( T * obj,
const std::string & key )
inherited

Add an object to the store.

◆ record() [6/8]

StatusCode xAOD::TStore::record ( THolder * hldr,
const std::string & key )
protectedinherited

Function doing the second step of recording a ConstDataVector object.

Definition at line 286 of file TStore.cxx.

286 {
287
288 // Make sure that the key is not yet taken:
289 if( m_objects.find( key ) != m_objects.end() ) {
290 ::Error( "xAOD::TStore::record",
291 XAOD_MESSAGE( "Trying to overwrite object with key \"%s\"" ),
292 key.c_str() );
293 // We delete the holder object at this point. It's quite ugly in terms
294 // of code readibility, but it results in fewer characters in the
295 // template code...
296 delete hldr;
297 return StatusCode::FAILURE;
298 }
299
300 // Register the new object:
301 const auto itr = m_objects.emplace( key, hldr ).first;
302 m_keys[ Utils::hash( key ) ] = key;
303 // shortcut: one key per pointer, an object recorded twice (non-owning, from TPyStore) is lost by either remove; index all keys if that is ever used
304 m_names.emplace( hldr->get(), &itr->first );
305 return StatusCode::SUCCESS;
306 }
SG::sgkey_t hash(const std::string &name)
This function provides a hashed version of the key (branch) names used in the xAOD file,...

◆ record() [7/8]

StatusCode xAOD::TStore::record ( void * obj,
const std::string & key,
const std::string & classname,
::Bool_t isOwner,
::Bool_t isConst )
protectedinherited

Function recording an object that has a dictionary available.

This internal function does the heavy lifting of recording objects into the store that have a proper ROOT dictionary.

Parameters
objTypeless pointer to the object being recorded
keyKey to record the object with
classnameThe type name of the object being recorded
isOwnerIf kTRUE, the store takes ownership of the object, otherwise it doesn't
Returns
The usual StatusCode types

Definition at line 225 of file TStore.cxx.

227 {
228
229 // Cache
230 using clCache_t = CxxUtils::ConcurrentStrMap<::TClass*, CxxUtils::SimpleUpdater>;
231 static clCache_t clMap ATLAS_THREAD_SAFE {clCache_t::Updater_t()};
232
233 // First check if we have this dictionary cached already:
234 ::TClass* cl = 0;
235 auto clItr = clMap.find( classname );
236 if( clItr != clMap.end() ) {
237 // If the cached value doesn't work, then bail now:
238 if( ( ! clItr->second ) || ( ! clItr->second->IsLoaded() ) ) {
239 return StatusCode::RECOVERABLE;
240 }
241 // Otherwise we're done:
242 cl = clItr->second;
243 }
244
245 // If it's not cached, ask ROOT for it:
246 if( ! cl ) {
247 cl = ::TClass::GetClass( classname.c_str(), kTRUE, kTRUE );
248 clMap.emplace( classname, cl );
249 }
250 if( ( ! cl ) || ( ! cl->IsLoaded() ) ) {
251 return StatusCode::RECOVERABLE;
252 }
253
254 // Make sure that the key is not yet taken:
255 if( m_objects.find( key ) != m_objects.end() ) {
256 ::Error( "xAOD::TStore::record",
257 XAOD_MESSAGE( "Trying to overwrite object with key \"%s\"" ),
258 key.c_str() );
259 return StatusCode::FAILURE;
260 }
261
262 // Register the new object:
263 if( isConst )
264 return record( new THolder( const_cast<const void*>(obj), cl, isOwner ), key );
265 return record( new THolder( obj, cl, isOwner ), key );
266 }
#define ATLAS_THREAD_SAFE

◆ record() [8/8]

StatusCode xAOD::TStore::record ( void * obj,
const std::string & key,
const std::type_info & ti,
::Bool_t isOwner,
::Bool_t isConst )
protectedinherited

Function recording an object that has no dictionary.

Definition at line 268 of file TStore.cxx.

270 {
271
272 // Make sure that the key is not yet taken:
273 if( m_objects.find( key ) != m_objects.end() ) {
274 ::Error( "xAOD::TStore::record",
275 XAOD_MESSAGE( "Trying to overwrite object with key \"%s\"" ),
276 key.c_str() );
277 return StatusCode::FAILURE;
278 }
279
280 // Register the new object:
281 if( isConst )
282 return record( new THolder( const_cast<const void*>(obj), ti, isOwner ), key );
283 return record( new THolder( obj, ti, isOwner ), key );
284 }

◆ record_impl()

template<typename T>
StatusCode xAOD::TStore::record_impl ( T * obj,
const std::string & key,
::Bool_t isOwner,
::Bool_t isConst )
privateinherited

Internal implementation of the templated record method.

◆ remove() [1/2]

StatusCode xAOD::TStore::remove ( const std::string & key)
inherited

Remove an object from the store by name.

Definition at line 57 of file TStore.cxx.

57 {
58
59 // Look up this object:
60 Objects_t::iterator itr = m_objects.find( key );
61 if( itr == m_objects.end() ) {
62 ::Warning( "xAOD::TStore::remove",
63 "Couldn't find object with key \"%s\"",
64 key.c_str() );
65 return StatusCode::RECOVERABLE;
66 }
67
68 // Forget its pointer, and delete the holder object:
69 m_names.erase( itr->second->get() );
70 delete itr->second;
71
72 // Now remove this element from the maps:
73 m_objects.erase( itr );
74 m_keys.erase( Utils::hash( key ) );
75
76 // We were successful:
77 return StatusCode::SUCCESS;
78 }

◆ remove() [2/2]

StatusCode xAOD::TStore::remove ( void * ptr)
inherited

Remove an object from the store by pointer.

Definition at line 80 of file TStore.cxx.

80 {
81
82 // Look for this object:
83 auto itr = m_names.find( ptr );
84 if( itr == m_names.end() ) {
85 ::Warning( "xAOD::TStore::remove",
86 "Couldn't find object with pointer %p",
87 ptr );
88 return StatusCode::RECOVERABLE;
89 }
90
91 // Copy the key, removing the object destroys the string it points to:
92 return remove( std::string( *itr->second ) );
93 }
StatusCode remove(const std::string &key)
Remove an object from the store by name.
Definition TStore.cxx:57

◆ retrieve() [1/2]

template<typename T>
StatusCode xAOD::TStore::retrieve ( const T *& obj,
const std::string & key ) const
inherited

Retrieve either a constant or non-constant object from the store.

◆ retrieve() [2/2]

template<typename T>
StatusCode xAOD::TStore::retrieve ( T *& obj,
const std::string & key ) const
inherited

Retrieve a non-constant object from the store.

◆ setActive()

void xAOD::TStore::setActive ( )
inherited

Set this as the active transient store in the application.

Definition at line 43 of file TStore.cxx.

43 {
44
46 return;
47 }
static void setStore(TStore *ptr)
Set the active store pointer.

◆ TStore() [1/2]

Inherit the constructor(s) of xAOD::TStore.

Definition at line 54 of file TStore.cxx.

25 : m_objects(), m_keys() {
26
27 setActive();
28 }
void setActive()
Set this as the active transient store in the application.
Definition TStore.cxx:43

◆ TStore() [2/2]

xAOD::TStore::TStore ( const TStore & )
delete

Inherit the constructor(s) of xAOD::TStore.

Member Data Documentation

◆ m_keys

HashedKeys_t xAOD::TStore::m_keys
protectedinherited

The key map.

Definition at line 172 of file TStore.h.

◆ m_names

std::unordered_map< const void*, const std::string* > xAOD::TStore::m_names
protectedinherited

Key of each managed object, by object pointer (points into m_objects).

Definition at line 174 of file TStore.h.

◆ m_objects

Objects_t xAOD::TStore::m_objects
protectedinherited

The object storage.

Definition at line 170 of file TStore.h.


The documentation for this class was generated from the following files: