ATLAS Offline Software
ActiveStoreSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef STOREGATE_ACTIVESTORESVC_H
6 #define STOREGATE_ACTIVESTORESVC_H
7 
8 #include "GaudiKernel/Service.h"
9 #include "GaudiKernel/StatusCode.h"
10 
12 
13 class StoreGateSvc;
14 class ISvcLocator;
15 
16 
29 class ActiveStoreSvc : public IProxyDict,
30  public Service
31 {
32 public:
33 
35  inline StoreGateSvc* activeStore() const {
36  // Can't just `return StoreGateSvc::currentStoreGate()` due to
37  // a circular dependency
38  return activeStoreOOL();
39  }
40 
42  inline StoreGateSvc* operator->() const {
43  return activeStore();
44  }
45 
47  using IProxyDict::proxy;
48 
50  void setStore(StoreGateSvc* s);
51 
53  virtual SG::DataProxy* proxy(const void* const pTransient) const override;
54 
56  virtual SG::DataProxy* proxy(const CLID& id, const std::string& key) const override;
57 
61  virtual SG::DataProxy* proxy_exact (SG::sgkey_t sgkey) const override;
62 
64  virtual std::vector<const SG::DataProxy*> proxies() const override;
66 
69 
86  virtual
88  const std::string& key,
89  bool allowMods,
90  bool returnExisting) override;
91 
92 
101  virtual
102  sgkey_t stringToKey (const std::string& str, CLID clid) override;
103 
111  virtual
112  const std::string* keyToString (sgkey_t key) const override;
113 
122  virtual
123  const std::string* keyToString (sgkey_t key,
124  CLID& clid) const override;
125 
138  virtual
139  void registerKey (sgkey_t key,
140  const std::string& str,
141  CLID clid) override;
142 
143 
145  virtual StatusCode initialize() override;
146  virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ) override;
148 
150  static const InterfaceID& interfaceID();
151 
153  ActiveStoreSvc(const std::string& name, ISvcLocator* svc);
154 
155  virtual ~ActiveStoreSvc() override;
156 
157 private:
158  StoreGateSvc* activeStoreOOL() const;
159  std::string m_storeName; //< property: StoreGate instance name
160 
161 };
162 #endif // STOREGATE_ACTIVESTORESVC_H
163 
164 
165 
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
IProxyDict::proxy
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
ActiveStoreSvc::~ActiveStoreSvc
virtual ~ActiveStoreSvc() override
Standard Destructor.
Definition: ActiveStoreSvc.cxx:25
ActiveStoreSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: ActiveStoreSvc.cxx:171
ActiveStoreSvc::proxy_exact
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override
Get proxy given a hashed key+clid.
Definition: ActiveStoreSvc.cxx:60
ActiveStoreSvc::ActiveStoreSvc
ActiveStoreSvc(const std::string &name, ISvcLocator *svc)
Standard Service Constructor. sets active store to default event store.
Definition: ActiveStoreSvc.cxx:16
ActiveStoreSvc
A service that caches a pointer to the currently active store. It also implements the IProxyDict stor...
Definition: ActiveStoreSvc.h:31
ActiveStoreSvc::proxies
virtual std::vector< const SG::DataProxy * > proxies() const override
return the list of all current proxies in store
Definition: ActiveStoreSvc.cxx:67
IStringPool::sgkey_t
SG::sgkey_t sgkey_t
Type of the keys.
Definition: IStringPool.h:34
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ActiveStoreSvc::keyToString
virtual const std::string * keyToString(sgkey_t key) const override
Find the string corresponding to a given key.
Definition: ActiveStoreSvc.cxx:126
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IProxyDict.h
ActiveStoreSvc::initialize
virtual StatusCode initialize() override
Service initialization.
Definition: ActiveStoreSvc.cxx:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActiveStoreSvc::activeStoreOOL
StoreGateSvc * activeStoreOOL() const
Definition: ActiveStoreSvc.cxx:188
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
ActiveStoreSvc::stringToKey
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override
Find the key for a string/CLID pair.
Definition: ActiveStoreSvc.cxx:113
ActiveStoreSvc::registerKey
virtual void registerKey(sgkey_t key, const std::string &str, CLID clid) override
Remember an additional mapping from key to string/CLID.
Definition: ActiveStoreSvc.cxx:159
ActiveStoreSvc::setStore
void setStore(StoreGateSvc *s)
set the active store pointer: used by the event loop mgrs
Definition: ActiveStoreSvc.cxx:44
ActiveStoreSvc::operator->
StoreGateSvc * operator->() const
dereference operator to access the active store
Definition: ActiveStoreSvc.h:42
str
Definition: BTagTrackIpAccessor.cxx:11
SG::DataObjectSharedPtr
Smart pointer to manage DataObject reference counts.
Definition: DataObjectSharedPtr.h:46
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::DataProxy
Definition: DataProxy.h:44
ActiveStoreSvc::interfaceID
static const InterfaceID & interfaceID()
not really kosher: should be in IActiveStoreSvc
Definition: ActiveStoreSvc.cxx:167
ActiveStoreSvc::recordObject
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override
Record an object in the store.
Definition: ActiveStoreSvc.cxx:96
ActiveStoreSvc::addToStore
StatusCode addToStore(CLID id, SG::DataProxy *proxy) override
Raw addition of a proxy to the store.
Definition: ActiveStoreSvc.cxx:73
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