Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Types | Public Member Functions | Static 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 Types

typedef SG::sgkey_t sgkey_t
 Type of the keys. More...
 

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 StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface) override
 
 ActiveStoreSvc (const std::string &name, ISvcLocator *svc)
 Standard Service Constructor. sets active store to default event store. More...
 
virtual ~ActiveStoreSvc () override
 Standard Destructor. 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...
 
 DeclareInterfaceID (IProxyDict, 2, 0)
 
virtual void boundHandle (IResetable *handle)
 Tell the store that a handle has been bound to a proxy. More...
 
virtual void unboundHandle (IResetable *handle)
 Tell the store that a handle has been unbound from a proxy. More...
 
virtual bool tryELRemap (sgkey_t sgkey_in, size_t index_in, sgkey_t &sgkey_out, size_t &index_out)
 Test to see if the target of an ElementLink has moved. More...
 
virtual StatusCode createObj (IConverter *cvt, IOpaqueAddress *addr, DataObject *&refpObject)
 Call converter to create an object, possibly with locking. More...
 
virtual IProxyDicthiveProxyDict () override
 Return the current event-slot-specific store. More...
 
virtual SG::SourceID sourceID (const std::string &key="EventSelector") const
 Return the metadata source ID for the current event slot. More...
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 not really kosher: should be in IActiveStoreSvc More...
 

Private Member Functions

StoreGateSvcactiveStoreOOL () const
 

Private Attributes

std::string m_storeName
 

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 Typedef Documentation

◆ sgkey_t

typedef SG::sgkey_t IStringPool::sgkey_t
inherited

Type of the keys.

Definition at line 34 of file IStringPool.h.

Constructor & Destructor Documentation

◆ ActiveStoreSvc()

ActiveStoreSvc::ActiveStoreSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Standard Service Constructor. sets active store to default event store.

Standard Constructor.

Definition at line 16 of file ActiveStoreSvc.cxx.

16  :
17  Service(name,svc),
18  m_storeName()
19 {
20  declareProperty("StoreName", m_storeName=StoreID::storeName(StoreID::EVENT_STORE));
21 }

◆ ~ActiveStoreSvc()

ActiveStoreSvc::~ActiveStoreSvc ( )
overridevirtual

Standard Destructor.

Definition at line 25 of file ActiveStoreSvc.cxx.

26 {}

Member Function Documentation

◆ activeStore()

StoreGateSvc* ActiveStoreSvc::activeStore ( ) const
inline

returns pointer to the active store as StoreGateSvc

Definition at line 35 of file ActiveStoreSvc.h.

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

◆ activeStoreOOL()

StoreGateSvc * ActiveStoreSvc::activeStoreOOL ( ) const
private

Definition at line 188 of file ActiveStoreSvc.cxx.

189 {
191 }

◆ addToStore()

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

Raw addition of a proxy to the store.

Implements IProxyDict.

Definition at line 73 of file ActiveStoreSvc.cxx.

74 {
75  return activeStore()->addToStore (id, proxy);
76 }

◆ boundHandle()

void IProxyDict::boundHandle ( IResetable handle)
virtualinherited

Tell the store that a handle has been bound to a proxy.

Parameters
handleThe handle that was bound. The default implementation does nothing.

Reimplemented in SGImplSvc.

Definition at line 23 of file IProxyDict.cxx.

24 {
25 }

◆ createObj()

StatusCode IProxyDict::createObj ( IConverter *  cvt,
IOpaqueAddress *  addr,
DataObject *&  refpObject 
)
virtualinherited

Call converter to create an object, possibly with locking.

Parameters
cvtThe converter to call.
addrOpaque address information for the object to create.
refpObjectReference to location of the pointer of the created object.

This calls the createObj method on cvt to create the referenced transient object.

This will also lock the store, if that is required.

The default implementation just forwards the method call, with no locking.

Reimplemented in StoreGateSvc, and SGImplSvc.

Definition at line 70 of file IProxyDict.cxx.

73 {
74  return cvt->createObj (addr, refpObject);
75 }

◆ DeclareInterfaceID()

IProxyDict::DeclareInterfaceID ( IProxyDict  ,
,
 
)
inherited

◆ hiveProxyDict()

IProxyDict * IProxyDict::hiveProxyDict ( )
overridevirtualinherited

Return the current event-slot-specific store.

The default version just returns this.

Reimplemented in StoreGateSvc, and SGImplSvc.

Definition at line 83 of file IProxyDict.cxx.

84 {
85  return this;
86 }

◆ initialize()

StatusCode ActiveStoreSvc::initialize ( )
overridevirtual

Service initialization.

Definition at line 30 of file ActiveStoreSvc.cxx.

30  {
31 
33 
34  msg() << MSG::VERBOSE << "Initializing " << name() << endmsg;
35 
36  SmartIF<StoreGateSvc> storeGate{service(m_storeName, /*createIf*/true)};
37  CHECK( storeGate.isValid() );
38  storeGate->makeCurrent();
39 
40  return StatusCode::SUCCESS;
41 }

◆ interfaceID()

const InterfaceID & ActiveStoreSvc::interfaceID ( )
static

not really kosher: should be in IActiveStoreSvc

Definition at line 167 of file ActiveStoreSvc.cxx.

167  {
168  static const InterfaceID IDActiveStoreSvc("ActiveStoreSvc", 1, 0);
169  return IDActiveStoreSvc;
170 }

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

Implements IStringPool.

Definition at line 126 of file ActiveStoreSvc.cxx.

127 {
128  return activeStore()->keyToString (key);
129 }

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

