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

StoreGateSvc * activeStore () const
 returns pointer to the active store as StoreGateSvc
StoreGateSvc * operator-> () 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::DataProxy * proxy (const void *const pTransient) const override
 get proxy for a given data object address in memory
virtual SG::DataProxy * proxy (const CLID &id, const std::string &key) const override
 get proxy with given id and key. Returns 0 to flag failure
virtual SG::DataProxy * proxy_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::DataProxy * recordObject (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

StoreGateSvc * activeStoreOOL () 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 155 of file ActiveStoreSvc.cxx.

156{
158}
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 61 of file ActiveStoreSvc.cxx.

62{
63 return activeStore()->addToStore (id, proxy);
64}
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 18 of file ActiveStoreSvc.cxx.

18 {
19
20 CHECK( Service::initialize() );
21
22 SG_MSG_VERBOSE ("Initializing {}", name());
23
24 SmartIF<StoreGateSvc> storeGate{service(m_storeName, /*createIf*/true)};
25 CHECK( storeGate.isValid() );
26 storeGate->makeCurrent();
27
28 return StatusCode::SUCCESS;
29}
#define CHECK(...)
Evaluate an expression and check for errors.
#define SG_MSG_VERBOSE(x,...)
Gaudi::Property< std::string > m_storeName

◆ 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 114 of file ActiveStoreSvc.cxx.

115{
116 return activeStore()->keyToString (key);
117}
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 128 of file ActiveStoreSvc.cxx.

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

◆ 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 55 of file ActiveStoreSvc.cxx.

55 {
56 return activeStore()->proxies();
57}
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 44 of file ActiveStoreSvc.cxx.

44 {
45 return activeStore()->proxy(id,key);
46}
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 38 of file ActiveStoreSvc.cxx.

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

◆ 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 48 of file ActiveStoreSvc.cxx.

49{
50 return activeStore()->proxy_exact (sgkey);
51}
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 84 of file ActiveStoreSvc.cxx.

88{
89 return activeStore()->recordObject (obj, key, allowMods, returnExisting);
90}
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 147 of file ActiveStoreSvc.cxx.

150{
151 return activeStore()->registerKey (key, str, clid);
152}
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 32 of file ActiveStoreSvc.cxx.

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

◆ 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 101 of file ActiveStoreSvc.cxx.

102{
103 return activeStore()->stringToKey (str, clid);
104}
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: