ATLAS Offline Software
Loading...
Searching...
No Matches
SGImplSvc Class Referencefinal

The Athena Transient Store API. More...

#include <SGImplSvc.h>

Inheritance diagram for SGImplSvc:

Public Member Functions

 SGImplSvc (const SGImplSvc &)=delete
SGImplSvc & operator= (const SGImplSvc &)=delete
Basic Client Interface: data object access
StatusCode retrieve (CLID clid, SG::detail::IteratorBase &cibegin, SG::detail::IteratorBase &ciend) const
 Retrieve all objects of type T: returns an SG::ConstIterator range.
Advanced Client Interface: data object registration
StatusCode recordAddress (const std::string &skey, CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress, bool clearAddressFlag=true, const std::vector< CLID > &bases={})
 Create a proxy object using an IOpaqueAddress and a transient key.
StatusCode recordAddress (CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress, bool clearAddressFlag=true, const std::vector< CLID > &bases={})
 Create a proxy object using an IOpaqueAddress.
StatusCode symLink (const void *p2BRegistered, CLID linkID)
 make a soft link to the object T* already registered
StatusCode symLink (const CLID id, const std::string &key, const CLID linkid)
 make a soft link to the object pointed by id/key
StatusCode setAlias (CLID clid, const std::string &key, const std::string &aliasKey)
 make an alias to a DataObject (provide data type and old key)
StatusCode setAlias (const void *p2BAliased, const std::string &aliasKey)
 make an alias to a DataObject (provide only valid pointer)
StatusCode setAlias (SG::DataProxy *proxy, const std::string &aliasKey)
 make an alias to a DataObject (provide valid proxy)
StatusCode setConst (const void *pointer)
 prevent downstream clients from modifying the pointed-at dobj
StatusCode remove (const void *pObject)
 Remove pObject, will remove its proxy if not reset only.
StatusCode removeDataAndProxy (const void *pObject)
 Remove pObject and its proxy no matter what.
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 Note that the swap is invalidated at event boundaries and/or when somebody clear the store.
Advanced Client Interface: data object access
DataObject * typeless_retrievePrivateCopy (const CLID clid, const std::string &key)
CLID clid (const std::string &key) const
 Retrieve the main CLID of the object recorded in StoreGate with the given "key" WARNING: slow!
std::vector< CLID > clids (const std::string &key) const
 Retrieve all the CLID s (including symlinks) of the object recorded in StoreGate with the given "key" WARNING: slow!
int typeCount (const CLID &id) const
 Return the number of instances of type T (input CLID).
bool contains (const CLID id, const std::string &key) const
 Look up a keyed object in TDS by CLID.
bool transientContains (const CLID id, const std::string &key) const
 Look up a transient data object in TDS only by CLID.
std::string dump () const
 dump objects in store.
void setStoreID (StoreID::type id)
 set store ID. request forwarded to DataStore:
virtual StoreID::type storeID () const override
 get store ID. request forwarded to DataStore:
void keys (const CLID &id, std::vector< std::string > &vkeys, bool includeAlias=false, bool onlyValid=true)
 provide list of all StoreGate keys associated with an object.
virtual::IProxyDict * hiveProxyDict () override final
 implements IHiveStore interface for compat with Hive
virtual SG::DataProxy * proxy (const void *const pTransient) const override final
 get proxy for a given data object address in memory
SG::DataProxy * proxy (const CLID &id) const
 get default proxy with given id.
virtual SG::DataProxy * proxy (const CLID &id, const std::string &key) const override final
 get proxy with given id and key. Returns 0 to flag failure
SG::DataProxy * proxy (const CLID &id, const char *key) const
 get proxy with given id and key.
virtual StatusCode addToStore (CLID id, SG::DataProxy *proxy) override final
 Raw addition of a proxy to the store.
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 SG::DataProxy * proxy_exact (SG::sgkey_t sgkey) const override final
 Get proxy given a hashed key+clid.
more proxy dictionary functionality
SG::DataProxy * proxy (const CLID &id, bool checkValid) const
 get default proxy with given id, optionally checking validity.
SG::DataProxy * proxy (const CLID &id, const std::string &key, bool checkValid) const
 get proxy with given id and key, optionally checking validity.
SG::DataProxy * proxy (const CLID &id, const char *key, bool checkValid) const
 get proxy with given id and key, optionally checking validity.
virtual std::vector< const SG::DataProxy * > proxies () const override final
 return the list of all current proxies in store
std::vector< CLID > clids () const
 Return all CLIDs in the store.
SG::DataProxy * transientProxy (const CLID &id, const std::string &key) const
 get proxy with given id and key.
DataObject * accessData (const CLID &id) const
 find proxy and access its data. Returns 0 to flag failure
DataObject * accessData (const CLID &id, const std::string &key) const
 find proxy and access its data. Returns 0 to flag failure
void setProxyProviderSvc (IProxyProviderSvc *pPPSvc)
 associate ProxyProviderSvc to this store
IProxyProviderSvc * proxyProviderSvc ()
 Return current ProxyProviderSvc.
virtual SG::SourceID sourceID (const std::string &key="EventSelector") const override
 Return the metadata source ID for the current event slot.
ElementLink remapping
void remap_impl (sgkey_t source, sgkey_t target, off_t index_offset)
 Declare a remapping.
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.
Gaudi Standard Service constructors/destructors
 SGImplSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
virtual ~SGImplSvc () override final
 Standard Destructor.
Gaudi IService implementation
virtual StatusCode initialize () override final
 Service initialization.
virtual StatusCode reinitialize () override final
 Service reinitialization.
virtual StatusCode start () override final
 Service start.
virtual StatusCode stop () override final
 Service stop.
virtual StatusCode finalize () override final
 Service finalization.
Gaudi IIncidentListener implementation
virtual void handle (const Incident &) override final
 triggered by Incident service
StatusCode loadEventProxies ()
 load proxies at begin event

String <-> int key conversions. IStringPool implementation

typedef IStringPool::sgkey_t sgkey_t
virtual sgkey_t stringToKey (const std::string &str, CLID clid) override final
 Find the key for a string/CLID pair.
virtual const std::string * keyToString (sgkey_t key) const override final
 Find the string corresponding to a given key.
virtual const std::string * keyToString (sgkey_t key, CLID &clid) const override final
 Find the string and CLID corresponding to a given key.
virtual void registerKey (sgkey_t key, const std::string &str, CLID clidid) override final
 Remember an additional mapping from key to string/CLID.
bool mergeStringPool (const SGImplSvc &other)
 Merge the string pool from another store into this one.

IHiveStoreMgr implementation

typedef std::recursive_mutex mutex_t
typedef std::lock_guard< mutex_t > lock_t
class IOVDbSvc
 access clearProxyPayload
class IOVSvcTool
class StoreGateSvc
class SG::VarHandleBase
 access typeless_record
class ActiveStoreSvc
PyObject * AthenaInternal::recordObjectToStore (StoreGateSvc *, PyObject *, PyObject *, bool, bool, bool)
void AthenaInternal::py_sg_clearProxyPayload (StoreGateSvc *, SG::DataProxy *)
ServiceHandle< IClassIDSvc > m_pCLIDSvc
ServiceHandle< IConversionSvc > m_pDataLoader
ServiceHandle< IProxyProviderSvc > m_pPPSHandle
IProxyProviderSvc * m_pPPS
ServiceHandle< IHistorySvc > m_pHistorySvc
SG::DataStore * m_pStore
std::list< DataObject * > m_trash
 The Recycle Bin.
ServiceHandle< IIncidentSvc > m_pIncSvc
 property
bool m_DumpStore
 Dump Property flag: triggers dump() at EndEvent.
bool m_ActivateHistory
 Activate the history service.
bool m_DumpArena
 DumpArena Property flag : trigger m_arena->report() at clearStore.
StringArrayProperty m_folderNameList
 FolderNameList Property.
ServiceHandle< IIOVSvc > m_pIOVSvc
 get the IOVSvc "just in time" (breaks recursion at initialize)
bool m_storeLoaded
 FIXME hack needed by loadEventProxies.
SG::StringPool m_stringpool
SG::RemapImpl * m_remap_impl
SG::Arena m_arena
 Allocation arena to associate with this store.
int m_slotNumber
 The Hive slot number for this store, or -1 if this isn't a Hive store.
int m_numSlots
 The total number of slots. 1 if this isn't a Hive store.
std::map< std::thread::id, std::vector< IResetable * > > m_newBoundHandles
 Keep track of proxies bound since the last call to commitNewDataObjects or clearStore.
mutex_t m_mutex
mutex_t m_remapMutex
mutex_t m_stringPoolMutex
virtual StatusCode clearStore (bool forceRemove=false) override final
 clear DataStore contents: called by the event loop mgrs
virtual void commitNewDataObjects () override final
 Reset handles added since the last call to commit.
void setSlotNumber (int slot, int numSlots)
 Set the Hive slot number for this store.
virtual void boundHandle (IResetable *handle) override final
 Tell the store that a proxy has been bound to a handle.
virtual void unboundHandle (IResetable *handle) override final
 Tell the store that a handle has been unbound from a proxy.
virtual StatusCode createObj (IConverter *cvt, IOpaqueAddress *addr, DataObject *&refpObject) override
 Call converter to create an object, with locking.
StatusCode record_HistObj (const CLID &id, const std::string &key, const std::string &store, bool allowMods, bool resetOnly=true)
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 record
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
StatusCode typeless_record (DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool resetOnly, bool noHist, const std::type_info *tinfo)
StatusCode typeless_record (DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool resetOnly, bool noHist, const std::type_info *tinfo, SG::DataProxy **proxy_ret, bool noOverwrite)
SG::DataProxy * record_impl (DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool resetOnly, bool allowOverwrite, const std::type_info *tinfo)
 real recording of an object with a key, allow possibility of specifying const-access
void releaseObject (const CLID &id, const std::string &key)
 release object held by proxy, if any.
void clearProxyPayload (SG::DataProxy *)
 use to reset a proxy (clearing the data object it contains) Unlike DataProxy::reset this method correctly updates SGSvc internals
SG::DataProxy * locatePersistent (const SG::TransientAddress *tAddr, bool checkValid=false) const
SG::DataStore * store ()
const SG::DataStore * store () const
bool isSymLinked (const CLID &linkID, SG::DataProxy *dp)
StatusCode addSymLink (const CLID &linkid, SG::DataProxy *dp)
StatusCode addAlias (const std::string &aliasKey, SG::DataProxy *dp)
std::string createKey (const CLID &dataID)
 creates a key internally if none specified by client
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
void recycle (DataObject *pBadDObj)
 put a bad (unrecordable) dobj away
void emptyTrash ()
 throw away bad objects
StatusCode removeProxy (SG::DataProxy *proxy, const void *pTrans, bool forceRemove=false)
 remove proxy from store, unless it is reset only.
StatusCode t2pRegister (const void *const pTrans, SG::DataProxy *const pPers)
 forwarded to DataStore
void t2pRemove (const void *const pTrans)
 forwarded to DataStore
void msg_update_handler (Gaudi::Details::PropertyBase &outputLevel)
 callback for output level property
bool associateAux_impl (SG::AuxVectorBase *ptr, const std::string &key, CLID auxclid) const
bool associateAux_impl (SG::AuxElement *ptr, const std::string &key, CLID auxclid) const
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.
void makeCurrent ()
 The current store is becoming the active store.

Detailed Description

The Athena Transient Store API.

Parameters
Dumpproperty (default false): set to call dump() at EndEvent
FolderNameListproperty (default ""): data folders to be created in this store
Author
ATLAS Collaboration

Definition at line 103 of file SGImplSvc.h.

Member Typedef Documentation

◆ lock_t

typedef std::lock_guard<mutex_t> SGImplSvc::lock_t
private

Definition at line 686 of file SGImplSvc.h.

◆ mutex_t

typedef std::recursive_mutex SGImplSvc::mutex_t
private

Definition at line 685 of file SGImplSvc.h.

◆ sgkey_t

Definition at line 336 of file SGImplSvc.h.

Constructor & Destructor Documentation

◆ SGImplSvc() [1/2]

SGImplSvc::SGImplSvc ( const SGImplSvc & )
delete

◆ SGImplSvc() [2/2]

SGImplSvc::SGImplSvc ( const std::string & name,
ISvcLocator * svc )

Standard Constructor.

Definition at line 103 of file SGImplSvc.cxx.

104 : base_class(name, svc),
105 m_pCLIDSvc("ClassIDSvc", name),
106 m_pDataLoader("EventPersistencySvc", name),
107 m_pPPSHandle("ProxyProviderSvc", name),
108 m_pPPS(nullptr),
109 m_pHistorySvc("HistorySvc", name),
110 m_pStore(new DataStore(*this)),
111 m_pIncSvc("IncidentSvc", name),
112 m_DumpStore(false),
113 m_ActivateHistory(false),
114 m_DumpArena(false),
115 m_pIOVSvc("IOVSvc", name),
116 m_storeLoaded(false),
117 m_remap_impl (new SG::RemapImpl),
118 m_arena (name),
119 m_slotNumber(-1),
120 m_numSlots(1)
121{
122 //our properties
123 declareProperty("ProxyProviderSvc", m_pPPSHandle);
124 declareProperty("Dump", m_DumpStore);
125 declareProperty("ActivateHistory", m_ActivateHistory);
126 declareProperty("DumpArena", m_DumpArena);
127 //StoreGateSvc properties
128 declareProperty("IncidentSvc", m_pIncSvc);
129 //add handler for Service base class property
130 m_outputLevel.declareUpdateHandler(&SGImplSvc::msg_update_handler, this);
131
132 SG::ArenaHeader* header = SG::ArenaHeader::defaultHeader();
133 header->addArena (&m_arena);
134}
SG::RemapImpl * m_remap_impl
Definition SGImplSvc.h:668
int m_slotNumber
The Hive slot number for this store, or -1 if this isn't a Hive store.
Definition SGImplSvc.h:674
ServiceHandle< IProxyProviderSvc > m_pPPSHandle
Definition SGImplSvc.h:643
bool m_DumpStore
Dump Property flag: triggers dump() at EndEvent.
Definition SGImplSvc.h:654
bool m_ActivateHistory
Activate the history service.
Definition SGImplSvc.h:655
void msg_update_handler(Gaudi::Details::PropertyBase &outputLevel)
callback for output level property
bool m_DumpArena
DumpArena Property flag : trigger m_arena->report() at clearStore.
Definition SGImplSvc.h:656
SG::Arena m_arena
Allocation arena to associate with this store.
Definition SGImplSvc.h:671
IProxyProviderSvc * m_pPPS
Definition SGImplSvc.h:646
SG::DataStore * m_pStore
Definition SGImplSvc.h:650
ServiceHandle< IHistorySvc > m_pHistorySvc
Definition SGImplSvc.h:648
ServiceHandle< IIOVSvc > m_pIOVSvc
get the IOVSvc "just in time" (breaks recursion at initialize)
Definition SGImplSvc.h:662
int m_numSlots
The total number of slots. 1 if this isn't a Hive store.
Definition SGImplSvc.h:677
bool m_storeLoaded
FIXME hack needed by loadEventProxies.
Definition SGImplSvc.h:664
ServiceHandle< IClassIDSvc > m_pCLIDSvc
Definition SGImplSvc.h:640
ServiceHandle< IIncidentSvc > m_pIncSvc
property
Definition SGImplSvc.h:653
ServiceHandle< IConversionSvc > m_pDataLoader
Definition SGImplSvc.h:641
static ArenaHeader * defaultHeader()
Return the global default Header instance.

◆ ~SGImplSvc()

SGImplSvc::~SGImplSvc ( )
finaloverridevirtual

Standard Destructor.

Definition at line 138 of file SGImplSvc.cxx.

138 {
139 SG::ArenaHeader* header = SG::ArenaHeader::defaultHeader();
140 header->delArena (&m_arena);
141
142 delete m_pStore;
143 delete m_remap_impl;
144}

Member Function Documentation

◆ accessData() [1/2]

DataObject * SGImplSvc::accessData ( const CLID & id) const

find proxy and access its data. Returns 0 to flag failure

Definition at line 947 of file SGImplSvc.cxx.

948{
950 DataProxy* theProxy(proxy(id, true));
951 return (0 == theProxy) ? 0 : theProxy->accessData();
952}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
virtual SG::DataProxy * proxy(const void *const pTransient) const override final
get proxy for a given data object address in memory
mutex_t m_mutex
Definition SGImplSvc.h:687
std::lock_guard< mutex_t > lock_t
Definition SGImplSvc.h:686

◆ accessData() [2/2]

DataObject * SGImplSvc::accessData ( const CLID & id,
const std::string & key ) const

find proxy and access its data. Returns 0 to flag failure

Definition at line 955 of file SGImplSvc.cxx.

956{
958 DataProxy* theProxy(proxy(id, key, true));
959 return (0 == theProxy) ? 0 : theProxy->accessData();
960}

◆ addAlias()

StatusCode SGImplSvc::addAlias ( const std::string & aliasKey,
SG::DataProxy * dp )
private

Definition at line 659 of file SGImplSvc.cxx.

660{
661 if (0 == proxy) {
662 SG_MSG_WARNING ("addAlias: no target DataProxy given, Cannot alias to a non-existing object");
663 return StatusCode::FAILURE;
664 }
665
666 // add key to proxy and to ProxyStore
667 return m_pStore->addAlias(aliasKey, proxy);
668}
#define SG_MSG_WARNING(x,...)

◆ addAutoSymLinks()

void SGImplSvc::addAutoSymLinks ( const std::string & key,
CLID clid,
SG::DataProxy * dp,
const std::type_info * tinfo,
bool warn_nobib = true )
private

Add automatically-made symlinks for DP.

Definition at line 1515 of file SGImplSvc.cxx.

1520{
1521 // Automatically make all legal base class symlinks
1522 if (!tinfo) {
1524 }
1525 const SG::BaseInfoBase* bib = nullptr;
1526 if (tinfo) {
1527 bib = SG::BaseInfoBase::find (*tinfo);
1528 }
1529 if (!bib) {
1530 // Could succeed where the previous fails if clid for DataVector<T>
1531 // but tinfo is for ConstDataVector<DataVector<T> >.
1533 }
1534 if ( bib ) {
1535 const std::vector<CLID>& bases = bib->get_bases();
1536 for ( std::size_t i = 0, iMax = bases.size(); i < iMax; ++i ) {
1537 if ( bases[i] != clid ) {
1538 if ( addSymLink( bases[i], dp ).isSuccess() ) {
1539 // register with t2p
1540 if (dp->object())
1541 this->t2pRegister( SG::DataProxy_cast( dp, bases[i] ), dp ).ignore();
1542 }
1543 else {
1544 SG_MSG_WARNING ("record_impl: Doing auto-symlinks for object"
1545 " with CLID {} and SG key {}:"
1546 " Proxy already set for base CLID {}; not making auto-symlink.",
1547 clid, key, bases[i]);
1548 }
1549 }
1550 }
1551
1552 // Handle copy conversions.
1553 {
1554 for (CLID copy_clid : bib->get_copy_conversions()) {
1555 if (m_pStore->addSymLink (copy_clid, dp).isFailure()) {
1556 SG_MSG_WARNING ("record_impl: Doing auto-symlinks for object"
1557 " with CLID {} and SG key {}:"
1558 " Proxy already set for copy-conversion CLID {}; not making auto-symlink.",
1559 clid, key, copy_clid);
1560 }
1561 }
1562 }
1563 }
1564 else {
1565 if (warn_nobib) {
1566 SG_MSG_WARNING ("record_impl: Could not find suitable SG::BaseInfoBase for CLID [{}] ({}) !\t"
1567 "No auto-symlink established !",
1568 clid, key);
1569 }
1570 }
1571}
uint32_t CLID
The Class ID type.
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
StatusCode t2pRegister(const void *const pTrans, SG::DataProxy *const pPers)
forwarded to DataStore
CLID clid(const std::string &key) const
Retrieve the main CLID of the object recorded in StoreGate with the given "key" WARNING: slow!
StatusCode addSymLink(const CLID &linkid, SG::DataProxy *dp)
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
Definition BaseInfo.cxx:587
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Definition BaseInfo.cxx:307
std::vector< CLID > get_copy_conversions() const
Return known copy conversions.
Definition BaseInfo.cxx:470
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies

◆ addSymLink()

StatusCode SGImplSvc::addSymLink ( const CLID & linkid,
SG::DataProxy * dp )
private

Definition at line 582 of file SGImplSvc.cxx.

583{
584 if (0 == dp) {
585 SG_MSG_WARNING ("addSymLink: no target DataProxy found. Sorry, can't link to a non-existing data object");
586 return StatusCode::FAILURE;
587 }
588 StatusCode sc = m_pStore->addSymLink(linkid, dp);
589
590 // If the symlink is a derived->base conversion, then we may have
591 // a different transient pointer for the symlink.
592 if (sc.isSuccess() && dp->object()) {
593 void* baseptr = SG::DataProxy_cast (dp, linkid);
594 if (baseptr)
595 this->t2pRegister (baseptr, dp).ignore();
596 }
597 return sc;
598}
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ addToStore()

StatusCode SGImplSvc::addToStore ( CLID id,
SG::DataProxy * proxy )
finaloverridevirtual

Raw addition of a proxy to the store.

Parameters
idCLID of object being added.
proxyproxy to add.

Definition at line 772 of file SGImplSvc.cxx.

773{
775 return m_pStore->addToStore (id, proxy);
776}

◆ associateAux_impl() [1/2]

bool SGImplSvc::associateAux_impl ( SG::AuxElement * ptr,
const std::string & key,
CLID auxclid ) const
private

Definition at line 1750 of file SGImplSvc.cxx.

1753{
1755 SG_MSG_VERBOSE("called associateAux_impl for key " + key);
1756 // no Aux store set yet
1757 if (!ptr->hasStore()) {
1758 SG::DataProxy* dp = proxy (auxclid, key + "Aux.", true);
1759 if (dp) {
1760 if (!dp->isConst()) {
1761 SG::IAuxStore* pAux = SG::DataProxy_cast<SG::IAuxStore> (dp);
1762 if (pAux) {
1763 ptr->setStore (pAux);
1764 return true;
1765 }
1766 }
1767
1768 const SG::IConstAuxStore* pAux = SG::DataProxy_cast<SG::IConstAuxStore> (dp);
1769 if (pAux) {
1770 ptr->setStore (pAux);
1771 return true;
1772 }
1773 }
1774 }
1775 return false;
1776}
#define SG_MSG_VERBOSE(x,...)
void * ptr(T *p)
Definition SGImplSvc.cxx:75

◆ associateAux_impl() [2/2]

bool SGImplSvc::associateAux_impl ( SG::AuxVectorBase * ptr,
const std::string & key,
CLID auxclid ) const
private

Definition at line 1715 of file SGImplSvc.cxx.

1718{
1719 // If we already have the aux store (as should usually be the case), return
1720 // without taking out the SG lock. Otherwise, we can deadlock
1721 // if another thread is also trying to dereference a link to the aux store.
1722 // (Should _not_ be holding the SG lock when dereferencing the link!)
1723 if (ptr->hasStore()) return true;
1724
1726 SG_MSG_VERBOSE("called associateAux_impl for key " + key);
1727 // no Aux store set yet
1728 if (!ptr->hasStore()) {
1729 SG::DataProxy* dp = proxy (auxclid, key + "Aux.", true);
1730 if (dp) {
1731 if (!dp->isConst()) {
1732 SG::IAuxStore* pAux = SG::DataProxy_cast<SG::IAuxStore> (dp);
1733 if (pAux) {
1734 ptr->setStore (pAux);
1735 return true;
1736 }
1737 }
1738
1739 const SG::IConstAuxStore* pAux = SG::DataProxy_cast<SG::IConstAuxStore> (dp);
1740 if (pAux) {
1741 ptr->setStore (pAux);
1742 return true;
1743 }
1744 }
1745 }
1746 return false;
1747}

◆ boundHandle()

void SGImplSvc::boundHandle ( IResetable * handle)
finaloverridevirtual

Tell the store that a proxy has been bound to a handle.

Parameters
proxyThe proxy that was bound. The default implementation does nothing.

Definition at line 1592 of file SGImplSvc.cxx.

1593{
1594 m_newBoundHandles[std::this_thread::get_id()].push_back (handle);
1595}
virtual void handle(const Incident &) override final
triggered by Incident service
std::map< std::thread::id, std::vector< IResetable * > > m_newBoundHandles
Keep track of proxies bound since the last call to commitNewDataObjects or clearStore.
Definition SGImplSvc.h:683

◆ clearProxyPayload()

void SGImplSvc::clearProxyPayload ( SG::DataProxy * dp)
private

use to reset a proxy (clearing the data object it contains) Unlike DataProxy::reset this method correctly updates SGSvc internals

Definition at line 1402 of file SGImplSvc.cxx.

1402 {
1404
1405 // Remove transient pointer entries for this proxy.
1406 // But do that only if the proxy has a valid object.
1407 // Otherwise, we could trigger I/O --- which we don't want since it's useless
1408 // (we'd just destroy the object immediately). In some cases it can also
1409 // lead to a deadlock (see ATR-24482).
1410 if (dp->isValidObject()) {
1411 SG::DataProxy::CLIDCont_t clids = dp->transientID();
1412 SG::DataProxy::CLIDCont_t::const_iterator i(clids.begin()), e(clids.end());
1413 while (i != e) {
1414 t2pRemove(SG::DataProxy_cast (dp, *i++));
1415 }
1416 }
1417
1418 bool hard_reset = (m_numSlots > 1);
1419 dp->reset (hard_reset);
1420}
std::vector< CLID > clids(const std::string &key) const
Retrieve all the CLID s (including symlinks) of the object recorded in StoreGate with the given "key"...
void t2pRemove(const void *const pTrans)
forwarded to DataStore
TransientAddress::TransientClidSet CLIDCont_t
Definition DataProxy.h:54

◆ clearStore()

StatusCode SGImplSvc::clearStore ( bool forceRemove = false)
finaloverridevirtual

clear DataStore contents: called by the event loop mgrs

Parameters
forceRemoveif true remove proxies ignoring their resetOnly flag

Definition at line 267 of file SGImplSvc.cxx.

268{
269#ifdef DEBUG_SGIMPL
270 dbg::print(stderr, "SGImplSvc::clearStore(forceRemove={}) on {}\n", forceRemove, name());
271#endif
272 {
273 if (m_DumpArena) {
274 std::ostringstream s;
275 m_arena.report(s);
276 SG_MSG_INFO ("Report for Arena: {}\n{}", m_arena.name(), s.str());
277 }
278 }
279 {
281 emptyTrash();
282 for (auto& p : m_newBoundHandles)
283 p.second.clear();
284 assert(m_pStore);
285 SG_MSG_DEBUG ("Clearing store with forceRemove={}", forceRemove);
286 bool hard_reset = (m_numSlots > 1);
287 m_pStore->clearStore(forceRemove, hard_reset, &msgStream(MSG::DEBUG));
288 m_storeLoaded=false; //FIXME hack needed by loadEventProxies
289 }
290 {
291 lock_t remap_lock (m_remapMutex);
292 m_remap_impl->m_remaps.clear();
293 m_arena.reset();
294 }
295
296 return StatusCode::SUCCESS;
297}
#define SG_MSG_DEBUG(x,...)
#define SG_MSG_INFO(x,...)
mutex_t m_remapMutex
Definition SGImplSvc.h:688
void emptyTrash()
throw away bad objects
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition SGImplSvc.cxx:71

◆ clid()

CLID SGImplSvc::clid ( const std::string & key) const

Retrieve the main CLID of the object recorded in StoreGate with the given "key" WARNING: slow!

Definition at line 1481 of file SGImplSvc.cxx.

1482{
1485 store()->tRange(s_iter, s_end).ignore();
1486
1487 for ( ; s_iter != s_end; ++s_iter ) {
1488 if ( s_iter->second.find( key ) != s_iter->second.end() ) {
1489 return s_iter->first;
1490 }
1491 }
1492
1493 return CLID_NULL;
1494}
SG::DataStore * store()
StoreMap::const_iterator ConstStoreIterator
StatusCode tRange(ConstStoreIterator &f, ConstStoreIterator &e) const
Return an iterator over the StoreMap:

◆ clids() [1/2]

std::vector< CLID > SGImplSvc::clids ( ) const

Return all CLIDs in the store.

Definition at line 918 of file SGImplSvc.cxx.

919{
921
922 using std::distance;
923 DataStore::ConstStoreIterator s_iter, s_end;
924 store()->tRange(s_iter, s_end).ignore();
925
926 std::vector<CLID> clids;
927 clids.reserve( distance( s_iter, s_end ) );
928
929 for (; s_iter != s_end; ++s_iter ) {
930 const CLID id = s_iter->first;
931 clids.push_back (id);
932 }
933
934 return clids;
935}
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space

◆ clids() [2/2]

std::vector< CLID > SGImplSvc::clids ( const std::string & key) const

Retrieve all the CLID s (including symlinks) of the object recorded in StoreGate with the given "key" WARNING: slow!

Definition at line 1497 of file SGImplSvc.cxx.

1498{
1500 std::vector<CLID> clids;
1502 store()->tRange(s_iter, s_end).ignore();
1503
1504 for ( ; s_iter != s_end; ++s_iter ) {
1505 if ( s_iter->second.find( key ) != s_iter->second.end() ) {
1506 clids.push_back(s_iter->first);
1507 }
1508 }
1509
1510 return clids;
1511}

◆ commitNewDataObjects()

void SGImplSvc::commitNewDataObjects ( )
finaloverridevirtual

Reset handles added since the last call to commit.

Definition at line 1574 of file SGImplSvc.cxx.

1574 {
1576
1577 // Reset handles added since the last call to commit.
1578 bool hard_reset = (m_numSlots > 1);
1579 std::vector<IResetable*> handles;
1580 m_newBoundHandles[std::this_thread::get_id()].swap (handles);
1581 for (IResetable* h : handles)
1582 h->reset (hard_reset);
1583}

◆ contains()

bool SGImplSvc::contains ( const CLID id,
const std::string & key ) const

Look up a keyed object in TDS by CLID.

returns false if object not available in TDS or persistent stores Usage: if (!p_store->contains(FooID, "fooKey")) { ... }

Definition at line 678 of file SGImplSvc.cxx.

679{
680 try {
681 return (0 != proxy(id, key, true));
682 } catch(...) { return false; }
683}

◆ createKey()

string SGImplSvc::createKey ( const CLID & dataID)
private

creates a key internally if none specified by client

Definition at line 261 of file SGImplSvc.cxx.

262{
263 return std::to_string(m_pStore->typeCount(id) + 1);
264}

◆ createObj()

StatusCode SGImplSvc::createObj ( IConverter * cvt,
IOpaqueAddress * addr,
DataObject *& refpObject )
overridevirtual

Call converter to create an object, with locking.

Parameters
cvtThe converter to call.
addrOpaque address information for the object to create.
refpObjectReference to location of the pointer of the created object.

This calls the createObj method on cvt to create the referenced transient object, locking the store during the call.

Definition at line 1635 of file SGImplSvc.cxx.

1638{
1639 // This lock was here originally, but is probably not really needed ---
1640 // both DataProxy and the I/O components have their own locks.
1641 // Further, this was observed to cause deadlocks for the detector store,
1642 // and would in general be expected to be a contention issue.
1643 //lock_t lock (m_mutex);
1644 return cvt->createObj (addr, refpObject);
1645}

◆ dump()

string SGImplSvc::dump ( ) const

dump objects in store.

request forwarded to DataStore this is triggered at EndEvent setting the Dump property to true

Definition at line 504 of file SGImplSvc.cxx.

505{
507 auto out_buffer = std::string{};
508 auto out = std::back_inserter(out_buffer);
509 const std::string me = name();
510 std::format_to(out, "{}: <<<<<<<<<<<<<<<<< Data Store Dump >>>>>>>>>>>>>>> \n", me);
511 std::format_to(out, "{}: SGImplSvc()::dump() which is {} \n", me, m_storeLoaded ? "LOADED" : "NOT LOADED");
512
513 DataStore::ConstStoreIterator s_iter, s_end;
514 store()->tRange(s_iter, s_end).ignore();
515
516 for (; s_iter != s_end; ++s_iter)
517 {
518
519 CLID id = s_iter->first;
520 int nProxy = store()->typeCount(id);
521 std::string tname;
522 m_pCLIDSvc->getTypeNameOfID(id, tname).ignore();
523 std::format_to(out, "{}: Found {} {} for ClassID {} ({}): \n", me, nProxy, ((nProxy == 1) ? "proxy" : "proxies"), id, tname);
524
525 // loop over each type:
526 SG::ConstProxyIterator p_iter = (s_iter->second).begin();
527 SG::ConstProxyIterator p_end = (s_iter->second).end();
528
529 while (p_iter != p_end) {
530 const DataProxy& dp(*p_iter->second);
531 std::format_to(out, "{}: flags: ({:7s}, {:8s}, {:6s}) --- data: {:10p} --- key: {}\n", me,
532 (dp.isValid() ? "valid" : "INVALID"),
533 (dp.isConst() ? "locked" : "UNLOCKED"),
534 (dp.isResetOnly() ? "reset" : "DELETE"),
535 dbg::ptr(dp.object()), p_iter->first);
536 ++p_iter;
537 }
538 }
539 std::format_to(out, "{}: <<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>> \n", me);
540 return out_buffer;
541}
int typeCount(const CLID &id) const
Count number of object of a given type in store.
ProxyMap::const_iterator ConstProxyIterator
Definition ProxyMap.h:24

◆ emptyTrash()

void SGImplSvc::emptyTrash ( )
private

throw away bad objects

Definition at line 1252 of file SGImplSvc.cxx.

1252 {
1254 while (!m_trash.empty()) {
1255 m_trash.front()->release(); //delete the bad data object
1256 m_trash.pop_front(); //remove pointer from list
1257 }
1258}
std::list< DataObject * > m_trash
The Recycle Bin.
Definition SGImplSvc.h:651

◆ finalize()

StatusCode SGImplSvc::finalize ( )
finaloverridevirtual

Service finalization.

Definition at line 300 of file SGImplSvc.cxx.

300 {
301 SG_MSG_VERBOSE ("Finalizing {}", name());
302
303 // Incident service may not work in finalize.
304 // Clear this, so that we won't try to send an incident from clearStore.
305 (m_pIncSvc.release()).ignore();
306
307 const bool FORCEREMOVE(true);
308 clearStore(FORCEREMOVE).ignore();
309
310 m_stringpool.clear();
311 delete m_pStore;
312 m_pStore = nullptr;
313 delete m_remap_impl;
314 m_remap_impl = 0;
315 m_arena.erase();
316
317 return Service::finalize();
318}
SG::StringPool m_stringpool
Definition SGImplSvc.h:666
virtual StatusCode clearStore(bool forceRemove=false) override final
clear DataStore contents: called by the event loop mgrs

◆ handle()

void SGImplSvc::handle ( const Incident & inc)
finaloverridevirtual

triggered by Incident service

Definition at line 232 of file SGImplSvc.cxx.

232 {
233
234 if (inc.type() == "EndEvent") {
235 if (m_DumpStore) {
236 SG_MSG_DEBUG("Dumping StoreGate Contents");
237 SG_MSG_INFO ("\n{}\n", dump());
238 }
239 }
240}
std::string dump() const
dump objects in store.

◆ hiveProxyDict()

virtual::IProxyDict * SGImplSvc::hiveProxyDict ( )
inlinefinaloverride

implements IHiveStore interface for compat with Hive

Definition at line 227 of file SGImplSvc.h.

227 {
228 return this;
229 }

◆ initialize()

StatusCode SGImplSvc::initialize ( )
finaloverridevirtual

Service initialization.

Definition at line 148 of file SGImplSvc.cxx.

148 {
149
150 SG_MSG_VERBOSE ("Initializing {}", name());
151
152 CHECK( Service::initialize() );
153
154 if (!m_pStore)
155 m_pStore = new DataStore (*this);
156 if (!m_remap_impl)
157 m_remap_impl = new SG::RemapImpl;
158
159 //properties accessible from now on
160
162 // If this is the default event store (StoreGateSvc), then declare
163 // our arena as the default for memory allocations.
164 if (this->storeID() == StoreID::EVENT_STORE) {
165 m_arena.makeCurrent();
166 SG::CurrentEventStore::setStore (this);
168 }
169 // set up the incident service:
170 if (!(m_pIncSvc.retrieve()).isSuccess()) {
171 SG_MSG_ERROR ("Could not locate IncidentSvc ");
172 return StatusCode::FAILURE;
173 }
174
175 // We explicitly do not retrieve m_pIOVSvc and rely on retrieval
176 // on first use to avoid an initialization loop here.
177
178 CHECK( m_pDataLoader.retrieve() );
179 CHECK( m_pCLIDSvc.retrieve() );
180
181 if (!m_pPPSHandle.empty()) {
182 CHECK( m_pPPSHandle.retrieve() );
184 }
185
186 if ( m_pPPS && (m_pPPS->preLoadProxies(*m_pStore)).isFailure() )
187 {
188 SG_MSG_DEBUG(" Failed to preLoad proxies");
189 return StatusCode::FAILURE;
190 }
191
192 // Get hold of History Service
193 if (m_ActivateHistory) {
194 CHECK( m_pHistorySvc.retrieve() );
195 }
196
197 return StatusCode::SUCCESS;
198}
#define CHECK(...)
Evaluate an expression and check for errors.
#define SG_MSG_ERROR(x,...)
virtual StoreID::type storeID() const override
get store ID. request forwarded to DataStore:
void setStoreID(StoreID::type id)
@ EVENT_STORE
Definition StoreID.h:26
static StoreID::type findStoreID(const std::string &storeName)
Definition StoreID.cxx:21
void setProxyDictInEventContext(IProxyDict *sg)
Update the IProxyDict in the current EventContext.

◆ isSymLinked()

bool SGImplSvc::isSymLinked ( const CLID & linkID,
SG::DataProxy * dp )
private

Definition at line 497 of file SGImplSvc.cxx.

498{
499 return (0 != dp) ? dp->transientID(linkID) : false;
500}

◆ keys()

void SGImplSvc::keys ( const CLID & id,
std::vector< std::string > & vkeys,
bool includeAlias = false,
bool onlyValid = true )

provide list of all StoreGate keys associated with an object.

usage: p_store->keys(CLID, vkeys, optionalFlags);

Parameters
idCLID for which we are requesting list of keys
vkeyswill be filled with the (possibly empty) list of keys
includeAlias(default false) add alias keys as well
onlyValid(default true) add only keys of valid dobjs

Definition at line 488 of file SGImplSvc.cxx.

491{
493 return store()->keys(id, vkeys, includeAlias, onlyValid);
494}
void keys(const CLID &id, std::vector< std::string > &vkeys, bool includeAlias, bool onlyValid)

◆ keyToString() [1/2]

const std::string * SGImplSvc::keyToString ( sgkey_t key) const
finaloverridevirtual

Find the string corresponding to a given key.

Parameters
keyThe key to look up.
Returns
Pointer to the string found, or null. We can find keys as long as the corresponding string was given to either stringToKey() or registerKey().

Definition at line 1312 of file SGImplSvc.cxx.

1313{
1315 return m_stringpool.keyToString (key);
1316}
mutex_t m_stringPoolMutex
Definition SGImplSvc.h:689

◆ keyToString() [2/2]

const std::string * SGImplSvc::keyToString ( sgkey_t key,
CLID & clid ) const
finaloverridevirtual

Find the string and CLID corresponding to a given key.

Parameters
keyThe key to look up.
clid[out]The found CLID.
Returns
Pointer to the string found, or null. We can find keys as long as the corresponding string was given to either stringToKey() or registerKey().

Definition at line 1328 of file SGImplSvc.cxx.

1329{
1331 return m_stringpool.keyToString (key, clid);
1332}

◆ loadEventProxies()

StatusCode SGImplSvc::loadEventProxies ( )

load proxies at begin event

Definition at line 242 of file SGImplSvc.cxx.

242 {
244 StatusCode sc(StatusCode::SUCCESS);
245 //FIXME this should probably be dealt with by the providers
246 if (0 != m_pPPS && !m_storeLoaded) {
247 m_storeLoaded = true;
248 sc=m_pPPS->loadProxies(*m_pStore);
249#ifdef DEBUG_SGIMPL
250 dbg::print(stderr, "SGImplSvc::loadEventProxies() LOADED PROXIES on {}\n", name());
251 }
252 else {
253 dbg::print(stderr, "SGImplSvc::loadEventProxies() PROXIES ALREADY LOADED on {}\n", name());
254#endif
255 }
256 return sc;
257}

◆ locatePersistent()

DataProxy * SGImplSvc::locatePersistent ( const SG::TransientAddress * tAddr,
bool checkValid = false ) const
private

Definition at line 1142 of file SGImplSvc.cxx.

1144{
1145 DataProxy* dp = m_pStore->proxy(tAddr);
1146
1147 if (checkValid && 0 != dp) {
1148 return dp->isValid() ? dp : 0;
1149 } else {
1150 return dp;
1151 }
1152}

◆ makeCurrent()

void SGImplSvc::makeCurrent ( )
private

The current store is becoming the active store.

Switch the allocation arena, if needed. Only intended to be called by ActiveStoreSvc.

Switch the allocation arena, if needed, and call SG::CurrentEventStore::setStore.

Definition at line 1616 of file SGImplSvc.cxx.

1617{
1619 m_arena.makeCurrent();
1620 SG::CurrentEventStore::setStore (this);
1621}

◆ mergeStringPool()

bool SGImplSvc::mergeStringPool ( const SGImplSvc & other)

Merge the string pool from another store into this one.

Parameters
otherThe other store.

In case of collisions, the colliding entries are skipped, and false is returned. If no collisions, then true is returned.

Definition at line 1368 of file SGImplSvc.cxx.

1369{
1370 // We should hold m_stringPoolMutex before touching the pool.
1371 // But if we acquire the locks for both this and the other store,
1372 // we risk a deadlock. So first copy the other pool, so that we
1373 // don't need to hold both locks at the same time.
1374 SG::StringPool tmp;
1375 {
1376 lock_t lock (other.m_stringPoolMutex);
1377 tmp = other.m_stringpool;
1378 }
1380 return m_stringpool.merge (tmp);
1381}

◆ msg_update_handler()

void SGImplSvc::msg_update_handler ( Gaudi::Details::PropertyBase & outputLevel)
private

callback for output level property

Definition at line 1202 of file SGImplSvc.cxx.

1203{
1204 setUpMessaging();
1205 updateMsgStreamOutputLevel( outputLevel() );
1206 msgSvc()->setOutputLevel(name(), outputLevel());
1207}
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ operator=()

SGImplSvc & SGImplSvc::operator= ( const SGImplSvc & )
delete

◆ proxies()

std::vector< const SG::DataProxy * > SGImplSvc::proxies ( ) const
finaloverridevirtual

return the list of all current proxies in store

Definition at line 908 of file SGImplSvc.cxx.

909{
911 const std::vector<SG::DataProxy*>& proxies = store()->proxies();
912 std::vector<const SG::DataProxy*> ret (proxies.begin(), proxies.end());
913 return ret;
914}
virtual std::vector< const SG::DataProxy * > proxies() const override final
return the list of all current proxies in store
const std::vector< DataProxy * > & proxies() const
All proxies managed by this store.

◆ proxy() [1/7]

DataProxy * SGImplSvc::proxy ( const CLID & id) const

get default proxy with given id.

Returns 0 to flag failure Deprecated for the event store.

Definition at line 705 of file SGImplSvc.cxx.

706{
707 return proxy(id, false);
708}

◆ proxy() [2/7]

DataProxy * SGImplSvc::proxy ( const CLID & id,
bool checkValid ) const

get default proxy with given id, optionally checking validity.

Returns
0 to flag failure

Check if it is valid

Definition at line 711 of file SGImplSvc.cxx.

712{
713 DataProxy* dp = nullptr;
714 {
716 dp = m_pStore->proxy(id);
717 if (0 == dp && 0 != m_pPPS) {
718 SG::DataStore* pStore ATLAS_THREAD_SAFE = m_pStore;
719 dp = m_pPPS->retrieveProxy(id, string("DEFAULT"), *pStore);
720 }
721 }
723 // Be sure to release the lock before this.
724 // isValid() may call back to the store, so we could otherwise deadlock..
725 if (checkValid && 0 != dp) {
726 // FIXME: For keyless retrieve, this checks only the first instance
727 // of the CLID in store. If that happens to be invalid, but the second
728 // is valid - this does not work (when checkValid is requested).
729 return dp->isValid() ? dp : 0;
730 }
731 return dp;
732}
#define ATLAS_THREAD_SAFE

◆ proxy() [3/7]

SG::DataProxy * SGImplSvc::proxy ( const CLID & id,
const char * key ) const
inline

get proxy with given id and key.

Returns 0 to flag failure (overload to prevent a char* to be interpreted as a bool.)

Definition at line 246 of file SGImplSvc.h.

247 { return this->proxy(id, std::string(key)); }

◆ proxy() [4/7]

SG::DataProxy * SGImplSvc::proxy ( const CLID & id,
const char * key,
bool checkValid ) const
inline