Implements IStringPool.

Definition at line 140 of file ActiveStoreSvc.cxx.

142 {
143  return activeStore()->keyToString (key, clid);
144 }

◆ operator->()

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

dereference operator to access the active store

Definition at line 42 of file ActiveStoreSvc.h.

42  {
43  return activeStore();
44  }

◆ proxies()

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

return the list of all current proxies in store

Implements IProxyDict.

Definition at line 67 of file ActiveStoreSvc.cxx.

67  {
68  return activeStore()->proxies();
69 }

◆ 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

Implements IProxyDict.

Definition at line 56 of file ActiveStoreSvc.cxx.

56  {
57  return activeStore()->proxy(id,key);
58 }

◆ 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

Implements IProxyDict.

Definition at line 50 of file ActiveStoreSvc.cxx.

50  {
51  return activeStore()->proxy(pTransient);
52 }

◆ 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.

Implements IProxyDict.

Definition at line 60 of file ActiveStoreSvc.cxx.

61 {
62  return activeStore()->proxy_exact (sgkey);
63 }

◆ queryInterface()

StatusCode ActiveStoreSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
overridevirtual

Definition at line 171 of file ActiveStoreSvc.cxx.

172 {
173  if ( interfaceID().versionMatch(riid) ) {
174  *ppvInterface = (ActiveStoreSvc*)this;
175  }
176  else if ( IProxyDict::interfaceID().versionMatch(riid) ) {
177  *ppvInterface = (IProxyDict*)this;
178  }
179  else {
180  // Interface is not directly available: try out a base class
181  return Service::queryInterface(riid, ppvInterface);
182  }
183  addRef();
184  return StatusCode::SUCCESS;
185 }

◆ 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.

Implements IProxyDict.

Definition at line 96 of file ActiveStoreSvc.cxx.

100 {
101  return activeStore()->recordObject (obj, key, allowMods, returnExisting);
102 }

◆ 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.

Implements IStringPool.

Definition at line 159 of file ActiveStoreSvc.cxx.

162 {
163  return activeStore()->registerKey (key, str, clid);
164 }

◆ setStore()

void ActiveStoreSvc::setStore ( StoreGateSvc s)

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

Definition at line 44 of file ActiveStoreSvc.cxx.

44  {
45  s->makeCurrent();
46 }

◆ sourceID()

SG::SourceID IProxyDict::sourceID ( const std::string &  key = "EventSelector") const
virtualinherited

Return the metadata source ID for the current event slot.

Parameters
keySG key of the DataHeader to query. Returns an empty string if no source has been set.

The default version always returns an empty string.

Reimplemented in StoreGateSvc, and SGImplSvc.

Definition at line 97 of file IProxyDict.cxx.

98 {
99  return SG::SourceID();
100 }

◆ 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!

Implements IStringPool.

Definition at line 113 of file ActiveStoreSvc.cxx.

114 {
115  return activeStore()->stringToKey (str, clid);
116 }

◆ tryELRemap()

bool IProxyDict::tryELRemap ( sgkey_t  sgkey_in,
size_t  index_in,
sgkey_t sgkey_out,
size_t &  index_out 
)
virtualinherited

Test to see if the target of an ElementLink has moved.

Parameters
sgkey_inOriginal hashed key of the EL.
index_inOriginal index of the EL.
sgkey_out[out]New hashed key for the EL.
index_out[out]New index for the EL.
Returns
True if there is a remapping; false otherwise.

The default implementation here always returns false.

Reimplemented in StoreGateSvc, and SGImplSvc.

Definition at line 48 of file IProxyDict.cxx.

50 {
51  return false;
52 }

◆ unboundHandle()

void IProxyDict::unboundHandle ( IResetable handle)
virtualinherited

Tell the store that a handle has been unbound from a proxy.

Parameters
handleThe handle that was unbound. The default implementation does nothing.

Reimplemented in SGImplSvc.

Definition at line 33 of file IProxyDict.cxx.

34 {
35 }

Member Data Documentation

◆ m_storeName

std::string ActiveStoreSvc::m_storeName
private

Definition at line 159 of file ActiveStoreSvc.h.


The documentation for this class was generated from the following files:
common.sgkey
def sgkey(tool)
Definition: common.py:1028
ActiveStoreSvc::m_storeName
std::string m_storeName
Definition: ActiveStoreSvc.h:159
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ActiveStoreSvc::activeStore
StoreGateSvc * activeStore() const
returns pointer to the active store as StoreGateSvc
Definition: ActiveStoreSvc.h:35
initialize
void initialize()
Definition: run_EoverP.cxx:894
ActiveStoreSvc
A service that caches a pointer to the currently active store. It also implements the IProxyDict stor...
Definition: ActiveStoreSvc.h:31
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
StoreGateSvc::currentStoreGate
static StoreGateSvc * currentStoreGate()
get current StoreGate
Definition: StoreGateSvc.cxx:69
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActiveStoreSvc::activeStoreOOL
StoreGateSvc * activeStoreOOL() const
Definition: ActiveStoreSvc.cxx:188
SG::SourceID
std::string SourceID
Definition: AthenaKernel/AthenaKernel/SourceID.h:25
str
Definition: BTagTrackIpAccessor.cxx:11
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
python.PyAthena.obj
obj
Definition: PyAthena.py:132
ActiveStoreSvc::interfaceID
static const InterfaceID & interfaceID()
not really kosher: should be in IActiveStoreSvc
Definition: ActiveStoreSvc.cxx:167
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77
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:50