![]() |
ATLAS Offline Software
|
A relatively simple transient store for objects created in analysis. More...
#include <TStore.h>
Public Member Functions | |
| TStore () | |
| Default constructor. | |
| TStore (const TStore &)=delete | |
| Disallow copying the object. | |
| virtual | ~TStore () |
| Destructor. | |
| TStore & | operator= (const TStore &)=delete |
| Disallow copying the object. | |
| 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. | |
| 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. | |
| 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. | |
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. | |
Friends | |
| class | TEvent |
| Make TEvent a friend of this class. | |
| class | Event |
A relatively simple transient store for objects created in analysis.
This is a very simple transient store for objects that are created during analysis, but don't have to be written to the output file(s). To make it easier for the analysis tools to communicate with each other similar to how they would do it in Athena (with StoreGateSvc), they can use this class.
The usage of this class is highly optional in analysis, it should only be used if really necessary. (Passing around objects in analysis code directly is usually a better approach than using a store in my mind...)
|
protected |
|
protected |
| xAOD::TStore::TStore | ( | ) |
Default constructor.
Definition at line 24 of file TStore.cxx.
|
delete |
Disallow copying the object.
|
virtual |
Destructor.
Definition at line 30 of file TStore.cxx.
| void xAOD::TStore::clear | ( | ) |
Clear the store of all of its contents.
Definition at line 95 of file TStore.cxx.
| ::Bool_t xAOD::TStore::contains | ( | const std::string & | key | ) | const |
Function checking if an object is available from the store.
|
protected |
Non-templated function implementing the containment check.
Definition at line 143 of file TStore.cxx.
|
protected |
Check if an object with a given pointer is managed by the store.
| ptr | Pointer to the object that may or may not be in the store |
kTRUE if the object is managed by the store, or kFALSE if it isn't Definition at line 325 of file TStore.cxx.
|
protected |
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.
| hash | The hashed key of the object that we are looking for |
kTRUE if the object is managed by the store, or kFALSE if it is not Definition at line 315 of file TStore.cxx.
|
protected |
Function retrieving a const object in a non-template way.
Definition at line 202 of file TStore.cxx.
Get the name of a managed object.
| ptr | Pointer to the object that we want to know the name of |
Definition at line 357 of file TStore.cxx.
|
protected |
Get the name corresponding to a hashed key.
This is a fairly fast function.
Used by ElementLinks that point to objects in this store.
| hash | The hashed key for which we want to find the string key |
Definition at line 337 of file TStore.cxx.
|
protected |
Function determining the list keys associated with a type name.
Definition at line 371 of file TStore.cxx.
|
protected |
Function retrieving a non-const object in a non-template way.
Definition at line 182 of file TStore.cxx.
return holder for key
Definition at line 50 of file TStore.cxx.
| ::Bool_t xAOD::TStore::isConst | ( | const std::string & | key | ) | const |
Function checking if an object with a given type is constant.
Non-templated function implementing the const-ness check.
Definition at line 156 of file TStore.cxx.
| void xAOD::TStore::keys | ( | std::vector< std::string > & | vkeys | ) | const |
provide a list of keys associated with a type
| void xAOD::TStore::print | ( | ) | const |
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.
Add a const object to the store.
|
protected |
Function doing the first step of recording a ConstDataVector object.
| StatusCode xAOD::TStore::record | ( | std::unique_ptr< const T > | obj, |
| const std::string & | key ) |
Add a const object to the store, explicitly taking ownership of it.
| StatusCode xAOD::TStore::record | ( | std::unique_ptr< T > | obj, |
| const std::string & | key ) |
Add an object to the store, explicitly taking ownership of it.
| StatusCode xAOD::TStore::record | ( | T * | obj, |
| const std::string & | key ) |
Add an object to the store.
Function doing the second step of recording a ConstDataVector object.
Definition at line 286 of file TStore.cxx.
|
protected |
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.
| obj | Typeless pointer to the object being recorded |
| key | Key to record the object with |
| classname | The type name of the object being recorded |
| isOwner | If kTRUE, the store takes ownership of the object, otherwise it doesn't |
Definition at line 225 of file TStore.cxx.
|
protected |
Function recording an object that has no dictionary.
Definition at line 268 of file TStore.cxx.
|
private |
Internal implementation of the templated record method.
| StatusCode xAOD::TStore::remove | ( | const std::string & | key | ) |
Remove an object from the store by name.
Definition at line 57 of file TStore.cxx.
| StatusCode xAOD::TStore::remove | ( | void * | ptr | ) |
Remove an object from the store by pointer.
Definition at line 80 of file TStore.cxx.
| StatusCode xAOD::TStore::retrieve | ( | const T *& | obj, |
| const std::string & | key ) const |
Retrieve either a constant or non-constant object from the store.
| StatusCode xAOD::TStore::retrieve | ( | T *& | obj, |
| const std::string & | key ) const |
Retrieve a non-constant object from the store.
| void xAOD::TStore::setActive | ( | ) |
Set this as the active transient store in the application.
Definition at line 43 of file TStore.cxx.
|
friend |
|
protected |
|
protected |