ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ActiveStoreSvc Class Reference

A service that caches a pointer to the currently active store. It also implements the IProxyDict store interface. More...

#include <ActiveStoreSvc.h>

Inheritance diagram for ActiveStoreSvc:
Collaboration diagram for ActiveStoreSvc:

Public Member Functions

StoreGateSvcactiveStore () const
 returns pointer to the active store as StoreGateSvc More...
 
StoreGateSvcoperator-> () const
 dereference operator to access the active store More...
 
void setStore (StoreGateSvc *s)
 set the active store pointer: used by the event loop mgrs More...
 
virtual SG::DataProxyproxy (const void *const pTransient) const override
 get proxy for a given data object address in memory More...
 
virtual SG::DataProxyproxy (const CLID &id, const std::string &key) const override
 get proxy with given id and key. Returns 0 to flag failure More...
 
virtual SG::DataProxyproxy_exact (SG::sgkey_t sgkey) const override
 Get proxy given a hashed key+clid. More...
 
virtual std::vector< const SG::DataProxy * > proxies () const override
 return the list of all current proxies in store More...
 
StatusCode addToStore (CLID id, SG::DataProxy *proxy) override
 Raw addition of a proxy to the store. More...
 
virtual SG::DataProxyrecordObject (SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override
 Record an object in the store. More...
 
virtual sgkey_t stringToKey (const std::string &str, CLID clid) override
 Find the key for a string/CLID pair. More...
 
virtual const std::string * keyToString (sgkey_t key) const override
 Find the string corresponding to a given key. More...
 
virtual const std::string * keyToString (sgkey_t key, CLID &clid) const override
 Find the string and CLID corresponding to a given key. More...
 
virtual void registerKey (sgkey_t key, const std::string &str, CLID clid) override
 Remember an additional mapping from key to string/CLID. More...
 
virtual StatusCode initialize () override
 Service initialization. More...
 
virtual SG::DataProxyproxy (const CLID &id, const std::string &key) const=0
 TEMPORARY: avoid warnings. More...
 
virtual SG::DataProxyproxy (const void *const pTransient) const=0
 TEMPORARY: avoid warnings. More...
 

Private Member Functions

StoreGateSvcactiveStoreOOL () const
 

Private Attributes

Gaudi::Property< std::string > m_storeName {this, "StoreName", StoreID::storeName(StoreID::EVENT_STORE), "StoreGate instance name"}
 

Detailed Description

A service that caches a pointer to the currently active store. It also implements the IProxyDict store interface.

In most jobs the active store is simply the default event store (named "StoreGateSvc"). When doing pile-up (and perhaps later on in multi-threaded jobs, the active store changes during the event loop execution. It is important, for example, that converters always refer to the active store rather than to the default one.

Author
ATLAS Collaboration

Definition at line 29 of file ActiveStoreSvc.h.

Member Function Documentation

◆ activeStore()

StoreGateSvc* ActiveStoreSvc::activeStore ( ) const
inline

returns pointer to the active store as StoreGateSvc

Definition at line 36 of file ActiveStoreSvc.h.

36  {
37  // Can't just `return StoreGateSvc::currentStoreGate()` due to
38  // a circular dependency
39  return activeStoreOOL();
40  }

◆ activeStoreOOL()

StoreGateSvc * ActiveStoreSvc::activeStoreOOL ( ) const
private

Definition at line 154 of file ActiveStoreSvc.cxx.

155 {
157 }

◆ addToStore()

StatusCode ActiveStoreSvc::addToStore ( CLID  id,
SG::DataProxy proxy 
)
override

Raw addition of a proxy to the store.

Definition at line 60 of file ActiveStoreSvc.cxx.

61 {
62  return activeStore()->addToStore (id, proxy);
63 }

◆ initialize()

StatusCode ActiveStoreSvc::initialize ( )
overridevirtual

Service initialization.

Definition at line 17 of file ActiveStoreSvc.cxx.

17  {
18 
20 
21  msg() << MSG::VERBOSE << "Initializing " << name() << endmsg;
22 
23  SmartIF<StoreGateSvc> storeGate{service(m_storeName, /*createIf*/true)};
24  CHECK( storeGate.isValid() );
25  storeGate->makeCurrent();
26 
27  return StatusCode::SUCCESS;
28 }

◆ keyToString() [1/2]

virtual const std::string* ActiveStoreSvc::keyToString ( sgkey_t  key) const
overridevirtual

Find the string corresponding to a given key.

Parameters
keyThe key to look up.
Returns
Pointer to the string found, or null. We can find keys as long as the corresponding string was given to either stringToKey() or registerKey().

◆ keyToString() [2/2]

virtual const std::string* ActiveStoreSvc::keyToString ( sgkey_t  key,
CLID clid 
) const
overridevirtual

Find the string and CLID corresponding to a given key.

Parameters
keyThe key to look up.
clid[out]The found CLID.
Returns
Pointer to the string found, or null. We can find keys as long as the corresponding string was given to either stringToKey() or registerKey().

◆ operator->()

StoreGateSvc* ActiveStoreSvc::operator-> ( ) const
inline

dereference operator to access the active store

Definition at line 43 of file ActiveStoreSvc.h.

43  {
44  return activeStore();
45  }

◆ proxies()

std::vector< const SG::DataProxy * > ActiveStoreSvc::proxies ( ) const
overridevirtual

return the list of all current proxies in store

Definition at line 54 of file ActiveStoreSvc.cxx.

54  {
55  return activeStore()->proxies();
56 }

◆ proxy() [1/4]

DataProxy * ActiveStoreSvc::proxy ( const CLID id,
const std::string &  key 
) const
overridevirtual

get proxy with given id and key. Returns 0 to flag failure

Definition at line 43 of file ActiveStoreSvc.cxx.

43  {
44  return activeStore()->proxy(id,key);
45 }

◆ proxy() [2/4]

virtual SG::DataProxy* IProxyDict::proxy

TEMPORARY: avoid warnings.

◆ proxy() [3/4]

DataProxy * ActiveStoreSvc::proxy ( const void *const  pTransient) const
overridevirtual

get proxy for a given data object address in memory

Definition at line 37 of file ActiveStoreSvc.cxx.

37  {
38  return activeStore()->proxy(pTransient);
39 }

◆ proxy() [4/4]

virtual SG::DataProxy* IProxyDict::proxy

TEMPORARY: avoid warnings.

◆ proxy_exact()

SG::DataProxy * ActiveStoreSvc::proxy_exact ( SG::sgkey_t  sgkey) const
overridevirtual

Get proxy given a hashed key+clid.

Find an exact match; no handling of aliases, etc. Returns 0 to flag failure.

Definition at line 47 of file ActiveStoreSvc.cxx.

48 {
49  return activeStore()->proxy_exact (sgkey);
50 }

◆ recordObject()

SG::DataProxy * ActiveStoreSvc::recordObject ( SG::DataObjectSharedPtr< DataObject >  obj,
const std::string &  key,
bool  allowMods,
bool  returnExisting 
)
overridevirtual

Record an object in the store.

Parameters
objThe data object to store.
keyThe key as which it should be stored.
allowModsIf false, the object will be recorded as const.
returnExistingIf true, return proxy if this key already exists.

Full-blown record. obj should usually be something deriving from SG::DataBucket.

Returns the proxy for the recorded object; nullptr on failure. If the requested CLID/key combination already exists in the store, the behavior is controlled by returnExisting. If true, then the existing proxy is returned; otherwise, nullptr is returned. In either case, obj is destroyed.

Definition at line 83 of file ActiveStoreSvc.cxx.

87 {
88  return activeStore()->recordObject (obj, key, allowMods, returnExisting);
89 }

◆ registerKey()

void ActiveStoreSvc::registerKey ( sgkey_t  key,
const std::string &  str,
CLID  clid 
)
overridevirtual

Remember an additional mapping from key to string/CLID.

Parameters
keyThe key to enter.
strThe string to enter.
clidThe CLID associated with the string.
Returns
True if successful; false if the key already corresponds to a different string.

This registers an additional mapping from a key to a string; it can be found later through lookup() on the string. Logs an error if key already corresponds to a different string.

Definition at line 146 of file ActiveStoreSvc.cxx.

149 {
150  return activeStore()->registerKey (key, str, clid);
151 }

◆ setStore()

void ActiveStoreSvc::setStore ( StoreGateSvc s)

set the active store pointer: used by the event loop mgrs

Definition at line 31 of file ActiveStoreSvc.cxx.

31  {
32  s->makeCurrent();
33 }

◆ stringToKey()

sgkey_t ActiveStoreSvc::stringToKey ( const std::string &  str,
CLID  clid 
)
overridevirtual

Find the key for a string/CLID pair.

Parameters
strThe string to look up.
clidThe CLID associated with the string.
Returns
A key identifying the string. A given string will always return the same key. Will abort in case of a hash collision!

Definition at line 100 of file ActiveStoreSvc.cxx.

101 {
102  return activeStore()->stringToKey (str, clid);
103 }

Member Data Documentation

◆ m_storeName

Gaudi::Property<std::string> ActiveStoreSvc::m_storeName {this, "StoreName", StoreID::storeName(StoreID::EVENT_STORE), "StoreGate instance name"}
private

Definition at line 149 of file ActiveStoreSvc.h.


The documentation for this class was generated from the following files:
common.sgkey
def sgkey(tool)
Definition: common.py:1027
ActiveStoreSvc::activeStore
StoreGateSvc * activeStore() const
returns pointer to the active store as StoreGateSvc
Definition: ActiveStoreSvc.h:36
initialize
void initialize()
Definition: run_EoverP.cxx:894
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
StoreGateSvc::currentStoreGate
static StoreGateSvc * currentStoreGate()
get current StoreGate
Definition: StoreGateSvc.cxx:51
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActiveStoreSvc::activeStoreOOL
StoreGateSvc * activeStoreOOL() const
Definition: ActiveStoreSvc.cxx:154
ActiveStoreSvc::m_storeName
Gaudi::Property< std::string > m_storeName
Definition: ActiveStoreSvc.h:149
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
str
Definition: BTagTrackIpAccessor.cxx:11
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
python.PyAthena.obj
obj
Definition: PyAthena.py:132
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
python.PyKernel.storeGate
storeGate
Definition: PyKernel.py:40
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
ActiveStoreSvc::proxy
virtual SG::DataProxy * proxy(const void *const pTransient) const override
get proxy for a given data object address in memory
Definition: ActiveStoreSvc.cxx:37