ATLAS Offline Software
Loading...
Searching...
No Matches
ActiveStoreSvc Class Reference

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

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 }
StoreGateSvc * activeStoreOOL() const

◆ activeStoreOOL()

StoreGateSvc * ActiveStoreSvc::activeStoreOOL ( ) const
private

Definition at line 154 of file ActiveStoreSvc.cxx.

155{
157}
static StoreGateSvc * currentStoreGate()
get current StoreGate

◆ 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}
virtual SG::DataProxy * proxy(const void *const pTransient) const override
get proxy for a given data object address in memory
StoreGateSvc * activeStore() const
returns pointer to the active store as StoreGateSvc
virtual StatusCode addToStore(CLID id, SG::DataProxy *proxy) override final
Raw addition of a proxy to the store.

◆ initialize()

StatusCode ActiveStoreSvc::initialize ( )
overridevirtual

Service initialization.

Definition at line 17 of file ActiveStoreSvc.cxx.

17 {
18
19 CHECK( Service::initialize() );
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}
#define endmsg
#define CHECK(...)
Evaluate an expression and check for errors.
Gaudi::Property< std::string > m_storeName
MsgStream & msg
Definition testRead.cxx:32

◆ keyToString() [1/2]

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().

Definition at line 113 of file ActiveStoreSvc.cxx.

114{
115 return activeStore()->keyToString (key);
116}
virtual const std::string * keyToString(sgkey_t key) const override final
Find the string corresponding to a given key.

◆ keyToString() [2/2]

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().

Definition at line 127 of file ActiveStoreSvc.cxx.

129{
130 return activeStore()->keyToString (key, clid);
131}

◆ 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}
virtual std::vector< const SG::DataProxy * > proxies() const override final
return the list of all current proxies in store

◆ proxy() [1/2]

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}
virtual SG::DataProxy * proxy(const void *const pTransient) const override final
get proxy for a given data object address in memory

◆ proxy() [2/2]

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_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}
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override final
Get proxy given a hashed key+clid.

◆ 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}
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override final
Record an object in the store.

◆ 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}
virtual void registerKey(sgkey_t key, const std::string &str, CLID clidid) override final
Remember an additional mapping from key to string/CLID.

◆ 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}
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override final
Find the key for a string/CLID pair.

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.

149{this, "StoreName", StoreID::storeName(StoreID::EVENT_STORE), "StoreGate instance name"};
@ EVENT_STORE
Definition StoreID.h:26
static const std::string & storeName(const StoreID::type &s)
Definition StoreID.cxx:77

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