get proxy with given id and key, optionally checking validity.

Returns
0 to flag failure (overload to prevent a char* to be interpreted as a bool.)

Definition at line 298 of file SGImplSvc.h.

299 { return this->proxy(id, std::string(key), checkValid); }

◆ proxy() [5/7]

DataProxy * SGImplSvc::proxy ( const CLID & id,
const std::string & key ) const
finaloverridevirtual

get proxy with given id and key. Returns 0 to flag failure

Definition at line 735 of file SGImplSvc.cxx.

736{
737 return proxy(id, key, false);
738}

◆ proxy() [6/7]

DataProxy * SGImplSvc::proxy ( const CLID & id,
const std::string & key,
bool checkValid ) const

get proxy with given id and key, optionally checking validity.

Returns
0 to flag failure

Definition at line 741 of file SGImplSvc.cxx.

742{
743 DataProxy* dp = nullptr;
744 {
746 dp = m_pStore->proxy(id, key);
747#ifdef DEBUG_SGIMPL
748 if (!dp) dbg::print(stderr, "::SGImplSvc::proxy(name={}, key={}): data proxy is null, m_pPPS is {}\n", this->name(), key, m_pPPS == 0 ? "NULL" : "NOT NULL");
749#endif
750 if (0 == dp && 0 != m_pPPS) {
751 SG::DataStore* pStore ATLAS_THREAD_SAFE = m_pStore;
752 dp = m_pPPS->retrieveProxy(id, key, *pStore);
753#ifdef DEBUG_SGIMPL
754 if (!dp) dbg::print(stderr, "::SGImplSvc::proxy(name={}, key={}): data proxy is still null\n", this->name(), key);
755#endif
756 }
757 }
758 // Be sure to release the lock before this.
759 // isValid() may call back to the store, so we could otherwise deadlock..
760 if (checkValid && 0 != dp && !(dp->isValid())) {
761 dp = 0;
762 }
763 return dp;
764}

◆ proxy() [7/7]

DataProxy * SGImplSvc::proxy ( const void *const pTransient) const
finaloverridevirtual

get proxy for a given data object address in memory

Definition at line 696 of file SGImplSvc.cxx.

697{
698 // No lock needed here --- the T2pmap held by DataStore has its own locking
699 // (and we were seeing contention here).
700 //lock_t lock (m_mutex);
701 return m_pStore->locatePersistent(pTransient);
702}

◆ proxy_exact()

SG::DataProxy * SGImplSvc::proxy_exact ( SG::sgkey_t sgkey) const
finaloverridevirtual

Get proxy given a hashed key+clid.

Find an exact match; no handling of aliases, etc. Returns 0 to flag failure.

Definition at line 885 of file SGImplSvc.cxx.

886{
887 return m_pStore->proxy_exact_unlocked (sgkey, m_mutex);
888}

◆ proxyProviderSvc()

IProxyProviderSvc * SGImplSvc::proxyProviderSvc ( )

Return current ProxyProviderSvc.

◆ record_HistObj()

StatusCode SGImplSvc::record_HistObj ( const CLID & id,
const std::string & key,
const std::string & store,
bool allowMods,
bool resetOnly = true )
private

Definition at line 1264 of file SGImplSvc.cxx.

1266 {
1267
1268 DataHistory *dho;
1269 dho = m_pHistorySvc->createDataHistoryObj( id, key, store );
1270
1271 std::string idname;
1272 StatusCode sc = m_pCLIDSvc->getTypeNameOfID(id, idname);
1273 if (sc.isFailure() || idname.empty() ) {
1274 idname = std::to_string(id);
1275 }
1276 idname += '/';
1277 idname += key;
1278
1279 DataObject* obj = SG::asStorable(dho);
1280
1281 const bool ALLOWOVERWRITE(false);
1282 if (record_impl(obj, idname, dho, allowMods, resetOnly, ALLOWOVERWRITE,
1283 &typeid(DataHistory)) == nullptr)
1284 return StatusCode::FAILURE;
1285 return StatusCode::SUCCESS;
1286}
SG::DataProxy * record_impl(DataObject *obj, const std::string &key, const void *const raw_ptr, bool allowMods, bool resetOnly, bool allowOverwrite, const std::type_info *tinfo)
real recording of an object with a key, allow possibility of specifying const-access
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)

◆ record_impl()

SG::DataProxy * SGImplSvc::record_impl ( DataObject * obj,
const std::string & key,
const void *const raw_ptr,
bool allowMods,
bool resetOnly,
bool allowOverwrite,
const std::type_info * tinfo )
private

real recording of an object with a key, allow possibility of specifying const-access

Definition at line 1072 of file SGImplSvc.cxx.

1076{
1077 CLID clid = pDObj->clID();
1078 std::string rawKey(key);
1079 if (!allowOverwrite && m_pPPS) {
1080 //do not overwrite a persistent object
1081 DataProxy* dp = m_pStore->proxy (clid, rawKey);
1082 if (!dp) {
1083 dp = m_pPPS->retrieveProxy(clid, rawKey, *m_pStore);
1084 }
1085 if (dp && dp->provider()) {
1086 std::string clidTypeName;
1087 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1088 SG_MSG_WARNING ("record_impl: you are recording an object with key {}, type {} (CLID {})\n"
1089 " There is already a persistent version of this object."
1090 " Recording a duplicate may lead to unreproducible results and it is deprecated.",
1091 rawKey, clidTypeName, clid);
1092 }
1093 }
1094 //now check whether raw_ptr has already been recorded
1095 //We need to do this before we create the bucket, the proxy etc
1096 SG::DataProxy* dp(proxy(raw_ptr));
1097 if (0 != dp) {
1098 std::string clidTypeName;
1099 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1100 SG_MSG_WARNING ("record_impl: failed for key={}, type {} (CLID {})\n"
1101 " object @{} already in store with key={}. Will not record a duplicate!",
1102 rawKey, clidTypeName, clid, raw_ptr, dp->name());
1103 if (pDObj != dp->object()) {
1104 DataBucketBase* pDBB(dynamic_cast<DataBucketBase*>(pDObj));
1105 if (!pDBB) std::abort();
1106 pDBB->relinquish(); //don't own the data obj already recorded!
1107 }
1108 this->recycle(pDObj);
1109 return nullptr;
1110 }
1111
1112
1113 // setup the proxy
1114 dp = setupProxy( clid, rawKey, pDObj, allowMods, resetOnly );
1115 if ( 0 == dp ) {
1116 std::string clidTypeName;
1117 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1118 SG_MSG_WARNING ("record_impl: Problem setting up the proxy for object @{}\n"
1119 " recorded with key {} of type {} (CLID {}) in DataObject @{}",
1120 raw_ptr, rawKey, clidTypeName, clid,
1121 static_cast<void*>(pDObj));
1122
1123 return nullptr;
1124 }
1125
1126 // record in t2p:
1127 if ( !(this->t2pRegister( raw_ptr, dp )).isSuccess() ) {
1128 std::string clidTypeName;
1129 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1130 SG_MSG_WARNING ("record_impl: can not add to t2p map object @{}\n"
1131 " with key {} of type {} (CLID {})",
1132 raw_ptr, rawKey, clidTypeName, clid);
1133 return nullptr;
1134 }
1135
1136 addAutoSymLinks (rawKey, clid, dp, tinfo);
1137
1138 return dp;
1139}
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.
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
void recycle(DataObject *pBadDObj)
put a bad (unrecordable) dobj away

◆ recordAddress() [1/2]

StatusCode SGImplSvc::recordAddress ( const std::string & skey,
CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress,
bool clearAddressFlag = true,
const std::vector< CLID > & bases = {} )

Create a proxy object using an IOpaqueAddress and a transient key.

Definition at line 333 of file SGImplSvc.cxx.

337{
339 assert(0 != pAddress);
340 CLID dataID = pAddress->clID();
341
342 if (dataID == 0)
343 {
344 SG_MSG_WARNING ("recordAddress: Invalid Class ID found in IOpaqueAddress @{}. IOA will not be recorded",
345 static_cast<void*>(pAddress.get()));
346 return StatusCode::FAILURE;
347 }
348
349 //do not overwrite a persistent object
350 if (m_pPPS) {
351 DataProxy* dp = m_pStore->proxy (dataID, skey);
352 if (!dp) {
353 dp = m_pPPS->retrieveProxy(dataID, skey, *m_pStore);
354 }
355 if (dp && dp->provider()) {
356 std::string clidTypeName;
357 m_pCLIDSvc->getTypeNameOfID(dataID, clidTypeName).ignore();
358 SG_MSG_WARNING ("recordAddress: failed for key={}, type (CLID {})\n"
359 " there is already a persistent version of this object. Will not record a duplicate! ",
360 skey, clidTypeName, dataID);
361 return StatusCode::FAILURE;
362 }
363 }
364
365 // Check if a key already exists
366 DataProxy* dp = m_pStore->proxy_exact(dataID, skey);
367 if (0 == dp && 0 != m_pPPS) {
368 dp = m_pPPS->retrieveProxy(dataID, skey, *m_pStore);
369 }
370
371 // Now treat the various cases:
372 if (0 == dp)
373 {
374 // create the proxy object and register it
375 dp = new DataProxy (TransientAddress (dataID, skey,
376 std::move(pAddress),
377 clearAddressFlag),
378 m_pDataLoader.get(), true, true);
379 m_pStore->addToStore(dataID, dp).ignore();
380
381 addAutoSymLinks (skey, dataID, dp, 0, false);
382
383 // Add extra bases.
384 for (CLID b : bases) {
385 if (addSymLink (b, dp).isFailure()) {
386 warning() << std::format ("Can't add extra base {} for object {}/{}",
387 b, dataID, skey) << endmsg;
388 }
389 }
390 }
391 else if ((0 != dp) && (0 == dp->address()))
392 // Note: intentionally not checking dp->isValidAddress()
393 {
394 // Update proxy with IOpaqueAddress
395 dp->setAddress(std::move(pAddress));
396 }
397 else
398 {
399 string errType;
400 m_pCLIDSvc->getTypeNameOfID(dataID, errType).ignore();
401 SG_MSG_WARNING ("recordAddress: preexisting proxy @{} with non-NULL IOA found for key type {} ({}). \n"
402 "Cannot record IOpaqueAddress @{}",
403 static_cast<void*>(dp), skey, errType, dataID,
404 static_cast<void*>(pAddress.get()));
405 return StatusCode::FAILURE;
406 }
407
408 return StatusCode::SUCCESS;
409
410}
#define endmsg
T * get()
Get the pointer.

◆ recordAddress() [2/2]

StatusCode SGImplSvc::recordAddress ( CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress,
bool clearAddressFlag = true,
const std::vector< CLID > & bases = {} )

Create a proxy object using an IOpaqueAddress.

Definition at line 416 of file SGImplSvc.cxx.

419{
421 assert(0 != pAddress);
422
423 CLID dataID = pAddress->clID();
424
425 string gK = (pAddress->par())[1]; // transient name by convention
426 if (gK.empty()) gK = (pAddress->par())[0]; // FIXME backward compatibility
427 if (gK.empty()) gK = createKey(dataID);
428
429 return this->recordAddress(gK, std::move(pAddress), clearAddressFlag, bases);
430}
std::string createKey(const CLID &dataID)
creates a key internally if none specified by client
StatusCode recordAddress(const std::string &skey, CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress, bool clearAddressFlag=true, const std::vector< CLID > &bases={})
Create a proxy object using an IOpaqueAddress and a transient key.

◆ recordObject()

SG::DataProxy * SGImplSvc::recordObject ( SG::DataObjectSharedPtr< DataObject > obj,
const std::string & key,
bool allowMods,
bool returnExisting )
finaloverridevirtual

Record an object in the store.

Parameters
objThe data object to store.
keyThe key as which it should be stored.
allowModsIf false, the object will be recorded as const.
returnExistingIf true, return proxy if this key already exists. If the object has been recorded under a different key, then make an alias. If the object has been recorded under a different clid, then make a link.

Full-blown record. obj should usually be something deriving from SG::DataBucket.

Returns the proxy for the recorded object; nullptr on failure. If the requested CLID/key combination already exists in the store, the behavior is controlled by returnExisting. If true, then the existing proxy is returned; otherwise, nullptr is returned. In either case, obj is destroyed.

Definition at line 799 of file SGImplSvc.cxx.

803{
805 const void* raw_ptr = obj.get();
806 const std::type_info* tinfo = nullptr;
807
808 if (DataBucketBase* bucket = dynamic_cast<DataBucketBase*> (obj.get())) {
809 raw_ptr = bucket->object();
810 tinfo = &bucket->tinfo();
811 }
812
813 if (returnExisting) {
814 SG::DataProxy* proxy = this->proxy (obj->clID(), key);
815 if (proxy && proxy->isValid()) return proxy;
816
817 // Look for the same object recorded under a different key/clid.
818 proxy = this->proxy (raw_ptr);
819 if (proxy && proxy->isValid()) {
820 if (proxy->transientID (obj->clID())) {
821 // CLID matches. Make an alias.
822 if (addAlias (key, proxy).isFailure()) {
823 CLID clid = proxy->clID();
824 std::string clidTypeName;
825 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
826 SG_MSG_WARNING ("SGImplSvc::recordObject: addAlias fails for object {} [{}] {} and new key {}",
827 clid, clidTypeName, proxy->name(), key);
828 proxy = nullptr;
829 }
830 }
831
832 else if (key == proxy->name() || proxy->hasAlias(key) > 0)
833 {
834 // key matches. Make a symlink.
835 if (addSymLink (obj->clID(), proxy).isFailure()) {
836 CLID clid = proxy->clID();
837 std::string clidTypeName;
838 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
839 CLID newclid = obj->clID();
840 std::string newclidTypeName;
841 m_pCLIDSvc->getTypeNameOfID(newclid, newclidTypeName).ignore();
842 SG_MSG_ERROR ("SGImplSvc::recordObject:"
843 " addSymLink fails for object {} [{}] {} and new clid {} [{}]",
844 clid, clidTypeName, proxy->name(),
845 newclid, newclidTypeName);
846 proxy = nullptr;
847 }
848 }
849
850 else {
851 CLID clid = proxy->clID();
852 std::string clidTypeName;
853 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
854 CLID newclid = obj->clID();
855 std::string newclidTypeName;
856 m_pCLIDSvc->getTypeNameOfID(newclid, newclidTypeName).ignore();
857 SG_MSG_ERROR ("SGImplSvc::recordObject:"
858 " existing object found with {} [{}] {} but neither"
859 " clid {} [{}] nor key {} match.",
860 clid, clidTypeName, proxy->name(),
861 newclid, newclidTypeName, key);
862 proxy = nullptr;
863 }
864
865 return proxy;
866 }
867 }
868
869 const bool resetOnly = true;
870 const bool noHist = false;
871 SG::DataProxy* proxy = nullptr;
872 if (this->typeless_record (obj.get(), key, raw_ptr,
873 allowMods, resetOnly, noHist, tinfo,
874 &proxy, true).isFailure())
875 {
876 return nullptr;
877 }
878 return proxy;
879}
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...
StatusCode addAlias(const std::string &aliasKey, SG::DataProxy *dp)

◆ recycle()

void SGImplSvc::recycle ( DataObject * pBadDObj)
private

put a bad (unrecordable) dobj away

Definition at line 1245 of file SGImplSvc.cxx.

1245 {
1246 assert(pBadDObj);
1247 pBadDObj->addRef();
1248 m_trash.push_back(pBadDObj);
1249}

◆ registerKey()

void SGImplSvc::registerKey ( sgkey_t key,
const std::string & str,
CLID clid )
finaloverridevirtual

Remember an additional mapping from key to string/CLID.

Parameters
keyThe key to enter.
strThe string to enter.
clidThe CLID associated with the string.
Returns
True if successful; false if the key already corresponds to a different string.

This registers an additional mapping from a key to a string; it can be found later through lookup() on the string. Logs an error if key already corresponds to a different string.

Definition at line 1347 of file SGImplSvc.cxx.

1350{
1352 if (!m_stringpool.registerKey (key, str, clid)) {
1353 CLID clid2;
1354 const std::string* str2 = m_stringpool.keyToString (key, clid2);
1355 SG_MSG_WARNING ("The numeric key {} maps to multiple string key/CLID pairs: {}/{} and {}/{}",
1356 key, *str2, clid2, str, clid);
1357 }
1358}

◆ reinitialize()

StatusCode SGImplSvc::reinitialize ( )
finaloverridevirtual

Service reinitialization.

Definition at line 321 of file SGImplSvc.cxx.

321 {
322 SG_MSG_VERBOSE ("Reinitializing {}", name());
323 const bool FORCEREMOVE(true);
324 clearStore(FORCEREMOVE).ignore();
325 //not in v20r2p2! return Service::reinitialize();
326 return StatusCode::SUCCESS;
327}

◆ releaseObject()

void SGImplSvc::releaseObject ( const CLID & id,
const std::string & key )
private

release object held by proxy, if any.

Gives up ownership (somebody else must take charge)

Definition at line 1385 of file SGImplSvc.cxx.

1385 {
1387 DataProxy *pP(0);
1388 if (0 != (pP = proxy(id, key))) {
1389 // remove all entries from t2p map
1390 SG::DataProxy::CLIDCont_t clids = pP->transientID();
1391 SG::DataProxy::CLIDCont_t::const_iterator i(clids.begin()), e(clids.end());
1392 while (i != e) t2pRemove(SG::DataProxy_cast (pP, *i++));
1393 DataBucketBase *pDBB(dynamic_cast<DataBucketBase*>(pP->object()));
1394 //tell the bucket to let go of the data object
1395 if (0 != pDBB) pDBB->relinquish(); //somebody else better took ownership
1396 bool hard_reset = (m_numSlots > 1);
1397 pP->reset (hard_reset);
1398 }
1399}

◆ remap_impl()

void SGImplSvc::remap_impl ( sgkey_t source,
sgkey_t target,
off_t index_offset )

Declare a remapping.

source Key hash of the container being remapped.

target Key hash of the container being remapped to.

index_offset Amount by which the index should be adjusted between the two containers.

Definition at line 1430 of file SGImplSvc.cxx.

1433{
1435 SG::RemapImpl::remap_t payload;
1436 payload.target = target;
1437 payload.index_offset = index_offset;
1438 m_remap_impl->m_remaps[source] = payload;
1439}

◆ remove()

StatusCode SGImplSvc::remove ( const void * pObject)

Remove pObject, will remove its proxy if not reset only.

Definition at line 1228 of file SGImplSvc.cxx.

1229{
1231 return removeProxy(proxy(pObject), pObject);
1232}
StatusCode removeProxy(SG::DataProxy *proxy, const void *pTrans, bool forceRemove=false)
remove proxy from store, unless it is reset only.

◆ removeDataAndProxy()

StatusCode SGImplSvc::removeDataAndProxy ( const void * pObject)

Remove pObject and its proxy no matter what.

Definition at line 1237 of file SGImplSvc.cxx.

1238{
1240 const bool FORCEREMOVE(true);
1241 return removeProxy(proxy(pObject), pObject, FORCEREMOVE);
1242}

◆ removeProxy()

StatusCode SGImplSvc::removeProxy ( SG::DataProxy * proxy,
const void * pTrans,
bool forceRemove = false )
private

remove proxy from store, unless it is reset only.

provide pTrans!=0 (must match proxy...) to save time

Parameters
forceRemoveremove the proxy no matter what

Definition at line 1155 of file SGImplSvc.cxx.

1157{
1159 // check if valid proxy
1160 if (0 == proxy) return StatusCode::FAILURE;
1161
1162 if (0 == pTrans) {
1163 DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(proxy->object());
1164 if (bucket) pTrans = bucket->object();
1165 }
1166
1167 // remove all entries from t2p map
1168 // --- only if the proxy actually has an object!
1169 // otherwise, we can trigger I/O.
1170 // besides being useless here, we can get deadlocks if we
1171 // call into the I/O code while holding the SG lock.
1172 if (proxy->isValidObject()) {
1173 this->t2pRemove(pTrans);
1174 SG::DataProxy::CLIDCont_t clids = proxy->transientID();
1175 for (SG::DataProxy::CLIDCont_t::const_iterator i = clids.begin();
1176 i != clids.end();
1177 ++i)
1178 {
1179 void* ptr = SG::DataProxy_cast (proxy, *i);
1180 this->t2pRemove(ptr);
1181 }
1182 }
1183
1184 // remove from store
1185 return m_pStore->removeProxy(proxy, forceRemove, true);
1186}
virtual void * object()=0

◆ retrieve()

StatusCode SGImplSvc::retrieve ( CLID clid,
SG::detail::IteratorBase & cibegin,
SG::detail::IteratorBase & ciend ) const

Retrieve all objects of type T: returns an SG::ConstIterator range.

Definition at line 1685 of file SGImplSvc.cxx.

1688{
1692
1693 if (!(m_pStore->pRange(clid,first,end)).isSuccess()) {
1694 std::string typnam;
1695 m_pCLIDSvc->getTypeNameOfID(clid, typnam).ignore();
1696 SG_MSG_DEBUG("retrieve(range): no object found of type {} (CLID {})",
1697 typnam, clid);
1698 }
1699
1700 (ciend.setState(end, end, true)).ignore();
1701
1702 if (!(cibegin.setState(first, end, true)).isSuccess()) {
1703 std::string typnam;
1704 m_pCLIDSvc->getTypeNameOfID(clid, typnam).ignore();
1705 SG_MSG_DEBUG("retrieve(range): Can't initialize iterator for object range "
1706 " of type {} (CLID {})",
1707 typnam, clid);
1708 return StatusCode::FAILURE;
1709 }
1710
1711 return StatusCode::SUCCESS;
1712}
StatusCode setState(SG::ConstProxyIterator itr, SG::ConstProxyIterator itrEnd, bool isConst)
Reset state of the iterator.
bool first
Definition DeMoScan.py:534

◆ setAlias() [1/3]

StatusCode SGImplSvc::setAlias ( CLID clid,
const std::string & key,
const std::string & aliasKey )

make an alias to a DataObject (provide data type and old key)

Definition at line 626 of file SGImplSvc.cxx.

628{
630
631 SG::DataProxy* dp(0);
632 dp = proxy(clid, key);
633 if (0 == dp) {
634 error() << "setAlias: problem setting alias "
635 << std::string(aKey) << '\n'
636 << "DataObject does not exist, record before setting alias."
637 << endmsg;
638 return StatusCode::FAILURE;
639 }
640
641 StatusCode sc = addAlias(aKey, dp);
642 if (sc.isFailure()) {
643 error() << "setAlias: problem setting alias "
644 << (std::string)aKey << '\n'
645 << "DataObject does not exist, record before setting alias."
646 << endmsg;
647 return StatusCode::FAILURE;
648 }
649
650 return StatusCode::SUCCESS;
651}

◆ setAlias() [2/3]

StatusCode SGImplSvc::setAlias ( const void * p2BAliased,
const std::string & aliasKey )

make an alias to a DataObject (provide only valid pointer)

Definition at line 601 of file SGImplSvc.cxx.

602{
604
605 SG::DataProxy* dp(0);
606 dp = proxy(pObject);
607 if (0 == dp) {
608 SG_MSG_ERROR ("setAlias: problem setting alias {}\n"
609 "DataObject does not exist, record before setting alias.",
610 aliasKey);
611 return StatusCode::FAILURE;
612 }
613
614 StatusCode sc = addAlias(aliasKey, dp);
615 if (sc.isFailure()) {
616 SG_MSG_ERROR ("setAlias: problem setting alias {}\n"
617 "DataObject does not exist, record before setting alias.",
618 aliasKey);
619 return StatusCode::FAILURE;
620 }
621
622 return StatusCode::SUCCESS;
623}

◆ setAlias() [3/3]

StatusCode SGImplSvc::setAlias ( SG::DataProxy * proxy,
const std::string & aliasKey )

make an alias to a DataObject (provide valid proxy)

Definition at line 653 of file SGImplSvc.cxx.

654{
655 return addAlias( aliasKey, proxy );
656}

◆ setConst()

StatusCode SGImplSvc::setConst ( const void * pointer)

prevent downstream clients from modifying the pointed-at dobj

Definition at line 1209 of file SGImplSvc.cxx.

1210{
1212 // Check if DataProxy does not exist
1213 DataProxy * dp = proxy(pObject);
1214
1215 if (0 == dp)
1216 {
1217 SG_MSG_WARNING ("setConst: NO Proxy for the dobj you want to set const");
1218 return StatusCode::FAILURE;
1219 }
1220
1221 dp->setConst();
1222 return StatusCode::SUCCESS;
1223}

◆ setProxyProviderSvc()

void SGImplSvc::setProxyProviderSvc ( IProxyProviderSvc * pPPSvc)

associate ProxyProviderSvc to this store

◆ setSlotNumber()

void SGImplSvc::setSlotNumber ( int slot,
int numSlots )

Set the Hive slot number for this store.

Parameters
slotThe slot number. -1 means that this isn't a Hive store.
numSlotsThe total number of slots. Should be 1 for the non-Hive case.

Definition at line 897 of file SGImplSvc.cxx.

898{
899 m_slotNumber = slot;
900 m_numSlots = numSlots;
901
902 SG::ArenaHeader* header = SG::ArenaHeader::defaultHeader();
903 header->setArenaForSlot (slot, &m_arena);
904}

◆ setStoreID()

void SGImplSvc::setStoreID ( StoreID::type id)

set store ID. request forwarded to DataStore:

set store id in DataStore:

Definition at line 474 of file SGImplSvc.cxx.

475{
477 store()->setStoreID(id);
478}

◆ setupProxy()

DataProxy * SGImplSvc::setupProxy ( const CLID & dataID,
const std::string & gK,
DataObject * pDObj,
bool allowMods,
bool resetOnly )
private

try to locate a proxy or create it if needed

Definition at line 432 of file SGImplSvc.cxx.

436 {
437 // locate the proxy
438 DataProxy* dp = m_pStore->proxy_exact(dataID, gK);
439
440 if (0 != dp) { //proxy found
441 if (0 != dp->object())
442 {
443 // Case 0: duplicated proxy
444 SG_MSG_WARNING (" setupProxy:: error setting up proxy for key {} and clid {}\n"
445 " Pre-existing valid DataProxy @{} found in Store for key {} with clid {}",
446 gK, dataID,
447 static_cast<void*>(dp),
448 dp->object()->name(),
449 dp->object()->clID());
450 recycle(pDObj); // commit this object to trash
451 dp = 0;
452 } else {
453 // Case 1: Proxy found... if not valid, update it:
454 dp->setObject(pDObj);
455 if (!allowMods) dp->setConst();
456 }
457 } else {
458 // Case 2: No Proxy found:
459 dp = new DataProxy(pDObj,
460 TransientAddress(dataID, gK),
461 !allowMods, resetOnly);
462 if (!(m_pStore->addToStore(dataID, dp).isSuccess())) {
463 SG_MSG_WARNING (" setupProxy:: could not addToStore proxy @{}",
464 static_cast<void*>(dp));
465 recycle(pDObj); // commit this object to trash
466 delete dp;
467 dp = 0;
468 }
469 }
470 return dp;
471}

◆ sourceID()

SG::SourceID SGImplSvc::sourceID ( const std::string & key = "EventSelector") const
overridevirtual

Return the metadata source ID for the current event slot.

Parameters
keySG key of the DataHeader to query. Returns an empty string if no source has been set.

The default version always returns an empty string.

Returns an empty string if no source has been set.

The default version always returns an empty string.

Definition at line 1667 of file SGImplSvc.cxx.

1668{
1670 SG::DataProxy* dp =proxy (ClassID_traits<DataHeader>::ID(), key, true);
1671 if (dp) {
1673 if (dh) {
1674 return dh->begin()->getToken()->dbID().toString();
1675 }
1676 }
1677 return "";
1678}
std::vector< DataHeaderElement >::const_iterator begin() const

◆ start()

StatusCode SGImplSvc::start ( )
finaloverridevirtual

Service start.

Definition at line 200 of file SGImplSvc.cxx.

200 {
201
202 SG_MSG_VERBOSE ("Start {}", name());
203 /*
204 // This will need regFcn clients to be updated first.
205 if ( 0 == m_pPPS || (m_pPPS->preLoadProxies(*m_pStore)).isFailure() ) {
206 SG_MSG_DEBUG (" Failed to preLoad proxies");
207 return StatusCode::FAILURE;
208 }
209 */
210
211 return StatusCode::SUCCESS;
212}

◆ stop()

StatusCode SGImplSvc::stop ( )
finaloverridevirtual

Service stop.

Definition at line 214 of file SGImplSvc.cxx.

214 {
215
216 SG_MSG_VERBOSE ("Stop {}", name());
217 //HACK ALERT: ID event store objects refer to det store objects
218 //by setting an ad-hoc priority for event store(s) we make sure they are finalized and hence cleared first
219 // see e.g. https://savannah.cern.ch/bugs/index.php?99993
220 if (store()->storeID() == StoreID::EVENT_STORE) {
221 ISvcManager* pISM(dynamic_cast<ISvcManager*>(serviceLocator().get()));
222 if (!pISM)
223 return StatusCode::FAILURE;
224 pISM->setPriority(name(), pISM->getPriority(name())+1).ignore();
225 SG_MSG_VERBOSE ("stop: setting service priority to {} so that event stores get finalized and cleared before other stores",
226 pISM->getPriority(name()));
227 }
228 return StatusCode::SUCCESS;
229}
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132

◆ store() [1/2]

DataStore * SGImplSvc::store ( )
private

Definition at line 544 of file SGImplSvc.cxx.

545{
546 return m_pStore;
547}

◆ store() [2/2]

const DataStore * SGImplSvc::store ( ) const
private

Definition at line 550 of file SGImplSvc.cxx.

551{
552 return m_pStore;
553}

◆ storeID()

StoreID::type SGImplSvc::storeID ( ) const
overridevirtual

get store ID. request forwarded to DataStore:

get store id from DataStore:

Definition at line 480 of file SGImplSvc.cxx.

481{
483 return store()->storeID();
484}
virtual StoreID::type storeID() const override

◆ stringToKey()

SGImplSvc::sgkey_t SGImplSvc::stringToKey ( const std::string & str,
CLID clid )
finaloverridevirtual

Find the key for a string/CLID pair.

Parameters
strThe string to look up.
clidThe CLID associated with the string.
Returns
A key identifying the string. A given string will always return the same key. Will abort in case of a hash collision!

Definition at line 1298 of file SGImplSvc.cxx.

1299{
1301 return m_stringpool.stringToKey (str, clid);
1302}

◆ symLink() [1/2]

StatusCode SGImplSvc::symLink ( const CLID id,
const std::string & key,
const CLID linkid )

make a soft link to the object pointed by id/key

Definition at line 570 of file SGImplSvc.cxx.

571{
573 SG::DataProxy* dp(proxy(id, key, false));
574 // if symLink already exists, just return success
575 return isSymLinked(linkID,dp) ?
576 StatusCode::SUCCESS :
577 addSymLink(linkID,dp);
578}
bool isSymLinked(const CLID &linkID, SG::DataProxy *dp)

◆ symLink() [2/2]

StatusCode SGImplSvc::symLink ( const void * p2BRegistered,
CLID linkID )

make a soft link to the object T* already registered

Definition at line 559 of file SGImplSvc.cxx.

560{
562 SG::DataProxy* dp(proxy(pObject));
563
564 // if symLink already exists, just return success
565 return isSymLinked(linkID,dp) ?
566 StatusCode::SUCCESS :
567 addSymLink(linkID,dp);
568}

◆ t2pRegister()

StatusCode SGImplSvc::t2pRegister ( const void *const pTrans,
SG::DataProxy *const pPers )
private

forwarded to DataStore

Definition at line 1189 of file SGImplSvc.cxx.

1190{
1191 return m_pStore->t2pRegister(pTrans, pPers);
1192}

◆ t2pRemove()

void SGImplSvc::t2pRemove ( const void *const pTrans)
private

forwarded to DataStore

Definition at line 1196 of file SGImplSvc.cxx.

1197{
1198 m_pStore->t2pRemove(pTrans);
1199}

◆ transientContains()

bool SGImplSvc::transientContains ( const CLID id,
const std::string & key ) const

Look up a transient data object in TDS only by CLID.

returns false if object not available in TDS

Definition at line 687 of file SGImplSvc.cxx.

688{
689 try {
690 return (0 != transientProxy(id, key));
691 } catch(...) { return false; }
692}
SG::DataProxy * transientProxy(const CLID &id, const std::string &key) const
get proxy with given id and key.

◆ transientProxy()

DataProxy * SGImplSvc::transientProxy ( const CLID & id,
const std::string & key ) const

get proxy with given id and key.

Does not query ProxyProviderSvc.

Returns
0 to flag failure

Definition at line 939 of file SGImplSvc.cxx.

940{
942 DataProxy* dp(m_pStore->proxy(id, key));
943 return ( (0 != dp && dp->isValidObject()) ? dp : 0 );
944}

◆ transientSwap()

bool SGImplSvc::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 Note that the swap is invalidated at event boundaries and/or when somebody clear the store.

Returns
false if swap failed

Definition at line 963 of file SGImplSvc.cxx.

965{
967 const bool checkValid = true;
968 DataProxy* a = proxy( id, keyA, checkValid );
969 DataProxy* b = proxy( id, keyB, checkValid );
970 if ( 0 == a || 0 == b ) { return false; }
971 DataObject* objA = a->accessData();
972 DataObject* objB = b->accessData();
973
974 if ( 0 == objA || 0 == objB ) { return false; }
975 // prevent 'accidental' release of DataObjects...
976 const unsigned int refCntA = objA->addRef();
977 const unsigned int refCntB = objB->addRef();
978 // in case swap is being specialized for DataObjects
979 using std::swap;
980 swap( objA, objB );
981 a->setObject( objA );
982 b->setObject( objB );
983 // and then restore old ref-count;
984 return ( (refCntA-1) == objA->release() &&
985 (refCntB-1) == objB->release() );
986}
void swap(DataVector< T > &a, DataVector< T > &b)
See DataVector<T, BASE>::swap().
static Double_t a
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)

◆ tryELRemap()

bool SGImplSvc::tryELRemap ( sgkey_t sgkey_in,
size_t index_in,
sgkey_t & sgkey_out,
size_t & index_out )
finaloverridevirtual

Test to see if the target of an ElementLink has moved.

Parameters
sgkey_inOriginal hashed key of the EL.
index_inOriginal index of the EL.
sgkey_out[out]New hashed key for the EL.
index_out[out]New index for the EL.
Returns
True if there is a remapping; false otherwise.

Definition at line 1450 of file SGImplSvc.cxx.

1452{
1454 SG::RemapImpl::remap_map_t::iterator i =
1455 m_remap_impl->m_remaps.find (sgkey_in);
1456 if (i == m_remap_impl->m_remaps.end())
1457 return false;
1458 const SG::RemapImpl::remap_t& payload = i->second;
1459 sgkey_out = payload.target;
1460 index_out = index_in + payload.index_offset;
1461 return true;
1462}

◆ typeCount()

int SGImplSvc::typeCount ( const CLID & id) const

Return the number of instances of type T (input CLID).

Definition at line 670 of file SGImplSvc.cxx.

671{
673 return m_pStore->typeCount(id);
674}

◆ typeless_overwrite()

StatusCode SGImplSvc::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 )
private

same as typeless_record, allows to overwrite an object in memory or on disk

Definition at line 1037 of file SGImplSvc.cxx.

1044{
1046 StatusCode sc(StatusCode::SUCCESS);
1047 SG::DataProxy* toRemove(proxy(clid, key, false));
1048 if (0 != toRemove) {
1049 toRemove->addRef();
1050 const bool FORCEREMOVE(true);
1051 sc =removeProxy(toRemove, (void*)0, FORCEREMOVE);
1052 }
1053 if (sc.isSuccess()) {
1054 const bool ALLOWOVERWRITE(true);
1055 const bool NORESET(false);
1056 if (record_impl( obj, key, raw_ptr, allowMods, NORESET, ALLOWOVERWRITE, tinfo) == nullptr)
1057 sc = StatusCode::FAILURE;
1058 else if ( m_ActivateHistory && noHist && store()->storeID() == StoreID::EVENT_STORE ) {
1059 sc = record_HistObj( obj->clID(), key, name(), allowMods, NORESET );
1060 }
1061 }
1062 //for detector store objects managed by IIOVSvc, replace the old proxy with the new one (#104311)
1063 if (toRemove && sc.isSuccess() && store()->storeID() == StoreID::DETECTOR_STORE) {
1064 sc = m_pIOVSvc->replaceProxy(toRemove, proxy(clid, key));
1065 }
1066 if (toRemove)
1067 toRemove->release();
1068 return sc;
1069}
StatusCode record_HistObj(const CLID &id, const std::string &key, const std::string &store, bool allowMods, bool resetOnly=true)
@ DETECTOR_STORE
Definition StoreID.h:27

◆ typeless_record() [1/3]

StatusCode SGImplSvc::typeless_record ( DataObject * obj,
const std::string & key,
const void *const raw_ptr,
bool allowMods,
bool resetOnly,
bool noHist,
const std::type_info * tinfo )
private

Definition at line 999 of file SGImplSvc.cxx.

1003{
1004 return typeless_record (obj, key, raw_ptr, allowMods, resetOnly, noHist,tinfo,
1005 nullptr, true);
1006}

◆ typeless_record() [2/3]

StatusCode SGImplSvc::typeless_record ( DataObject * obj,
const std::string & key,
const void *const raw_ptr,
bool allowMods,
bool resetOnly,
bool noHist,
const std::type_info * tinfo,
SG::DataProxy ** proxy_ret,
bool noOverwrite )
private

Definition at line 1010 of file SGImplSvc.cxx.

1016{
1018 SG::DataProxy* proxy =
1019 record_impl( obj, key, raw_ptr, allowMods, resetOnly, !noOverwrite, tinfo);
1020 if ( proxy == nullptr )
1021 return StatusCode::FAILURE;
1022 if (proxy_ret)
1023 *proxy_ret = proxy;
1024
1025 if ( !m_ActivateHistory || noHist ) {
1026 return StatusCode::SUCCESS;
1027 }
1028
1029 if ( store()->storeID() != StoreID::EVENT_STORE ) {
1030 return StatusCode::SUCCESS;
1031 } else {
1032 return record_HistObj( obj->clID(), key, name(), allowMods, resetOnly );
1033 }
1034}

◆ typeless_record() [3/3]

StatusCode SGImplSvc::typeless_record ( DataObject * obj,
const std::string & key,
const void *const raw_ptr,
bool allowMods,
bool resetOnly = true,
bool noHist = false )
private

type-less recording of an object with a key, allow possibility of specifying const-access and history record

Definition at line 989 of file SGImplSvc.cxx.

992{
993 return typeless_record (obj, key, raw_ptr, allowMods, resetOnly, noHist, 0,
994 nullptr, true);
995}

◆ typeless_retrievePrivateCopy()

DataObject * SGImplSvc::typeless_retrievePrivateCopy ( const CLID clid,
const std::string & key )

Definition at line 1465 of file SGImplSvc.cxx.

1467{
1469 DataObject* obj = nullptr;
1470 SG::DataProxy* dp = proxy (clid, key);
1471 //we do not want anyone to mess up with our copy hence we release it immediately.
1472 if (dp && dp->isValid()) {
1473 obj = dp->object();
1474 obj->addRef();
1475 clearProxyPayload (dp);
1476 }
1477 return obj;
1478}
void clearProxyPayload(SG::DataProxy *)
use to reset a proxy (clearing the data object it contains) Unlike DataProxy::reset this method corre...

◆ unboundHandle()

void SGImplSvc::unboundHandle ( IResetable * handle)
finaloverridevirtual

Tell the store that a handle has been unbound from a proxy.

Parameters
handleThe handle that was unbound. The default implementation does nothing.

Definition at line 1604 of file SGImplSvc.cxx.

1605{
1606 std::vector<IResetable*>& v = m_newBoundHandles[std::this_thread::get_id()];
1607 std::vector<IResetable*>::iterator it =
1608 std::find (v.begin(), v.end(), handle);
1609 if (it != v.end())
1610 v.erase (it);
1611}

◆ ActiveStoreSvc

friend class ActiveStoreSvc
friend

Definition at line 634 of file SGImplSvc.h.

◆ AthenaInternal::py_sg_clearProxyPayload

◆ AthenaInternal::recordObjectToStore

PyObject * AthenaInternal::recordObjectToStore ( StoreGateSvc * ,
PyObject * ,
PyObject * ,
bool ,
bool ,
bool  )
friend

◆ IOVDbSvc

friend class IOVDbSvc
friend

access clearProxyPayload

Definition at line 567 of file SGImplSvc.h.

◆ IOVSvcTool

friend class IOVSvcTool
friend

Definition at line 568 of file SGImplSvc.h.

◆ SG::VarHandleBase

friend class SG::VarHandleBase
friend

access typeless_record

Definition at line 582 of file SGImplSvc.h.

◆ StoreGateSvc

friend class StoreGateSvc
friend

Definition at line 580 of file SGImplSvc.h.

Member Data Documentation

◆ m_ActivateHistory

bool SGImplSvc::m_ActivateHistory
private

Activate the history service.

Definition at line 655 of file SGImplSvc.h.

◆ m_arena

SG::Arena SGImplSvc::m_arena
private

Allocation arena to associate with this store.

Definition at line 671 of file SGImplSvc.h.

◆ m_DumpArena

bool SGImplSvc::m_DumpArena
private

DumpArena Property flag : trigger m_arena->report() at clearStore.

Definition at line 656 of file SGImplSvc.h.

◆ m_DumpStore

bool SGImplSvc::m_DumpStore
private

Dump Property flag: triggers dump() at EndEvent.

Definition at line 654 of file SGImplSvc.h.

◆ m_folderNameList

StringArrayProperty SGImplSvc::m_folderNameList
private

FolderNameList Property.

Definition at line 659 of file SGImplSvc.h.

◆ m_mutex

mutex_t SGImplSvc::m_mutex
mutableprivate

Definition at line 687 of file SGImplSvc.h.

◆ m_newBoundHandles

std::map<std::thread::id, std::vector<IResetable*> > SGImplSvc::m_newBoundHandles
private

Keep track of proxies bound since the last call to commitNewDataObjects or clearStore.

Has to be done per-thread. We can't use thread_specific_ptr because we want to be able to clear the vectors for all threads in clearStore().

Definition at line 683 of file SGImplSvc.h.

◆ m_numSlots

int SGImplSvc::m_numSlots
private

The total number of slots. 1 if this isn't a Hive store.

Definition at line 677 of file SGImplSvc.h.

◆ m_pCLIDSvc

ServiceHandle<IClassIDSvc> SGImplSvc::m_pCLIDSvc
private

Definition at line 640 of file SGImplSvc.h.

◆ m_pDataLoader

ServiceHandle<IConversionSvc> SGImplSvc::m_pDataLoader
private

Definition at line 641 of file SGImplSvc.h.

◆ m_pHistorySvc

ServiceHandle<IHistorySvc> SGImplSvc::m_pHistorySvc
private

Definition at line 648 of file SGImplSvc.h.

◆ m_pIncSvc

ServiceHandle<IIncidentSvc> SGImplSvc::m_pIncSvc
private

property

Definition at line 653 of file SGImplSvc.h.

◆ m_pIOVSvc

ServiceHandle<IIOVSvc> SGImplSvc::m_pIOVSvc
private

get the IOVSvc "just in time" (breaks recursion at initialize)

Definition at line 662 of file SGImplSvc.h.

◆ m_pPPS

IProxyProviderSvc* SGImplSvc::m_pPPS
private

Definition at line 646 of file SGImplSvc.h.

◆ m_pPPSHandle

ServiceHandle<IProxyProviderSvc> SGImplSvc::m_pPPSHandle
private

Definition at line 643 of file SGImplSvc.h.

◆ m_pStore

SG::DataStore* SGImplSvc::m_pStore
private

Definition at line 650 of file SGImplSvc.h.

◆ m_remap_impl

SG::RemapImpl* SGImplSvc::m_remap_impl
private

Definition at line 668 of file SGImplSvc.h.

◆ m_remapMutex

mutex_t SGImplSvc::m_remapMutex
mutableprivate

Definition at line 688 of file SGImplSvc.h.

◆ m_slotNumber

int SGImplSvc::m_slotNumber
private

The Hive slot number for this store, or -1 if this isn't a Hive store.

Definition at line 674 of file SGImplSvc.h.

◆ m_storeLoaded

bool SGImplSvc::m_storeLoaded
private

FIXME hack needed by loadEventProxies.

Definition at line 664 of file SGImplSvc.h.

◆ m_stringpool

SG::StringPool SGImplSvc::m_stringpool
private

Definition at line 666 of file SGImplSvc.h.

◆ m_stringPoolMutex

mutex_t SGImplSvc::m_stringPoolMutex
mutableprivate

Definition at line 689 of file SGImplSvc.h.

◆ m_trash

std::list<DataObject*> SGImplSvc::m_trash
private

The Recycle Bin.

Definition at line 651 of file SGImplSvc.h.


The documentation for this class was generated from the following files: