ATLAS Offline Software
ActiveStoreSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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 using namespace std;
15 
17 ActiveStoreSvc::ActiveStoreSvc(const std::string& name,ISvcLocator* svc) :
18  Service(name,svc),
19  p_activeStore(0),
20  m_storeName()
21 {
23 }
24 
25 
28 {}
29 
33 
35 
36  msg() << MSG::VERBOSE << "Initializing " << name() << endmsg;
37 
38  const bool CREATEIF(true);
39  CHECK( service(m_storeName, p_activeStore, CREATEIF) );
40  p_activeStore->makeCurrent();
41  return StatusCode::SUCCESS;
42 }
43 
46  // Now unconditional because the actual active store is thread_local
47  p_activeStore = s; // honestly, probably not necessary any more
48  s->makeCurrent();
49 }
50 
52 DataProxy*
53 ActiveStoreSvc::proxy(const void* const pTransient) const {
54  return activeStore()->proxy(pTransient);
55 }
56 
58 DataProxy*
59 ActiveStoreSvc::proxy(const CLID& id, const std::string& key) const {
60  return activeStore()->proxy(id,key);
61 }
62 
64 {
65  return activeStore()->proxy_exact (sgkey);
66 }
67 
69 vector<const SG::DataProxy*>
71  return activeStore()->proxies();
72 }
73 
74 
77 {
78  return activeStore()->addToStore (id, proxy);
79 }
80 
81 
100  const std::string& key,
101  bool allowMods,
102  bool returnExisting)
103 {
104  return activeStore()->recordObject (obj, key, allowMods, returnExisting);
105 }
106 
107 
116 sgkey_t ActiveStoreSvc::stringToKey (const std::string& str, CLID clid)
117 {
118  return activeStore()->stringToKey (str, clid);
119 }
120 
121 
129 const std::string* ActiveStoreSvc::keyToString (sgkey_t key) const
130 {
131  return activeStore()->keyToString (key);
132 }
133 
134 
144  CLID& clid) const
145 {
146  return activeStore()->keyToString (key, clid);
147 }
148 
149 
163  const std::string& str,
164  CLID clid)
165 {
166  return activeStore()->registerKey (key, str, clid);
167 }
168 
169 
170 const InterfaceID& ActiveStoreSvc::interfaceID() {
171  static const InterfaceID IDActiveStoreSvc("ActiveStoreSvc", 1, 0);
172  return IDActiveStoreSvc;
173 }
174 StatusCode ActiveStoreSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)
175 {
176  if ( interfaceID().versionMatch(riid) ) {
177  *ppvInterface = (ActiveStoreSvc*)this;
178  }
179  else if ( IProxyDict::interfaceID().versionMatch(riid) ) {
180  *ppvInterface = (IProxyDict*)this;
181  }
182  else {
183  // Interface is not directly available: try out a base class
184  return Service::queryInterface(riid, ppvInterface);
185  }
186  addRef();
187  return StatusCode::SUCCESS;
188 }
189 
190 
192 {
194 }
common.sgkey
def sgkey(tool)
Definition: common.py:1028
ActiveStoreSvc.h
ActiveStoreSvc::m_storeName
std::string m_storeName
Definition: ActiveStoreSvc.h:161
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:36
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ActiveStoreSvc::~ActiveStoreSvc
virtual ~ActiveStoreSvc() override
Standard Destructor.
Definition: ActiveStoreSvc.cxx:27
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
ActiveStoreSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: ActiveStoreSvc.cxx:174
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:63
ActiveStoreSvc::ActiveStoreSvc
ActiveStoreSvc(const std::string &name, ISvcLocator *svc)
Standard Service Constructor. sets active store to default event store.
Definition: ActiveStoreSvc.cxx:17
ActiveStoreSvc
A service that caches a pointer to the currently active store. It also implements the IProxyDict stor...
Definition: ActiveStoreSvc.h:32
ActiveStoreSvc::p_activeStore
StoreGateSvc * p_activeStore
Definition: ActiveStoreSvc.h:160
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:51
python.FakeAthena.Service
def Service(name)
Definition: FakeAthena.py:38
ActiveStoreSvc::proxies
virtual std::vector< const SG::DataProxy * > proxies() const override
return the list of all current proxies in store
Definition: ActiveStoreSvc.cxx:70
Atlas.StoreGateSvc
StoreGateSvc
Definition: Atlas.UnixStandardJob.py:25
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:129
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:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActiveStoreSvc::activeStoreOOL
StoreGateSvc * activeStoreOOL() const
Definition: ActiveStoreSvc.cxx:191
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:116
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:162
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
ActiveStoreSvc::setStore
void setStore(StoreGateSvc *s)
set the active store pointer: used by the event loop mgrs
Definition: ActiveStoreSvc.cxx:45
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:135
SG::DataProxy
Definition: DataProxy.h:44
ActiveStoreSvc::interfaceID
static const InterfaceID & interfaceID()
not really kosher: should be in IActiveStoreSvc
Definition: ActiveStoreSvc.cxx:170
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:99
ActiveStoreSvc::addToStore
StatusCode addToStore(CLID id, SG::DataProxy *proxy) override
Raw addition of a proxy to the store.
Definition: ActiveStoreSvc.cxx:76
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:53