ATLAS Offline Software
ActiveStoreSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 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 #include "AthenaKernel/StoreID.h"
13 
14 class StoreGateSvc;
15 
16 
29 class ActiveStoreSvc : public extends<Service, IProxyDict>
30 {
31 public:
33  using base_class::base_class;
34 
36  inline StoreGateSvc* activeStore() const {
37  // Can't just `return StoreGateSvc::currentStoreGate()` due to
38  // a circular dependency
39  return activeStoreOOL();
40  }
41 
43  inline StoreGateSvc* operator->() const {
44  return activeStore();
45  }
46 
48  using IProxyDict::proxy;
49 
51  void setStore(StoreGateSvc* s);
52 
54  virtual SG::DataProxy* proxy(const void* const pTransient) const override;
55 
57  virtual SG::DataProxy* proxy(const CLID& id, const std::string& key) const override;
58 
62  virtual SG::DataProxy* proxy_exact (SG::sgkey_t sgkey) const override;
63 
65  virtual std::vector<const SG::DataProxy*> proxies() const override;
67 
70 
87  virtual
89  const std::string& key,
90  bool allowMods,
91  bool returnExisting) override;
92 
93 
102  virtual
103  sgkey_t stringToKey (const std::string& str, CLID clid) override;
104 
112  virtual
113  const std::string* keyToString (sgkey_t key) const override;
114 
123  virtual
124  const std::string* keyToString (sgkey_t key,
125  CLID& clid) const override;
126 
139  virtual
140  void registerKey (sgkey_t key,
141  const std::string& str,
142  CLID clid) override;
143 
144 
145  virtual StatusCode initialize() override;
146 
147 private:
148  StoreGateSvc* activeStoreOOL() const;
149  Gaudi::Property<std::string> m_storeName{this, "StoreName", StoreID::storeName(StoreID::EVENT_STORE), "StoreGate instance name"};
150 
151 };
152 #endif // STOREGATE_ACTIVESTORESVC_H
153 
154 
155 
common.sgkey
def sgkey(tool)
Definition: common.py:1027
ActiveStoreSvc::keyToString
virtual const std::string * keyToString(sgkey_t key, CLID &clid) const override
Find the string and CLID corresponding to a given key.
ActiveStoreSvc::activeStore
StoreGateSvc * activeStore() const
returns pointer to the active store as StoreGateSvc
Definition: ActiveStoreSvc.h:36
IProxyDict::proxy
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
ActiveStoreSvc::proxy_exact
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override
Get proxy given a hashed key+clid.
Definition: ActiveStoreSvc.cxx:47
ActiveStoreSvc
A service that caches a pointer to the currently active store. It also implements the IProxyDict stor...
Definition: ActiveStoreSvc.h:30
ActiveStoreSvc::proxies
virtual std::vector< const SG::DataProxy * > proxies() const override
return the list of all current proxies in store
Definition: ActiveStoreSvc.cxx:54
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:120
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
StoreID.h
IProxyDict.h
ActiveStoreSvc::initialize
virtual StatusCode initialize() override
Service initialization.
Definition: ActiveStoreSvc.cxx:17
ActiveStoreSvc::activeStoreOOL
StoreGateSvc * activeStoreOOL() const
Definition: ActiveStoreSvc.cxx:154
ActiveStoreSvc::m_storeName
Gaudi::Property< std::string > m_storeName
Definition: ActiveStoreSvc.h:149
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:100
ActiveStoreSvc::keyToString
virtual const std::string * keyToString(sgkey_t key) const override
Find the string corresponding to a given key.
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:146
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
ActiveStoreSvc::setStore
void setStore(StoreGateSvc *s)
set the active store pointer: used by the event loop mgrs
Definition: ActiveStoreSvc.cxx:31
ActiveStoreSvc::operator->
StoreGateSvc * operator->() const
dereference operator to access the active store
Definition: ActiveStoreSvc.h:43
str
Definition: BTagTrackIpAccessor.cxx:11
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
SG::DataObjectSharedPtr
Smart pointer to manage DataObject reference counts.
Definition: DataObjectSharedPtr.h:45
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::DataProxy
Definition: DataProxy.h:45
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77
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:83
ActiveStoreSvc::addToStore
StatusCode addToStore(CLID id, SG::DataProxy *proxy) override
Raw addition of a proxy to the store.
Definition: ActiveStoreSvc.cxx:60
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