|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #include "GaudiKernel/IIncidentSvc.h"
14 #include "Gaudi/Interfaces/IOptionsSvc.h"
15 #include "GaudiKernel/IAppMgrUI.h"
31 m_pPPSHandle(
"ProxyProviderSvc",
name),
32 m_incSvc(
"IncidentSvc",
name),
34 m_algContextSvc (
"AlgContextSvc",
name)
40 declareProperty(
"Dump",
m_DumpStore=
false,
"Dump contents at EndEvent");
41 declareProperty(
"ActivateHistory",
m_ActivateHistory=
false,
"record DataObjects history");
42 declareProperty(
"DumpArena",
m_DumpArena=
false,
"Dump Arena usage stats");
44 declareProperty(
"IncidentSvc",
m_incSvc);
56 if (m_defaultStore) m_defaultStore->release();
57 m_defaultStore = pStore;
58 if (m_defaultStore) m_defaultStore->addRef();
63 currentHiveEventSlot=pSlot;
64 if ( 0 != currentHiveEventSlot) {
65 currentHiveEventSlot->
pEvtStore->makeCurrent();
70 if (!::currentStoreGate) {
72 ISvcLocator *svcLocator = Gaudi::svcLocator();
73 SmartIF<StoreGateSvc> sg{svcLocator->service(
"StoreGateSvc/StoreGateSvc")};
74 if ( !sg.isValid() ) {
76 "Could not get \"StoreGateSvc\" to initialize currentStoreGate",
77 "StoreGateSvc", StatusCode::FAILURE);
82 return ::currentStoreGate;
87 return currentHiveEventSlot;
95 _SGVOIDCALL(commitNewDataObjects, ());
101 IOpaqueAddress* pAddress,
bool clearAddressFlag) {
102 _SGXCALL(recordAddress, (skey, pAddress, clearAddressFlag), StatusCode::FAILURE);
107 _SGXCALL(recordAddress, (pAddress, clearAddressFlag), StatusCode::FAILURE);
113 _SGXCALL(setConst, (pObject), StatusCode::FAILURE);
126 SmartIF<Gaudi::Interfaces::IOptionsSvc> pJOSvc{serviceLocator()->service(
"JobOptionsSvc")};
127 if ( !pJOSvc.isValid() ) {
128 error() <<
"Failed to retrieve JobOptionsSvc" <<
endmsg;
131 const std::string implStoreName =
name() +
"_Impl";
132 for (
const Gaudi::Details::PropertyBase*
p : getProperties()) {
133 pJOSvc->set( implStoreName +
"." +
p->name(),
p->toString() );
140 std::string implStoreFullName =
"SGImplSvc/" + implStoreName;
141 debug() <<
"trying to create store " << implStoreFullName <<
endmsg;
143 ISvcManager* pSM(
dynamic_cast<ISvcManager*
>(&*serviceLocator()));
144 if (!pSM) std::abort();
145 m_defaultStore =
dynamic_cast<SGImplSvc*
>( (pSM->createService(implStoreFullName)).
get() );
147 if (!m_defaultStore) {
148 error() <<
"Could not create store " << implStoreFullName <<
endmsg;
149 return StatusCode::FAILURE;
152 if ( m_defaultStore->sysInitialize().isSuccess() ) {
159 if (
name() ==
"StoreGateSvc") {
160 m_defaultStore->makeCurrent();
163 error() <<
"Could not initialize default store " << implStoreFullName
165 return StatusCode::FAILURE;
167 if ( !m_incSvc.retrieve().isSuccess() ) {
168 error() <<
"Could not locate IncidentSvc" <<
endmsg;
169 return StatusCode::FAILURE;
175 const int PRIORITY=100;
176 m_incSvc->addListener(
this,
"EndEvent",PRIORITY);
177 m_incSvc->addListener(
this,
"BeginEvent", PRIORITY);
179 return StatusCode::SUCCESS;
189 ISvcManager* pISM(
dynamic_cast<ISvcManager*
>(serviceLocator().
get()));
191 return StatusCode::FAILURE;
192 pISM->setPriority(
name(), pISM->getPriority(
name())+1).ignore();
193 verbose() <<
"stop: setting service priority to " << pISM->getPriority(
name())
194 <<
" so that event stores get finalized and cleared before other stores" <<
endmsg;
196 return StatusCode::SUCCESS;
200 currentStore()->handle(inc);
209 if (m_defaultStore) {
211 CHECK( m_defaultStore->finalize());
212 m_defaultStore->release();
215 printBadList (m_badRetrieves,
"retrieve()");
216 printBadList (m_badRecords,
"record()");
217 return StatusCode::SUCCESS;
224 _SGXCALL(
proxy, (pTransient), 0);
230 _SGXCALL(
proxy, (
id), 0);
244 _SGXCALL(
proxy, (
id, checkValid), 0);
251 _SGXCALL(
proxy, (
id,
key, checkValid), 0);
262 _SGXCALL(addToStore, (
id,
proxy), StatusCode::FAILURE);
288 const std::string&
key,
292 _SGXCALL(recordObject, (std::move(
obj),
key, allowMods, returnExisting),
nullptr);
297 vector<const SG::DataProxy*>
299 vector<const SG::DataProxy*> nullV;
300 _SGXCALL(proxies, (), nullV);
308 _SGXCALL(clids, (), nullV);
315 _SGXCALL(transientProxy, (
id,
key), 0);
322 _SGXCALL(accessData, (
id), 0);
328 _SGXCALL(accessData, (
id,
key), 0);
333 const std::string& keyA,
const std::string& keyB ) {
334 _SGXCALL(transientSwap, (
id, keyA, keyB),
false);
341 const void*
const raw_ptr,
342 bool allowMods,
bool resetOnly,
344 _SGXCALL(typeless_record, (
obj,
key, raw_ptr, allowMods, resetOnly, noHist), StatusCode::FAILURE);
349 DataObject*
obj,
const std::string&
key,
350 const void*
const raw_ptr,
353 const std::type_info* tinfo) {
354 _SGXCALL(typeless_overwrite, (
id,
obj,
key, raw_ptr, allowMods, noHist, tinfo), StatusCode::FAILURE);
363 _SGVOIDCALL(setStoreID,(
id));
368 bool includeAlias,
bool onlyValid)
const
370 _SGVOIDCALL(
keys,(
id, vkeys, includeAlias, onlyValid));
377 std::string nullS =
"\n>>>>>>>NO CURRENT STORE<<<<<<<\n";
378 _SGXCALL(
dump, (), nullS);
383 _SGXCALL(typeCount, (clid), -1);
390 _SGXCALL( stringToKey, (
str, clid), 0 );
395 _SGXCALL( keyToString, (
key), 0 );
400 _SGXCALL( keyToString, (
key, clid), 0 );
405 const std::string&
str,
407 _SGVOIDCALL( registerKey, (
key,
str, clidid) );
412 off_t index_offset) {
413 _SGVOIDCALL( remap_impl, (
source,
target, index_offset) );
418 sgkey_t& sgkey_out,
size_t& index_out) {
419 _SGXCALL( tryELRemap, (sgkey_in, index_in, sgkey_out, index_out),
false );
426 _SGXCALL( proxyRange, (
id,
beg,
end), StatusCode::FAILURE );
432 _SGVOIDCALL( releaseObject, (
id,
key) );
437 _SGVOIDCALL( clearProxyPayload, (
proxy) );
444 _SGXCALL(loadEventProxies, (), StatusCode::FAILURE);
452 StatusCode sc = currentStore()->clearStore(forceRemove);
455 if (
sc.isSuccess()) {
463 _SGVOIDCALL( emptyTrash, () );
468 static const InterfaceID IDStoreGateSvc(
"StoreGateSvc", 1, 0);
469 return IDStoreGateSvc;
473 if ( interfaceID().versionMatch(riid) ) {
476 else if ( IProxyDict::interfaceID().versionMatch(riid) ) {
479 else if ( IHiveStore::interfaceID().versionMatch(riid) ) {
482 else if ( IHiveStoreMgr::interfaceID().versionMatch(riid) ) {
487 return Service::queryInterface(riid, ppvInterface);
490 return StatusCode::SUCCESS;
497 ::currentStoreGate =
this;
498 _SGVOIDCALL (makeCurrent, ());
503 _SGXCALL(removeProxy, (
proxy, pTrans, forceRemove), StatusCode::FAILURE);
519 IOpaqueAddress* addr,
520 DataObject*& refpObject)
522 _SGXCALL( createObj, (cvt, addr, refpObject), StatusCode::FAILURE );
533 CLID clid,
const std::string&
key)
const
538 if (m_algContextSvc.isValid()) {
539 if (IAlgorithm*
alg = m_algContextSvc->currentAlg()) {
540 if (
alg->type() ==
"AthenaOutputStream")
return;
541 if (
alg->type() ==
"AthIncFirerAlg")
return;
542 algo =
alg->type() +
"/" +
alg->name();
556 const std::string&
what)
const
558 if (
bad.empty())
return;
559 std::vector<std::string>
lines;
561 lines.push_back (
id.fullKey() +
" [" +
id.m_algo +
"]");
564 warning() <<
"Called " <<
what <<
" on these objects in a MT store" <<
endmsg;
565 for (
const std::string&
s :
lines) {
573 std::cout << sg->dump() <<
"\n";
579 f << sg->dump() <<
"\n";
bool transientSwap(const CLID &id, const std::string &keyA, const std::string &keyB)
swap the content of 2 keys payload A indexed by keyA will now be accessed via keyB and vice versa Not...
int typeCount() const
Return the number of instances of an object of type T int i = p_store->typeCount<T>(); Note that th...
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
static void setSlot(SG::HiveEventSlot *pSlot)
set the hive event slot pointer: used by the event loop mgrs
void clearProxyPayload(SG::DataProxy *)
use to reset a proxy (clearing the data object it contains) Unlike DataProxy::reset this method corre...
static const InterfaceID & interfaceID()
Should rather be in IStoreGateSvc.h if we had one.
void SG_dump(StoreGateSvc *sg)
These are intended to be easy to call from the debugger.
virtual StatusCode stop() override
Service start.
virtual void handle(const Incident &) override final
void makeCurrent()
The current store is becoming the active store.
virtual ~StoreGateSvc() override
Standard Destructor.
bool m_ActivateHistory
property: activate the history service
bool m_DumpStore
property Dump: triggers dump() at EndEvent
void printBadList(const BadItemList &bad, const std::string &what) const
Print out a list of bad calls during finalization.
StatusCode typeless_overwrite(const CLID &id, DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool noHist=false, const std::type_info *tinfo=0)
same as typeless_record, allows to overwrite an object in memory or on disk
virtual void commitNewDataObjects() override final
Reset handles added since the last call to commit.
ServiceHandle< IProxyProviderSvc > m_pPPSHandle
property
void keys(std::vector< std::string > &vkeys, bool includeAlias=false, bool onlyValid=true) const
provide list of all StoreGate keys associated with an object.
SG::sgkey_t sgkey_t
Type of the keys.
StatusCode removeProxy(SG::DataProxy *proxy, const void *pTrans, bool forceRemove=false)
remove proxy from store, unless it is reset only.
void remap_impl(sgkey_t source, sgkey_t target, off_t index_offset)
Declare a remapping.
StatusCode proxyRange(const CLID &id, SG::ConstProxyIterator &beg, SG::ConstProxyIterator &end) const
return a range to all proxies of a given CLID
void emptyTrash()
throw away bad objects
bool m_DumpArena
DumpArena Property flag : trigger m_arena->report() at clearStore.
virtual StatusCode finalize() override
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
void releaseObject(const CLID &id, const std::string &key)
release object held by proxy, if any.
virtual StatusCode initialize() override
Service initialization.
std::string dump() const
dump objects in store.
std::unordered_set< BadListItem, DataObjID_Hasher > BadItemList
IStringPool::sgkey_t sgkey_t
ServiceHandle< IIncidentSvc > m_incSvc
property
::StatusCode StatusCode
StatusCode definition for legacy code.
static StoreGateSvc * currentStoreGate()
get current StoreGate
void setDefaultStore(SGImplSvc *pStore)
set pointer to default event store: used by ActiveStoreSvc
virtual const std::string * keyToString(sgkey_t key) const override final
Find the string corresponding to a given key.
StatusCode loadEventProxies()
load proxies at begin event
#define CHECK(...)
Evaluate an expression and check for errors.
defines an enum used by address providers to decide what kind of StoreGateSvc they are providing addr...
virtual StatusCode clearStore(bool forceRemove=false) override final
clear DataStore contents: called by the event loop mgrs
AthROOTErrorHandlerSvc * svc
virtual void registerKey(sgkey_t key, const std::string &str, CLID clidid) override final
Remember an additional mapping from key to string/CLID.
uint32_t CLID
The Class ID type.
StatusCode typeless_record(DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool resetOnly=true, bool noHist=false)
type-less recording of an object with a key, allow possibility of specifying const-access and history...
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override final
Find the key for a string/CLID pair.
std::vector< CLID > clids() const
Return all CLIDs in the store.
virtual StatusCode createObj(IConverter *cvt, IOpaqueAddress *addr, DataObject *&refpObject) override
Call converter to create an object, with locking.
void rememberBad(BadItemList &bad, CLID clid, const std::string &key) const
Remember that retrieve or record was called for a MT store.
virtual SG::DataProxy * proxy(const void *const pTransient) const override final
get proxy for a given data object address in memory
std::lock_guard< mutex_t > lock_t
Helpers for checking error return status codes and reporting errors.
StatusCode setConst(const void *pointer)
prevent downstream clients from modifying the pointed-at dobj
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
the interface through which HiveWB control StoreGate instances
Incident sent after a store is cleared.
StatusCode recordAddress(const std::string &skey, IOpaqueAddress *pAddress, bool clearAddressFlag=true)
Create a proxy object using an IOpaqueAddress and a transient key.
DataObject * accessData(const CLID &id) const
find proxy and access its data. Returns 0 to flag failure
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override final
Record an object in the store.
virtual std::vector< const SG::DataProxy * > proxies() const override final
return the list of all current proxies in store
virtual bool tryELRemap(sgkey_t sgkey_in, size_t index_in, sgkey_t &sgkey_out, size_t &index_out) override final
Test to see if the target of an ElementLink has moved.
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
void setStoreID(StoreID::type id)
set store ID. request forwarded to DataStore:
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
SG::DataProxy * transientProxy(const CLID &id, const std::string &key) const
get proxy with given id and key.
Smart pointer to manage DataObject reference counts.
virtual StatusCode addToStore(CLID id, SG::DataProxy *proxy) override final
Raw addition of a proxy to the store.
the interface that provides access to the current hive store
StoreGateSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
static SG::HiveEventSlot * currentSlot()
ProxyMap::const_iterator ConstProxyIterator
Incident sent after a store is cleared.