ATLAS Offline Software
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
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_t contains (const std::string &key, const std::string &type) const
 Function checking if an object with a given key and type is available. More...
 
::Bool_t isConst (const std::string &key, const std::string &type) const
 Function checking if an object with a given key and type is constant. More...
 
StatusCode record (void *obj, const std::string &key, const std::string &type)
 Record an object into the store in a typeless way. More...
 
void dump () const
 Print the contents of the store using a Python friendly function. More...
 
 TStore ()
 Inherit the constructor(s) of xAOD::TStore. More...
 
 TStore (const TStore &)=delete
 Inherit the constructor(s) of xAOD::TStore. More...
 
void setActive ()
 Set this as the active transient store in the application. More...
 
void print () const
 Print the current contents of the transient store. More...
 
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. More...
 
template<typename T >
::Bool_t isConst (const std::string &key) const
 Function checking if an object with a given type is constant. More...
 
template<typename T >
StatusCode retrieve (const T *&obj, const std::string &key) const
 Retrieve either a constant or non-constant object from the store. More...
 
template<typename T >
StatusCode retrieve (T *&obj, const std::string &key) const
 Retrieve a non-constant object from the store. More...
 
template<typename T >
StatusCode record (T *obj, const std::string &key)
 Add an object to the store. More...
 
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. More...
 
template<typename T >
StatusCode record (const T *obj, const std::string &key)
 Add a const object to the store. More...
 
template<typename T >
void keys (std::vector< std::string > &vkeys) const
 provide a list of keys associated with a type More...
 
const THolderholder (const std::string &key) const
 return holder for key More...
 
StatusCode remove (const std::string &key)
 Remove an object from the store by name. More...
 
StatusCode remove (void *ptr)
 Remove an object from the store by pointer. More...
 
void clear ()
 Clear the store of all of its contents. More...
 

Protected Types

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

Protected Member Functions

::Bool_t contains (const std::string &key, const std::type_info &ti) const
 Non-templated function implementing the containment check. More...
 
::Bool_t isConst (const std::string &key, const std::type_info &ti) const
 Non-templated function implementing the const-ness check. More...
 
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. More...
 
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. More...
 
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. More...
 
StatusCode record (THolder *hldr, const std::string &key)
 Function doing the second step of recording a ConstDataVector object. More...
 
void * getObject (const std::string &key, const std::type_info &ti) const
 Function retrieving a non-const object in a non-template way. More...
 
const void * getConstObject (const std::string &key, const std::type_info &ti) const
 Function retrieving a const object in a non-template way. More...
 
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. More...
 
::Bool_t contains (const void *ptr) const
 Check if an object with a given pointer is managed by the store. More...
 
const std::string & getName (SG::sgkey_t hash) const
 Get the name corresponding to a hashed key. More...
 
const std::string & getName (const void *ptr) const
 Get the name of a managed object. More...
 
void getNames (const std::string &targetClassName, std::vector< std::string > &vkeys) const
 Function determining the list keys associated with a type name. More...
 
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. More...
 
::Bool_t contains (const void *ptr) const
 Check if an object with a given pointer is managed by the store. More...
 
const std::string & getName (SG::sgkey_t hash) const
 Get the name corresponding to a hashed key. More...
 
const std::string & getName (const void *ptr) const
 Get the name of a managed object. More...
 
void getNames (const std::string &targetClassName, std::vector< std::string > &vkeys) const
 Function determining the list keys associated with a type name. More...
 

Protected Attributes

Objects_t m_objects
 The object storage. More...
 
HashedKeys_t m_keys
 The key map. More...
 

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. More...
 

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 30 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 164 of file TStore.h.

◆ Objects_t

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

Type of the internal container storing all the objects.

Definition at line 162 of file TStore.h.

Member Function Documentation

◆ clear()

void xAOD::TStore::clear ( )
inherited

Clear the store of all of its contents.

Definition at line 105 of file TStore.cxx.

105  {
106 
107  // Delete all the managed objects:
108  Objects_t::iterator itr = m_objects.begin();
110  for( ; itr != end; ++itr ) {
111  delete itr->second;
112  }
113 
114  // And clear the maps:
115  m_objects.clear();
116  m_keys.clear();
117 
118  return;
119  }

◆ contains() [1/5]

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/5]

Bool_t xAOD::TPyStore::contains ( 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
kTRUE if the object is acessible, kFALSE otherwise

Definition at line 27 of file TPyStore.cxx.

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

◆ contains() [3/5]

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 152 of file TStore.cxx.

153  {
154 
155  // Look up this object:
156  Objects_t::const_iterator itr = m_objects.find( key );
157  if( itr == m_objects.end() ) {
158  return kFALSE;
159  }
160 
161  // Check if the object is of the right type:
162  return itr->second->getAsConst( ti, kTRUE );
163  }

◆ contains() [4/5]

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

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

This is a quite slow function.

It needs to check each managed object to possibly find which one of them has this pointer.

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 343 of file TStore.cxx.

343  {
344 
345  // Loop over all the managed objects:
346  Objects_t::const_iterator itr = m_objects.begin();
347  Objects_t::const_iterator end = m_objects.end();
348  for( ; itr != end; ++itr ) {
349  // Check if this is the right object:
350  if( itr->second->get() == ptr ) {
351  return kTRUE;
352  }
353  }
354 
355  // We didn't find it:
356  return kFALSE;
357  }

◆ contains() [5/5]

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 330 of file TStore.cxx.

330  {
331 
332  // Do the check quickly:
333  return ( m_keys.find( hash ) != m_keys.end() );
334  }

◆ 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  }

◆ 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 211 of file TStore.cxx.

212  {
213 
214  // Look up this object:
215  Objects_t::const_iterator itr = m_objects.find( key );
216  if( itr == m_objects.end() ) {
217  return 0;
218  }
219 
220  // Try to retrieve it as the requested type:
221  return itr->second->getAsConst( ti );
222  }

◆ getName() [1/2]

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

Get the name of a managed object.

This is just as slow as the previous contains function.

It needs to look at all the managed objects one by one to find under what name it is managed.

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 390 of file TStore.cxx.

390  {
391 
392  // Loop over all the managed objects:
393  Objects_t::const_iterator itr = m_objects.begin();
394  Objects_t::const_iterator end = m_objects.end();
395  for( ; itr != end; ++itr ) {
396  // Check if this is the right object:
397  if( itr->second->get() == ptr ) {
398  return itr->first;
399  }
400  }
401 
402  // We didn't find the object:
403  ::Warning( "xAOD::TStore::getName", "Object %p is not held by the store",
404  ptr );
405  static const std::string dummy( "" );
406  return dummy;
407  }

◆ 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 366 of file TStore.cxx.

366  {
367 
368  // Try to find the name associated with this key:
369  HashedKeys_t::const_iterator itr = m_keys.find( hash );
370  if( itr != m_keys.end() ) {
371  // We found it:
372  return itr->second;
373  }
374 
375  // We didn't find it:
376  ::Warning( "xAOD::TStore::getName", "Key 0x%08x not known by the store",
377  hash );
378  static const std::string dummy( "" );
379  return dummy;
380  }

◆ 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 409 of file TStore.cxx.

410  {
411  std::set< std::string > keys;
412 
413  for ( const auto& pair : m_objects ) {
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;
418  if (cl)
419  typeName = cl->GetName();
420  else if (ti)
422 
423  if (!typeName.empty() && typeName == targetTypeName)
424  keys.insert( key );
425  }
426 
427  vkeys.insert( vkeys.end(), keys.begin(), keys.end() );
428  }

◆ 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 191 of file TStore.cxx.

192  {
193 
194  // Look up this object:
195  Objects_t::const_iterator itr = m_objects.find( key );
196  if( itr == m_objects.end() ) {
197  return 0;
198  }
199 
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" ),
203  key.c_str(), SG::normalizedTypeinfoName( ti ).c_str() );
204  return nullptr;
205  }
206 
207  // Try to retrieve it as the requested type:
208  return itr->second->getAs( ti );
209  }

◆ 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/3]

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/3]

Bool_t xAOD::TPyStore::isConst ( 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
kTRUE if the object is acessible, kFALSE 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 ) {
69  ::Warning( "xAOD::TPyStore::isConst",
70  "Type name \"%s\" not known", type.c_str() );
71  return kFALSE;
72  }
73 
74  // Check if the dictionary can return a type_info:
75  const std::type_info* ti = cl->GetTypeInfo();
76  if( ! ti ) {
77  ::Warning( "xAOD::TPyStore::isConst",
78  "Type \"%s\" doesn't have a proper dictionary",
79  type.c_str() );
80  return kFALSE;
81  }
82 
83  // Use the base class to answer the question:
84  return TStore::isConst( key, *ti );
85  }

◆ isConst() [3/3]

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 165 of file TStore.cxx.

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

◆ 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 124 of file TStore.cxx.

124  {
125 
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() :
136  ( ti ? SG::normalizedTypeinfoName( *ti ).c_str() :
137  "Unknown" ) ) );
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" ) );
146  }
147  ::Info( "xAOD::TStore::print", "-----------------------------------" );
148 
149  return;
150  }

◆ 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< T >  obj,
const std::string &  key 
)
inherited

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

◆ record() [4/8]

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

Add an object to the store.

