ATLAS Offline Software
|
A relatively simple transient store for objects created in analysis. More...
#include <TStore.h>
Public Member Functions | |
TStore () | |
Default constructor. More... | |
TStore (const TStore &)=delete | |
Disallow copying the object. More... | |
virtual | ~TStore () |
Destructor. More... | |
TStore & | operator= (const TStore &)=delete |
Disallow copying the object. 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... | |
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... | |
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... | |
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... | |
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... | |
Friends | |
class | TEvent |
Make TEvent a friend of this class. 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 > | |
StatusCode | record (std::unique_ptr< const T > obj, const std::string &key) |
Add a const object to the store, explicitly taking ownership of it. More... | |
template<typename T > | |
void | keys (std::vector< std::string > &vkeys) const |
provide a list of keys associated with a type More... | |
const THolder * | holder (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... | |
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 | ( | ) |
|
virtual |
void xAOD::TStore::clear | ( | ) |
::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 152 of file TStore.cxx.
|
protected |
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.
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 343 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 330 of file TStore.cxx.
|
protected |
Function retrieving a const object in a non-template way.
Definition at line 211 of file TStore.cxx.
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.
ptr | Pointer to the object that we want to know the name of |
Definition at line 390 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 366 of file TStore.cxx.
|
protected |
Function determining the list keys associated with a type name.
Definition at line 409 of file TStore.cxx.
|
protected |
Function retrieving a non-const object in a non-template way.
Definition at line 191 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 165 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 124 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 303 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 234 of file TStore.cxx.
|
protected |
|
private |
Internal implementation of the templated record method.
StatusCode xAOD::TStore::remove | ( | const std::string & | key | ) |
StatusCode xAOD::TStore::remove | ( | void * | ptr | ) |
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 |