7#ifndef STOREGATE_STOREGATESVC_H
8#define STOREGATE_STOREGATESVC_H
15#include "GaudiKernel/Service.h"
16#include "GaudiKernel/SmartIF.h"
25#include <GaudiKernel/ClassID.h>
26#include <GaudiKernel/IMessageSvc.h>
27#include "Gaudi/Property.h"
28#include "GaudiKernel/ServiceHandle.h"
29#include "GaudiKernel/StatusCode.h"
30#include "GaudiKernel/DataObjID.h"
31#include "GaudiKernel/IAlgContextSvc.h"
50#include "GaudiKernel/IClassIDSvc.h"
59#include "GaudiKernel/IIncidentListener.h"
68 class TestHiveStoreSvc;
82struct _object;
typedef _object
PyObject;
146 template <
typename T,
typename TKEY,
typename... ARGS>
155 template <
typename T,
typename TKEY>
156 StatusCode
record(T* p2BRegistered,
const TKEY& key);
159 template <
typename T,
typename TKEY>
160 StatusCode
record(
const T* p2BRegistered,
const TKEY& key);
165 template <
typename T,
typename TKEY>
166 StatusCode
record(T* p2BRegistered,
const TKEY& key,
167 bool allowMods,
bool resetOnly=
true,
bool noHist=
false);
170 template <
typename T,
typename TKEY>
171 StatusCode
record(std::unique_ptr<T> pUnique,
const TKEY& key);
174 template <
typename T,
typename TKEY>
175 StatusCode
record(std::unique_ptr<const T> pUnique,
const TKEY& key);
179 template <
typename T,
typename TKEY>
180 StatusCode
record(std::unique_ptr<T> pUnique,
const TKEY& key,
181 bool allowMods,
bool resetOnly=
true,
bool noHist=
false);
190 template <
typename T>
194 template <
typename T>
199 template <
typename T>
204 template <
typename T>
206 template <
typename T>
210 template <
typename T,
typename TKEY>
215 template <
typename T>
216 StatusCode
retrieve(
const T*& ptr,
const std::string& key)
const;
220 template <
typename T,
typename TKEY>
225 template <
typename T>
226 StatusCode
retrieve(T*& ptr,
const std::string& key)
const;
231 template <
typename T,
class TKEY>
236 template <
typename T,
class TKEY>
238 template <
typename T,
class TKEY>
244 template <
typename T>
252 template <
typename T,
typename TKEY>
268 template <
typename T,
typename TKEY>
278 template <
typename T,
typename TKEY>
279 StatusCode
overwrite(T* p2BRegistered,
const TKEY& key);
282 template <
typename T,
typename TKEY>
284 bool allowMods,
bool noHist=
false);
288 template <
typename T,
typename TKEY>
289 StatusCode
overwrite(std::unique_ptr<T> pUnique,
const TKEY& key,
290 bool allowMods,
bool noHist=
false);
293 template <
typename T,
typename TKEY>
294 StatusCode
overwrite(std::unique_ptr<T> pUnique,
const TKEY& key);
299 bool clearAddressFlag=
true);
302 bool clearAddressFlag=
true);
305 template <
typename T,
typename TLINK>
306 StatusCode
symLink (
const T* p2BRegistered, TLINK* p2BLinked );
309 template <
typename T,
typename TLINK>
310 StatusCode
symLink (
const T* p2BRegistered,
const TLINK* p2BLinked );
313 template <KeyConcept TKEY>
317 template <
typename T,
typename TKEY,
typename AKEY>
321 template <
typename T,
typename AKEY>
328 StatusCode
setConst(
const void* pointer);
331 template <
typename T>
335 template <
typename T>
344 const std::string& keyA,
const std::string& keyB );
360 template <
typename T,
class TKEY>
362 const TKEY& requestedKey)
const;
374 template <
typename T,
class TKEY>
377 const TKEY& requestedKey)
const;
392 template <
typename T>
398 template<
typename TKEY>
404 template<
typename TKEY>
405 std::vector<CLID>
clids(
const TKEY& key )
const;
411 template <
typename T>
420 template <
typename TKEY>
428 template <
typename T,
typename TKEY>
433 template <
typename TKEY>
438 std::string
dump()
const;
452 template <
typename T>
454 keys(std::vector<std::string>& vkeys,
455 bool includeAlias =
false,
bool onlyValid =
true)
const;
465 keys(
const CLID&
id, std::vector<std::string>& vkeys,
466 bool includeAlias =
false,
bool onlyValid =
true)
const;
486 virtual StatusCode
clearStore(
bool forceRemove=
false) override final;
505 template <typename
H, typename TKEY>
509 template <typename
H, typename TKEY>
554 bool returnExisting) override final;
577 {
return this->
proxy(
id, std::string(key), checkValid); }
580 virtual std::vector<const SG::DataProxy*>
proxies()
const override final;
664 CLID clidid) override final;
695 template <class TKEY>
723 sgkey_t& sgkey_out,
size_t& index_out) override final;
738 virtual StatusCode
stop() override;
739 virtual StatusCode
finalize() override;
745 virtual
void handle(
const Incident&) override final;
763 IOpaqueAddress* addr,
764 DataObject*& refpObject) override;
778 Gaudi::Property<bool>
m_DumpStore{
this,
"Dump",
false,
"Dump contents at EndEvent"};
779 Gaudi::Property<bool>
m_ActivateHistory{
this,
"ActivateHistory",
false,
"record DataObjects history"};
780 Gaudi::Property<bool>
m_DumpArena{
this,
"DumpArena",
false,
"Dump Arena usage stats"};
831 const void*
const raw_ptr,
832 bool allowMods,
bool resetOnly=
true,
836 DataObject* obj,
const std::string& key,
837 const void*
const raw_ptr,
840 const std::type_info* tinfo=0);
843 template <
typename T,
typename TKEY>
844 StatusCode
record1(DataObject* obj, T* pObject,
const TKEY& key,
845 bool allowMods,
bool resetOnly=
true,
bool noHist=
false)
requires KeyConcept<TKEY>;
848 template <typename T, typename TKEY>
850 bool allowMods,
bool noHist=false) requires
KeyConcept<TKEY>;
879 bool forceRemove=false);
891 bool warn_nobib = true);
902 typedef std::unordered_set<BadListItem, DataObjID_Hasher>
BadItemList;
940 const std::string& key)
const;
949 const std::string& what)
const;
957 template <
class DOBJ>
959 const std::string& key,
960 bool ignoreMissing=
true)
const;
961 template <
class DOBJ>
963 const std::string& key,
964 bool ignoreMissing=
true)
const;
966 template <
class DOBJ,
class AUXSTORE>
968 const std::string& key,
969 const AUXSTORE*)
const;
970 template <
class DOBJ>
996 if ( StatusCode::SUCCESS == psg->
retrieve( obj ) )
1004 if ( StatusCode::SUCCESS == psg->
retrieve( obj, key ) )
Collection of memory allocators with a common lifetime, plus subsystem summary.
macros to associate a CLID to a type
defines an "iterator" over instances of a given type in StoreGateSvc
uint32_t CLID
The Class ID type.
Simple smart pointer for Gaudi-style refcounted objects.
A standard conforming forward iterator over items in StoreGate.
associate a data object with its VersionedKey
return type of StoreGateSvc::create.
void SG_dump(StoreGateSvc *sg)
These are intended to be easy to call from the debugger.
Maintain a mapping of strings to 64-bit ints.
Define macros for attributes used to control the static checker.
algorithm that marks for write data objects in SG
Simple smart pointer for Gaudi-style refcounted objects.
an iterator over instances of a given type in StoreGateSvc.
DataProxy provides the registry services for StoreGate.
A structure created by HiveMgrSvc and used by SGHiveStoreSvc to forward the StoreGateSvc method to a ...
Athena service for Interval Of Validity database.
Abstract interface for looking up strings/CLIDs in a pool.
the preferred mechanism to access information from the different event stores in a pileup job.
The Athena Transient Store API.
a const_iterator facade to DataHandle.
Mark that there's no associated AuxStore class.
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
Base class for VarHandle types.
The Athena Transient Store API.
StatusCode retrieve(T *&ptr) const
Retrieve the default object into a T*.
StatusCode record(T *p2BRegistered, const TKEY &key, bool allowMods, bool resetOnly=true, bool noHist=false)
Record an object with a key, allow possibility of specifying const-access.
SG::WPtr< T > create(const TKEY &key, ARGS... constructorArgs)
Create an object with one of its constructors and record it with a key.
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override final
Record an object in the store.
friend class SG::TestHiveStoreSvc
StatusCode recordAddress(const std::string &skey, CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress, bool clearAddressFlag=true)
Create a proxy object using an IOpaqueAddress and a transient key.
const T * tryConstRetrieve(const TKEY &key) const
virtual StatusCode finalize() override
StatusCode regHandle(DataHandle< H > &handle, const TKEY &key)
non-const method - will return an error
static SG::HiveEventSlot * currentSlot()
std::string dump() const
dump objects in store.
bool isSymLinked(const CLID &linkID, SG::DataProxy *dp)
virtual StatusCode createObj(IConverter *cvt, IOpaqueAddress *addr, DataObject *&refpObject) override
Call converter to create an object, with locking.
IProxyProviderSvc * proxyProviderSvc()
Return current ProxyProviderSvc.
StatusCode symLink(const T *p2BRegistered, const TLINK *p2BLinked)
make a soft link to the object T* already registered (const link)
virtual void handle(const Incident &) override final
StatusCode record(std::unique_ptr< T > pUnique, const TKEY &key, bool allowMods, bool resetOnly=true, bool noHist=false)
Record an object with a key, allow possibility of specifying const-access.
virtual void registerKey(sgkey_t key, const std::string &str, CLID clidid) override final
Remember an additional mapping from key to string/CLID.
StatusCode bind ATLAS_NOT_THREAD_SAFE(const DataHandle< T > &handle, const TKEY &key)
A "once-per-job" retrieve that binds a data object to a DataHandle, typically a data member of an Alg...
DataObject * accessData(const CLID &id) const
find proxy and access its data. Returns 0 to flag failure
StoreGateSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
SmartIF< SGImplSvc > m_defaultStore
T * tryRetrieve(const TKEY &key) const
Variant of the above which doesn't print a warning message.
void msg_update_handler(Gaudi::Details::PropertyBase &outputLevel)
callback for output level property
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
StatusCode loadEventProxies()
load proxies at begin event
friend class AthenaOutputStream
access proxyRange()
BadItemList m_badRetrieves ATLAS_THREAD_SAFE
Remember calls to retrieve and record for a MT store, so we can warn about them during finalize().
Gaudi::Property< bool > m_DumpArena
bool associateAux_impl(DOBJ *ptr, const std::string &key, const AUXSTORE *) const
StatusCode retrieve(SG::ConstIterator< T > &begin, SG::ConstIterator< T > &end) const
Retrieve all objects of type T: returns an SG::ConstIterator range.
StatusCode retrieve(T *&ptr, const std::string &key) const
Retrieve an object with "key", into a T*.
T * retrieve() const
Variant of the above which doesn't return a status code.
StoreID::type storeID() const
get store ID. request forwarded to DataStore:
StatusCode proxyRange(const CLID &id, SG::ConstProxyIterator &beg, SG::ConstProxyIterator &end) const
return a range to all proxies of a given CLID
void remap_impl(sgkey_t source, sgkey_t target, off_t index_offset)
Declare a remapping.
bool transientContains(const CLID &id, const TKEY &key) const
Look up a transient data object in TDS only by CLID.
StatusCode overwrite1(DataObject *obj, T *pObject, const TKEY &key, bool allowMods, bool noHist=false)
StatusCode symLink(const CLID id, const TKEY &key, const CLID linkid)
make a soft link to the object pointed by id/key
StatusCode overwrite(T *p2BRegistered, const TKEY &key, bool allowMods, bool noHist=false)
Record an object with a key, overwriting any existing object with same key.
void rememberBad(BadItemList &bad, CLID clid, const std::string &key) const
Remember that retrieve or record was called for a MT store.
StatusCode retrieve(T *&ptr, const TKEY &key) const
Retrieve an object with "key", into a T*.
void t2pRemove(const void *const pTrans)
forwarded to DataStore
static StoreGateSvc * currentStoreGate()
get current StoreGate
StatusCode retrieve(const T *&ptr, const std::string &key) const
Retrieve an object with "key", into a const T*.
StatusCode symLink(const T *p2BRegistered, TLINK *p2BLinked)
make a soft link to the object T* already registered (non-const)
StatusCode record(const T *p2BRegistered, const TKEY &key)
Record a const object with a key.
SG::DataProxy * setupProxy(const CLID &dataID, const std::string &gK, DataObject *pDObj, bool allowMods, bool resetOnly)
try to locate a proxy or create it if needed
std::lock_guard< mutex_t > lock_t
T * tryRetrieve() const
Variant of the above which doesn't print a warning message.
SG::DataProxy * transientProxy(const CLID &id, const std::string &key) const
get proxy with given id and key.
const T * tryConstRetrieve() const
void clearProxyPayload(SG::DataProxy *)
use to reset a proxy (clearing the data object it contains) Unlike DataProxy::reset this method corre...
StatusCode remove(const T *pObject)
Remove pObject, will remove its proxy if not reset only.
StatusCode overwrite(T *p2BRegistered, const TKEY &key)
Record an object with a key, overwriting any existing object with same key.
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
StatusCode record1(DataObject *obj, T *pObject, const TKEY &key, bool allowMods, bool resetOnly=true, bool noHist=false)
Gaudi::Property< bool > m_DumpStore
bool contains(const CLID &id, const TKEY &key) const
Look up a keyed object in TDS by CLID.
void setStoreID(StoreID::type id)
set store ID. request forwarded to DataStore:
StatusCode retrieveHighestVersion(SG::ObjectWithVersion< T > &dobjWithVersion, const TKEY &requestedKey) const
Retrieve version with highest cycle number for a given T,KEY combination If there is only one availab...
std::unordered_set< BadListItem, DataObjID_Hasher > BadItemList
IStringPool::sgkey_t sgkey_t
void rememberBadRetrieve(CLID clid, const std::string &key) const
Remember that retrieve() was called for a MT store.
int typeCount() const
Return the number of instances of an object of type T int i = p_store->typeCount<T>(); Note that th...
virtual StatusCode addToStore(CLID id, SG::DataProxy *proxy) override final
Raw addition of a proxy to the store.
CLID clid(const TKEY &key) const
Retrieve the main CLID of the object recorded in StoreGate with the given "key" WARNING: slow!
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.
StatusCode removeDataAndProxy(const T *pObject)
Remove pObject and its proxy no matter what.
friend class PileUpMergeSvc
access emptyTrash
StoreID::type m_storeID
Cache store type in the facade class.
bool associateAux_impl(DOBJ *, const std::string &, const SG::NoAuxStore *) const
virtual void commitNewDataObjects() override final
Reset handles added since the last call to commit.
StoreGateSvc & operator=(const StoreGateSvc &)
void makeCurrent()
The current store is becoming the active store.
bool associateAux(DOBJ *, const std::string &key, bool ignoreMissing=true) const
try to associate a data object to its auxiliary store if ignoreMissing=false
virtual SG::SourceID sourceID(const std::string &key="EventSelector") const override
Return the metadata source ID for the current event slot.
SGImplSvc * currentStore() const
returns pointer to the current SGImplSvc
StatusCode addSymLink(const CLID &linkid, SG::DataProxy *dp)
std::mutex mutex_t
Protect access to m_bad* members.
void emptyTrash()
throw away bad objects
bool transientContains(const TKEY &key) const
Look up a transient data object in TDS only (no Proxy lookup) returns false if object not available i...
virtual StatusCode initialize() override
Service initialization.
std::vector< CLID > clids(const TKEY &key) const
Retrieve all the CLID s (including symlinks) of the object recorded in StoreGate with the given "key"...
virtual StatusCode clearStore(bool forceRemove=false) override final
clear DataStore contents: called by the event loop mgrs
T * retrieve(const TKEY &key) const
Variant of the above which doesn't return a status code.
void printBadList(const BadItemList &bad, const std::string &what) const
Print out a list of bad calls during finalization.
ServiceHandle< IProxyProviderSvc > m_pPPSHandle
Properties.
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...
ServiceHandle< IAlgContextSvc > m_algContextSvc
StatusCode setAlias(SG::DataProxy *proxy, const std::string &aliasKey)
make an alias to a DataObject (provide valid proxy)
virtual const std::string * keyToString(sgkey_t key) const override final
Find the string corresponding to a given key.
std::unique_ptr< T > retrieveUniquePrivateCopy(const std::string &key)
EXPERTS ONLY: like readPrivateCopy this method returns your own private copy of a data object of type...
StatusCode retrieveAllVersions(std::list< SG::ObjectWithVersion< T > > &allVersions, const TKEY &requestedKey) const
Retrieve all versions of a given T,KEY combination sets allVersions, a ref to a vector of ObjectWithV...
StatusCode retrieve(const T *&ptr, const TKEY &key) const
Retrieve an object with "key", into a const T*.
StatusCode addAlias(const std::string &aliasKey, SG::DataProxy *dp)
void addAutoSymLinks(const std::string &key, CLID clid, SG::DataProxy *dp, const std::type_info *tinfo, bool warn_nobib=true)
Add automatically-made symlinks for DP.
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...
virtual sgkey_t stringToKey(const std::string &str, CLID clid) override final
Find the key for a string/CLID pair.
virtual StatusCode stop() override
Service start.
std::vector< CLID > clids() const
Return all CLIDs in the store.
StatusCode overwrite(std::unique_ptr< T > pUnique, const TKEY &key)
Record an object with a key, overwriting any existing object with same key, take ownership of the uni...
void rememberBadRecord(CLID clid, const std::string &key) const
Remember that retrieve() was called for a MT store.
std::string createKey(const CLID &dataID)
creates a key internally if none specified by client
Gaudi::Property< bool > m_ActivateHistory
virtual std::vector< const SG::DataProxy * > proxies() const override final
return the list of all current proxies in store
StatusCode setAlias(const T *p2BAliased, const AKEY &aliasKey)
make an alias to a DataObject (provide only valid pointer)
void recycle(DataObject *pBadDObj)
put a bad (unrecordable) dobj away
virtual SG::DataProxy * proxy(const void *const pTransient) const override final
get proxy for a given data object address in memory
void remap(CLID clid, const TKEY &source, const TKEY &target, off_t index_offset)
Declare a remapping.
friend class IOVDbSvc
access clearProxyPayload
StatusCode setConst(const void *pointer)
prevent downstream clients from modifying the pointed-at dobj
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override final
Get proxy given a hashed key+clid.
void keys(std::vector< std::string > &vkeys, bool includeAlias=false, bool onlyValid=true) const
provide list of all StoreGate keys associated with an object.
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
void releaseObject(const CLID &id, const std::string &key)
release object held by proxy, if any.
bool contains(const TKEY &key) const
Look up a keyed object in TDS (compare also tryRetrieve) returns false if object not available in TDS...
void setProxyProviderSvc(IProxyProviderSvc *pPPSvc)
associate ProxyProviderSvc to this store
ServiceHandle< IIncidentSvc > m_incSvc
StatusCode removeProxy(SG::DataProxy *proxy, const void *pTrans, bool forceRemove=false)
remove proxy from store, unless it is reset only.
bool associateAux(const DOBJ *, const std::string &key, bool ignoreMissing=true) const
StatusCode record(std::unique_ptr< const T > pUnique, const TKEY &key)
Record a const object with a key.
StoreGateSvc(const StoreGateSvc &)
StatusCode t2pRegister(const void *const pTrans, SG::DataProxy *const pPers)
forwarded to DataStore
virtual::IProxyDict * hiveProxyDict() override final
implements IHiveStore interface
static void setSlot(SG::HiveEventSlot *pSlot)
set the hive event slot pointer: used by the event loop mgrs
StatusCode overwrite(std::unique_ptr< T > pUnique, const TKEY &key, bool allowMods, bool noHist=false)
Record an object with a key, overwriting any existing object with same key.
StatusCode record(std::unique_ptr< T > pUnique, const TKEY &key)
Record an object with a key, take ownership of the unique_ptr obj.
StatusCode setAlias(const T *p2BAliased, const TKEY &key, const AKEY &aliasKey)
make an alias to a DataObject (provide data type and old key)
void setDefaultStore(SGImplSvc *pStore)
set pointer to default event store: used by ActiveStoreSvc
Algorithm preparing auxiliary store objects for slimming.
PyObject * recordObjectToStore(StoreGateSvc *, PyObject *, PyObject *, bool, bool, bool)
record object to storegate
void py_sg_clearProxyPayload(StoreGateSvc *self, SG::DataProxy *)
=============================================================================
ProxyMap::const_iterator ConstProxyIterator
static const T * retrieve(StoreGateSvc *psg)
static const T * retrieve(StoreGateSvc *psg, const std::string &key)
BadListItem(CLID clid, const std::string &key, const std::string &algo)