ATLAS Offline Software
ActiveStoreSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include "AthenaKernel/StoreID.h"
9 
10 #include "GaudiKernel/MsgStream.h"
11 #include "GaudiKernel/ISvcLocator.h"
12 
13 using namespace SG;
14 
16 ActiveStoreSvc::ActiveStoreSvc(const std::string& name,ISvcLocator* svc) :
17  Service(name,svc),
18  m_storeName()
19 {
20  declareProperty("StoreName", m_storeName=StoreID::storeName(StoreID::EVENT_STORE));
21 }
22 
23 
26 {}
27 
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 }
42 
45  s->makeCurrent();
46 }
47 
49 DataProxy*
50 ActiveStoreSvc::proxy(const void* const pTransient) const {
51  return activeStore()->proxy(pTransient);
52 }
53 
55 DataProxy*
56 ActiveStoreSvc::proxy(const CLID& id, const std::string& key) const {
57  return activeStore()->proxy(id,key);
58 }
59 
61 {
62  return activeStore()->proxy_exact (sgkey);
63 }
64 
66 std::vector<const SG::DataProxy*>
68  return activeStore()->proxies();
69 }
70 
71 
74 {
75  return activeStore()->addToStore (id, proxy);
76 }
77 
78 
97  const std::string& key,
98  bool allowMods,
99  bool returnExisting)
100 {
101  return activeStore()->recordObject (obj, key, allowMods, returnExisting);
102 }
103 
104 
113 sgkey_t ActiveStoreSvc::stringToKey (const std::string& str, CLID clid)
114 {
115  return activeStore()->stringToKey (str, clid);
116 }
117 
118 
126 const std::string* ActiveStoreSvc::keyToString (sgkey_t key) const
127 {
128  return activeStore()->keyToString (key);
129 }
130 
131 
141  CLID& clid) const
142 {
143  return activeStore()->keyToString (key, clid);
144 }
145 
146 
160  const std::string& str,
161  CLID clid)
162 {
163  return activeStore()->registerKey (key, str, clid);
164 }
165 
166 
167 const InterfaceID& ActiveStoreSvc::interfaceID() {
168  static const InterfaceID IDActiveStoreSvc("ActiveStoreSvc", 1, 0);
169  return IDActiveStoreSvc;
170 }
171 StatusCode ActiveStoreSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)
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 }
186 
187 
189 {
191 }
common.sgkey
def sgkey(tool)
Definition: common.py:1028
ActiveStoreSvc.h
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
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ActiveStoreSvc::~ActiveStoreSvc
virtual ~ActiveStoreSvc() override
Standard Destructor.
Definition: ActiveStoreSvc.cxx:25
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
ActiveStoreSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: ActiveStoreSvc.cxx:171
initialize
void initialize()
Definition: run_EoverP.cxx:894
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
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
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
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
StoreID.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
errorcheck.h
Helpers for checking error return status codes and reporting errors.
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
hydjet.StoreGateSvc
StoreGateSvc
Definition: hydjet.minbias.pbpb5520.r12345.job.py:40
ActiveStoreSvc::setStore
void setStore(StoreGateSvc *s)
set the active store pointer: used by the event loop mgrs
Definition: ActiveStoreSvc.cxx:44
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:14
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
StoreGateSvc.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
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:96
ActiveStoreSvc::addToStore
StatusCode addToStore(CLID id, SG::DataProxy *proxy) override
Raw addition of a proxy to the store.
Definition: ActiveStoreSvc.cxx:73
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