◆ record() [5/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 303 of file TStore.cxx.

303  {
304 
305  // Make sure that the key is not yet taken:
306  if( m_objects.find( key ) != m_objects.end() ) {
307  ::Error( "xAOD::TStore::record",
308  XAOD_MESSAGE( "Trying to overwrite object with key \"%s\"" ),
309  key.c_str() );
310  // We delete the holder object at this point. It's quite ugly in terms
311  // of code readibility, but it results in fewer characters in the
312  // template code...
313  delete hldr;
314  return StatusCode::FAILURE;
315  }
316 
317  // Register the new object:
318  m_objects[ key ] = hldr;
319  m_keys[ Utils::hash( key ) ] = key;
320  return StatusCode::SUCCESS;
321  }

◆ record() [6/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 234 of file TStore.cxx.

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

◆ record() [7/8]

StatusCode xAOD::TPyStore::record ( 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 104 of file TPyStore.cxx.

105  {
106 
107  // Simply forward the call to the appropriate function from the base
108  // class:
109  RETURN_CHECK( "xAOD::TPyStore::record",
111  /*isOwner*/kFALSE, /*isConst*/kFALSE ) );
112 
113  // Return gracefully:
114  return StatusCode::SUCCESS;
115  }

◆ 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 281 of file TStore.cxx.

283  {
284 
285  // Make sure that the key is not yet taken:
286  if( m_objects.find( key ) != m_objects.end() ) {
287  ::Error( "xAOD::TStore::record",
288  XAOD_MESSAGE( "Trying to overwrite object with key \"%s\"" ),
289  key.c_str() );
290  return StatusCode::FAILURE;
291  }
292 
293  // Register the new object:
294  if( isConst )
295  m_objects[ key ] = new THolder( const_cast<const void*>(obj), ti, isOwner );
296  else
297  m_objects[ key ] = new THolder( obj, ti, isOwner );
298 
299  m_keys[ Utils::hash( key ) ] = key;
300  return StatusCode::SUCCESS;
301  }

◆ 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  // Delete the hoder object:
69  delete itr->second;
70 
71  // Now remove this element from the maps:
72  m_objects.erase( itr );
73  m_keys.erase( Utils::hash( key ) );
74 
75  // We were successful:
76  return StatusCode::SUCCESS;
77  }

◆ remove() [2/2]

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

Remove an object from the store by pointer.

Definition at line 79 of file TStore.cxx.

79  {
80 
81  // Look for this object:
82  Objects_t::iterator itr = m_objects.begin();
84  for( ; itr != end; ++itr ) {
85 
86  // Check if this is the object in question:
87  if( itr->second->get() != ptr ) {
88  continue;
89  }
90 
91  // Yes, it is...
92  delete itr->second;
93  m_keys.erase( Utils::hash( itr->first ) );
94  m_objects.erase( itr );
95  return StatusCode::SUCCESS;
96  }
97 
98  // We didn't find the object in the store:
99  ::Warning( "xAOD::TStore::remove",
100  "Couldn't find object with pointer %p",
101  ptr );
102  return StatusCode::RECOVERABLE;
103  }

◆ 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 
45  TActiveStore::setStore( this );
46  return;
47  }

◆ TStore() [1/2]

xAOD::TStore::TStore

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

Definition at line 51 of file TStore.cxx.

25  : m_objects(), m_keys() {
26 
27  setActive();
28  }

◆ TStore() [2/2]

xAOD::TStore::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 169 of file TStore.h.

◆ m_objects

Objects_t xAOD::TStore::m_objects
protectedinherited

The object storage.

Definition at line 167 of file TStore.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RETURN_CHECK
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition: ReturnCheck.h:26
xAOD::TStore::m_keys
HashedKeys_t m_keys
The key map.
Definition: TStore.h:169
SG::normalizedTypeinfoName
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...
Definition: normalizedTypeinfoName.cxx:120
xAOD::TStore::setActive
void setActive()
Set this as the active transient store in the application.
Definition: TStore.cxx:43
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
atn_test_sgProducerConsumerDataPool_jobOptions.end
end
Definition: atn_test_sgProducerConsumerDataPool_jobOptions.py:25
xAOD::TStore::contains
::Bool_t contains(const std::string &key) const
Function checking if an object is available from the store.
xAOD::TStore::isConst
::Bool_t isConst(const std::string &key) const
Function checking if an object with a given type is constant.
python.xAODType.dummy
dummy
Definition: xAODType.py:4
xAOD::TStore::m_objects
Objects_t m_objects
The object storage.
Definition: TStore.h:167
xAOD::TStore::print
void print() const
Print the current contents of the transient store.
Definition: TStore.cxx:124
xAOD::TStore::record
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
xAOD::TActiveStore::setStore
static void setStore(TStore *ptr)
Set the active store pointer.
Definition: TActiveStore.cxx:21
xAOD::TStore::keys
void keys(std::vector< std::string > &vkeys) const
provide a list of keys associated with a type
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.PyAthena.obj
obj
Definition: PyAthena.py:135
xAOD::Utils::hash
SG::sgkey_t hash(const std::string &name)
This function provides a hashed version of the key (branch) names used in the xAOD file,...
Definition: Control/xAODRootAccess/Root/Utils.cxx:125
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37