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:
StoreID::type storeID () const
 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 AthenaOutputStream
 access proxyRange()
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
StatusCode proxyRange (const CLID &id, SG::ConstProxyIterator &beg, SG::ConstProxyIterator &end) const
 return a range to all proxies of a given CLID
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 105 of file SGImplSvc.h.

Member Typedef Documentation

◆ lock_t

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

Definition at line 695 of file SGImplSvc.h.

◆ mutex_t

typedef std::recursive_mutex SGImplSvc::mutex_t
private

Definition at line 694 of file SGImplSvc.h.

◆ sgkey_t

Definition at line 338 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 102 of file SGImplSvc.cxx.

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

◆ ~SGImplSvc()

SGImplSvc::~SGImplSvc ( )
finaloverridevirtual

Standard Destructor.

Definition at line 137 of file SGImplSvc.cxx.

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

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 961 of file SGImplSvc.cxx.

962{
964 DataProxy* theProxy(proxy(id, true));
965 return (0 == theProxy) ? 0 : theProxy->accessData();
966}
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:696
std::lock_guard< mutex_t > lock_t
Definition SGImplSvc.h:695

◆ 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 969 of file SGImplSvc.cxx.

970{
972 DataProxy* theProxy(proxy(id, key, true));
973 return (0 == theProxy) ? 0 : theProxy->accessData();
974}

◆ addAlias()

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

Definition at line 669 of file SGImplSvc.cxx.

670{
671 if (0 == proxy) {
672 warning() << "addAlias: no target DataProxy given, Cannot alias to a non-existing object"
673 << endmsg;
674 return StatusCode::FAILURE;
675 }
676
677 // add key to proxy and to ProxyStore
678 return m_pStore->addAlias(aliasKey, proxy);
679}
#define endmsg

◆ 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 1598 of file SGImplSvc.cxx.

1603{
1604 // Automatically make all legal base class symlinks
1605 if (!tinfo) {
1607 }
1608 const SG::BaseInfoBase* bib = nullptr;
1609 if (tinfo) {
1610 bib = SG::BaseInfoBase::find (*tinfo);
1611 }
1612 if (!bib) {
1613 // Could succeed where the previous fails if clid for DataVector<T>
1614 // but tinfo is for ConstDataVector<DataVector<T> >.
1616 }
1617 if ( bib ) {
1618 const std::vector<CLID>& bases = bib->get_bases();
1619 for ( std::size_t i = 0, iMax = bases.size(); i < iMax; ++i ) {
1620 if ( bases[i] != clid ) {
1621 if ( addSymLink( bases[i], dp ).isSuccess() ) {
1622 // register with t2p
1623 if (dp->object())
1624 this->t2pRegister( SG::DataProxy_cast( dp, bases[i] ), dp ).ignore();
1625 }
1626 else {
1627 warning() << "record_impl: Doing auto-symlinks for object with CLID "
1628 << clid
1629 << " and SG key " << key
1630 << ": Proxy already set for base CLID " << bases[i]
1631 << "; not making auto-symlink." << endmsg;
1632 }
1633 }
1634 }
1635
1636 // Handle copy conversions.
1637 {
1638 for (CLID copy_clid : bib->get_copy_conversions()) {
1639 if (m_pStore->addSymLink (copy_clid, dp).isFailure()) {
1640 warning() << "record_impl: Doing auto-symlinks for object with CLID "
1641 << clid
1642 << " and SG key " << key
1643 << ": Proxy already set for copy-conversion CLID "
1644 << copy_clid
1645 << "; not making auto-symlink." << endmsg;
1646 }
1647 }
1648 }
1649 }
1650 else {
1651 if (warn_nobib) {
1652 warning() << "record_impl: Could not find suitable SG::BaseInfoBase for CLID ["
1653 << clid << "] (" << key << ") !\t"
1654 << "No auto-symlink established !"
1655 << endmsg;
1656 }
1657 }
1658}
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:586
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Definition BaseInfo.cxx:306
std::vector< CLID > get_copy_conversions() const
Return known copy conversions.
Definition BaseInfo.cxx:469
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 589 of file SGImplSvc.cxx.

590{
591 if (0 == dp) {
592 warning() << "addSymLink: no target DataProxy found. Sorry, can't link to a non-existing data object"
593 << endmsg;
594 return StatusCode::FAILURE;
595 }
596 StatusCode sc = m_pStore->addSymLink(linkid, dp);
597
598 // If the symlink is a derived->base conversion, then we may have
599 // a different transient pointer for the symlink.
600 if (sc.isSuccess() && dp->object()) {
601 void* baseptr = SG::DataProxy_cast (dp, linkid);
602 if (baseptr)
603 this->t2pRegister (baseptr, dp).ignore();
604 }
605 return sc;
606}
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 783 of file SGImplSvc.cxx.

784{
786 return m_pStore->addToStore (id, proxy);
787}

◆ associateAux_impl() [1/2]

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

Definition at line 1838 of file SGImplSvc.cxx.

1841{
1843 SG_MSG_VERBOSE("called associateAux_impl for key " + key);
1844 // no Aux store set yet
1845 if (!ptr->hasStore()) {
1846 SG::DataProxy* dp = proxy (auxclid, key + "Aux.", true);
1847 if (dp) {
1848 if (!dp->isConst()) {
1849 SG::IAuxStore* pAux = SG::DataProxy_cast<SG::IAuxStore> (dp);
1850 if (pAux) {
1851 ptr->setStore (pAux);
1852 return true;
1853 }
1854 }
1855
1856 const SG::IConstAuxStore* pAux = SG::DataProxy_cast<SG::IConstAuxStore> (dp);
1857 if (pAux) {
1858 ptr->setStore (pAux);
1859 return true;
1860 }
1861 }
1862 }
1863 return false;
1864}
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ associateAux_impl() [2/2]

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

Definition at line 1803 of file SGImplSvc.cxx.

1806{
1807 // If we already have the aux store (as should usually be the case), return
1808 // without taking out the SG lock. Otherwise, we can deadlock
1809 // if another thread is also trying to dereference a link to the aux store.
1810 // (Should _not_ be holding the SG lock when dereferencing the link!)
1811 if (ptr->hasStore()) return true;
1812
1814 SG_MSG_VERBOSE("called associateAux_impl for key " + key);
1815 // no Aux store set yet
1816 if (!ptr->hasStore()) {
1817 SG::DataProxy* dp = proxy (auxclid, key + "Aux.", true);
1818 if (dp) {
1819 if (!dp->isConst()) {
1820 SG::IAuxStore* pAux = SG::DataProxy_cast<SG::IAuxStore> (dp);
1821 if (pAux) {
1822 ptr->setStore (pAux);
1823 return true;
1824 }
1825 }
1826
1827 const SG::IConstAuxStore* pAux = SG::DataProxy_cast<SG::IConstAuxStore> (dp);
1828 if (pAux) {
1829 ptr->setStore (pAux);
1830 return true;
1831 }
1832 }
1833 }
1834 return false;
1835}

◆ 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 1679 of file SGImplSvc.cxx.

1680{
1681 m_newBoundHandles[std::this_thread::get_id()].push_back (handle);
1682}
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:692

◆ 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 1485 of file SGImplSvc.cxx.

1485 {
1487
1488 // Remove transient pointer entries for this proxy.
1489 // But do that only if the proxy has a valid object.
1490 // Otherwise, we could trigger I/O --- which we don't want since it's useless
1491 // (we'd just destroy the object immediately). In some cases it can also
1492 // lead to a deadlock (see ATR-24482).
1493 if (dp->isValidObject()) {
1494 SG::DataProxy::CLIDCont_t clids = dp->transientID();
1495 SG::DataProxy::CLIDCont_t::const_iterator i(clids.begin()), e(clids.end());
1496 while (i != e) {
1497 t2pRemove(SG::DataProxy_cast (dp, *i++));
1498 }
1499 }
1500
1501 bool hard_reset = (m_numSlots > 1);
1502 dp->reset (hard_reset);
1503}
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 268 of file SGImplSvc.cxx.

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

◆ 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 1564 of file SGImplSvc.cxx.

1565{
1568 store()->tRange(s_iter, s_end).ignore();
1569
1570 for ( ; s_iter != s_end; ++s_iter ) {
1571 if ( s_iter->second.find( key ) != s_iter->second.end() ) {
1572 return s_iter->first;
1573 }
1574 }
1575
1576 return CLID_NULL;
1577}
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 932 of file SGImplSvc.cxx.

933{
935
936 using std::distance;
937 DataStore::ConstStoreIterator s_iter, s_end;
938 store()->tRange(s_iter, s_end).ignore();
939
940 std::vector<CLID> clids;
941 clids.reserve( distance( s_iter, s_end ) );
942
943 for (; s_iter != s_end; ++s_iter ) {
944 const CLID id = s_iter->first;
945 clids.push_back (id);
946 }
947
948 return clids;
949}
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 1580 of file SGImplSvc.cxx.

1581{
1583 std::vector<CLID> clids;
1585 store()->tRange(s_iter, s_end).ignore();
1586
1587 for ( ; s_iter != s_end; ++s_iter ) {
1588 if ( s_iter->second.find( key ) != s_iter->second.end() ) {
1589 clids.push_back(s_iter->first);
1590 }
1591 }
1592
1593 return clids;
1594}

◆ commitNewDataObjects()

void SGImplSvc::commitNewDataObjects ( )
finaloverridevirtual

Reset handles added since the last call to commit.

Definition at line 1661 of file SGImplSvc.cxx.

1661 {
1663
1664 // Reset handles added since the last call to commit.
1665 bool hard_reset = (m_numSlots > 1);
1666 std::vector<IResetable*> handles;
1667 m_newBoundHandles[std::this_thread::get_id()].swap (handles);
1668 for (IResetable* h : handles)
1669 h->reset (hard_reset);
1670}

◆ 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 689 of file SGImplSvc.cxx.

690{
691 try {
692 return (0 != proxy(id, key, true));
693 } catch(...) { return false; }
694}

◆ createKey()

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

creates a key internally if none specified by client

Definition at line 262 of file SGImplSvc.cxx.

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

◆ 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 1722 of file SGImplSvc.cxx.

1725{
1726 // This lock was here originally, but is probably not really needed ---
1727 // both DataProxy and the I/O components have their own locks.
1728 // Further, this was observed to cause deadlocks for the detector store,
1729 // and would in general be expected to be a contention issue.
1730 //lock_t lock (m_mutex);
1731 return cvt->createObj (addr, refpObject);
1732}

◆ 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 511 of file SGImplSvc.cxx.

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

1333 {
1335 while (!m_trash.empty()) {
1336 m_trash.front()->release(); //delete the bad data object
1337 m_trash.pop_front(); //remove pointer from list
1338 }
1339}
std::list< DataObject * > m_trash
The Recycle Bin.
Definition SGImplSvc.h:660

◆ finalize()

StatusCode SGImplSvc::finalize ( )
finaloverridevirtual

Service finalization.

Definition at line 303 of file SGImplSvc.cxx.

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

◆ 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 info() << '\n' << dump() << endl
238 << endmsg;
239 }
240 }
241}
std::string dump() const
dump objects in store.

◆ hiveProxyDict()

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

implements IHiveStore interface for compat with Hive

Definition at line 229 of file SGImplSvc.h.

229 {
230 return this;
231 }

◆ initialize()

StatusCode SGImplSvc::initialize ( )
finaloverridevirtual

Service initialization.

Definition at line 147 of file SGImplSvc.cxx.

147 {
148
149 verbose() << "Initializing " << name() << endmsg;
150
151 CHECK( Service::initialize() );
152
153 if (!m_pStore)
154 m_pStore = new DataStore (*this);
155 if (!m_remap_impl)
156 m_remap_impl = new SG::RemapImpl;
157
158 //properties accessible from now on
159
161 // If this is the default event store (StoreGateSvc), then declare
162 // our arena as the default for memory allocations.
163 if (this->storeID() == StoreID::EVENT_STORE) {
164 m_arena.makeCurrent();
165 SG::CurrentEventStore::setStore (this);
166 }
167 // set up the incident service:
168 if (!(m_pIncSvc.retrieve()).isSuccess()) {
169 error() << "Could not locate IncidentSvc "
170 << endmsg;
171 return StatusCode::FAILURE;
172 }
173
174 // We explicitly do not retrieve m_pIOVSvc and rely on retrieval
175 // on first use to avoid an initialization loop here.
176
177 CHECK( m_pDataLoader.retrieve() );
178 CHECK( m_pCLIDSvc.retrieve() );
179
180 if (!m_pPPSHandle.empty()) {
181 CHECK( m_pPPSHandle.retrieve() );
183 }
184
185 if ( m_pPPS && (m_pPPS->preLoadProxies(*m_pStore)).isFailure() )
186 {
187 SG_MSG_DEBUG(" Failed to preLoad proxies");
188 return StatusCode::FAILURE;
189 }
190
191 // Get hold of History Service
192 if (m_ActivateHistory) {
193 CHECK( m_pHistorySvc.retrieve() );
194 }
195
196 return StatusCode::SUCCESS;
197}
#define CHECK(...)
Evaluate an expression and check for errors.
StoreID::type storeID() const
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

◆ isSymLinked()

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

Definition at line 504 of file SGImplSvc.cxx.

505{
506 return (0 != dp) ? dp->transientID(linkID) : false;
507}

◆ 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 495 of file SGImplSvc.cxx.

498{
500 return store()->keys(id, vkeys, includeAlias, onlyValid);
501}
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 1393 of file SGImplSvc.cxx.

1394{
1396 return m_stringpool.keyToString (key);
1397}
mutex_t m_stringPoolMutex
Definition SGImplSvc.h:698

◆ 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 1409 of file SGImplSvc.cxx.

1410{
1412 return m_stringpool.keyToString (key, clid);
1413}

◆ loadEventProxies()

StatusCode SGImplSvc::loadEventProxies ( )

load proxies at begin event

Definition at line 243 of file SGImplSvc.cxx.

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

◆ locatePersistent()

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

Definition at line 1214 of file SGImplSvc.cxx.

1216{
1217 DataProxy* dp = m_pStore->proxy(tAddr);
1218
1219 if (checkValid && 0 != dp) {
1220 return dp->isValid() ? dp : 0;
1221 } else {
1222 return dp;
1223 }
1224}

◆ 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 1703 of file SGImplSvc.cxx.

1704{
1706 m_arena.makeCurrent();
1707 SG::CurrentEventStore::setStore (this);
1708}

◆ 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 1451 of file SGImplSvc.cxx.

1452{
1453 // We should hold m_stringPoolMutex before touching the pool.
1454 // But if we acquire the locks for both this and the other store,
1455 // we risk a deadlock. So first copy the other pool, so that we
1456 // don't need to hold both locks at the same time.
1457 SG::StringPool tmp;
1458 {
1459 lock_t lock (other.m_stringPoolMutex);
1460 tmp = other.m_stringpool;
1461 }
1463 return m_stringpool.merge (tmp);
1464}

◆ msg_update_handler()

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

callback for output level property

Definition at line 1274 of file SGImplSvc.cxx.

1275{
1276 setUpMessaging();
1277 updateMsgStreamOutputLevel( outputLevel() );
1278 msgSvc()->setOutputLevel(name(), outputLevel());
1279}
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 922 of file SGImplSvc.cxx.

923{
925 const std::vector<SG::DataProxy*>& proxies = store()->proxies();
926 std::vector<const SG::DataProxy*> ret (proxies.begin(), proxies.end());
927 return ret;
928}
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 716 of file SGImplSvc.cxx.

717{
718 return proxy(id, false);
719}

◆ 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 722 of file SGImplSvc.cxx.

723{
724 DataProxy* dp = nullptr;
725 {
727 dp = m_pStore->proxy(id);
728 if (0 == dp && 0 != m_pPPS) {
729 SG::DataStore* pStore ATLAS_THREAD_SAFE = m_pStore;
730 dp = m_pPPS->retrieveProxy(id, string("DEFAULT"), *pStore);
731 }
732 }
734 // Be sure to release the lock before this.
735 // isValid() may call back to the store, so we could otherwise deadlock..
736 if (checkValid && 0 != dp) {
737 // FIXME: For keyless retrieve, this checks only the first instance
738 // of the CLID in store. If that happens to be invalid, but the second
739 // is valid - this does not work (when checkValid is requested).
740 return dp->isValid() ? dp : 0;
741 }
742 return dp;
743}
#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 248 of file SGImplSvc.h.

249 { 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 300 of file SGImplSvc.h.

301 { 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 746 of file SGImplSvc.cxx.

747{
748 return proxy(id, key, false);
749}

◆ 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 752 of file SGImplSvc.cxx.

753{
754 DataProxy* dp = nullptr;
755 {
757 dp = m_pStore->proxy(id, key);
758#ifdef DEBUG_SGIMPL
759 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");
760#endif
761 if (0 == dp && 0 != m_pPPS) {
762 SG::DataStore* pStore ATLAS_THREAD_SAFE = m_pStore;
763 dp = m_pPPS->retrieveProxy(id, key, *pStore);
764#ifdef DEBUG_SGIMPL
765 if (!dp) dbg::print(stderr, "::SGImplSvc::proxy(name={}, key={}): data proxy is still null\n", this->name(), key);
766#endif
767 }
768 }
769 // Be sure to release the lock before this.
770 // isValid() may call back to the store, so we could otherwise deadlock..
771 if (checkValid && 0 != dp && !(dp->isValid())) {
772 dp = 0;
773 }
774 return dp;
775}

◆ 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 707 of file SGImplSvc.cxx.

708{
709 // No lock needed here --- the T2pmap held by DataStore has its own locking
710 // (and we were seeing contention here).
711 //lock_t lock (m_mutex);
712 return m_pStore->locatePersistent(pTransient);
713}

◆ 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 899 of file SGImplSvc.cxx.

900{
901 return m_pStore->proxy_exact_unlocked (sgkey, m_mutex);
902}

◆ proxyProviderSvc()

IProxyProviderSvc * SGImplSvc::proxyProviderSvc ( )

Return current ProxyProviderSvc.

◆ proxyRange()

StatusCode SGImplSvc::proxyRange ( const CLID & id,
SG::ConstProxyIterator & beg,
SG::ConstProxyIterator & end ) const
private

return a range to all proxies of a given CLID

Definition at line 1282 of file SGImplSvc.cxx.

1284 {
1286 return m_pStore->pRange(id,begin,end);
1287}

◆ 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 1345 of file SGImplSvc.cxx.

1347 {
1348
1349 DataHistory *dho;
1350 dho = m_pHistorySvc->createDataHistoryObj( id, key, store );
1351
1352 std::string idname;
1353 StatusCode sc = m_pCLIDSvc->getTypeNameOfID(id, idname);
1354 if (sc.isFailure() || idname.empty() ) {
1355 idname = std::to_string(id);
1356 }
1357 idname += '/';
1358 idname += key;
1359
1360 DataObject* obj = SG::asStorable(dho);
1361
1362 const bool ALLOWOVERWRITE(false);
1363 if (record_impl(obj, idname, dho, allowMods, resetOnly, ALLOWOVERWRITE,
1364 &typeid(DataHistory)) == nullptr)
1365 return StatusCode::FAILURE;
1366 return StatusCode::SUCCESS;
1367}
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 1086 of file SGImplSvc.cxx.

1090{
1091 CLID clid = pDObj->clID();
1092 std::string rawKey(key);
1093 bool isVKey(SG::VersionedKey::isVersionedKey(key));
1094 if (isVKey) {
1095 //FIXME VersionedKeys will need to be handled more efficiently
1096 SG::VersionedKey vk(rawKey);
1097 DataProxy *dp(proxy(clid, vk.key()));
1098 if (dp) {
1099 //proxies primary key
1100 const std::string& pTAName(dp->name());
1101 //original key as versioned
1102 SG::VersionedKey primaryVK(pTAName);
1103
1104 //if the existing matching object has no version
1105 //create a versioned alias for the original unversioned key
1106 //so it will remain accessible
1107 if (!SG::VersionedKey::isVersionedKey(pTAName)) {
1108 if (!(this->addAlias(primaryVK.rawVersionKey(), dp)).isSuccess()) {
1109 warning() << "record_impl: Could not setup alias key "
1110 << primaryVK.rawVersionKey()
1111 << " for unversioned object " << pTAName
1112 << endmsg;
1113 return nullptr;
1114 }
1115 }
1116 if (vk.isAuto()) {
1117 //make a new versioned key incrementing the existing version
1118 SG::VersionedKey newVK(primaryVK.key(), primaryVK.version()+1);
1119 //FIXME this will fail in a confusing way if version+1 is in use
1120 //FIXME need a better error message below, probably looking at all
1121 //FIXME aliases
1122 rawKey = newVK.rawVersionKey();
1123 }
1124 }
1125 }
1126 if (!allowOverwrite && m_pPPS) {
1127 //do not overwrite a persistent object
1128 DataProxy* dp = m_pStore->proxy (clid, rawKey);
1129 if (!dp) {
1130 dp = m_pPPS->retrieveProxy(clid, rawKey, *m_pStore);
1131 }
1132 if (dp && dp->provider()) {
1133 std::string clidTypeName;
1134 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1135 warning() << "record_impl: you are recording an object with key "
1136 << rawKey << ", type " << clidTypeName
1137 << " (CLID " << clid << ')'
1138 << "\n There is already a persistent version of this object. Recording a duplicate may lead to unreproducible results and it is deprecated."
1139 << endmsg;
1140 }
1141 }
1142 //now check whether raw_ptr has already been recorded
1143 //We need to do this before we create the bucket, the proxy etc
1144 SG::DataProxy* dp(proxy(raw_ptr));
1145 if (0 != dp) {
1146 std::string clidTypeName;
1147 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1148 warning() << "record_impl: failed for key="<< rawKey << ", type "
1149 << clidTypeName
1150 << " (CLID " << clid << ')'
1151 << "\n object @" << raw_ptr
1152 << " already in store with key="<< dp->name()
1153 << ". Will not record a duplicate! "
1154 << endmsg;
1155 if (pDObj != dp->object()) {
1156 DataBucketBase* pDBB(dynamic_cast<DataBucketBase*>(pDObj));
1157 if (!pDBB) std::abort();
1158 pDBB->relinquish(); //don't own the data obj already recorded!
1159 }
1160 this->recycle(pDObj);
1161 return nullptr;
1162 }
1163
1164
1165 // setup the proxy
1166 dp = setupProxy( clid, rawKey, pDObj, allowMods, resetOnly );
1167 if ( 0 == dp ) {
1168 std::string clidTypeName;
1169 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1170 warning() << "record_impl: Problem setting up the proxy for object @"
1171 << raw_ptr
1172 << "\n recorded with key " << rawKey
1173 << " of type " << clidTypeName
1174 << " (CLID " << clid << ") in DataObject @" << pDObj
1175 << endmsg;
1176
1177 return nullptr;
1178 }
1179
1180 // record in t2p:
1181 if ( !(this->t2pRegister( raw_ptr, dp )).isSuccess() ) {
1182 std::string clidTypeName;
1183 m_pCLIDSvc->getTypeNameOfID(clid, clidTypeName).ignore();
1184 warning() << "record_impl: can not add to t2p map object @" <<raw_ptr
1185 << "\n with key " << rawKey
1186 << " of type " << clidTypeName
1187 << " (CLID " << clid << ')'
1188 << endmsg;
1189 return nullptr;
1190 }
1191
1192 addAutoSymLinks (rawKey, clid, dp, tinfo);
1193
1194 //handle versionedKeys: we register an alias with the "true" key
1195 //unless an object as already been recorded with that key.
1196 //Notice that addAlias overwrites any existing alias, so a generic
1197 //retrieve will always return the last version added
1198 //FIXME not the one with the highest version
1199 if (isVKey) {
1200 SG::VersionedKey vk(rawKey);
1201 if (!(this->addAlias(vk.key(), dp)).isSuccess()) {
1202 warning() << "record_impl: Could not setup alias key " << vk.key()
1203 << " for VersionedKey " << rawKey
1204 << ". Generic access to this object with clid" << clid
1205 << " will not work"
1206 << endmsg;
1207 }
1208 }
1209
1210 return dp;
1211}
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
StatusCode addAlias(const std::string &aliasKey, SG::DataProxy *dp)
static bool isVersionedKey(const char *)
quickly determine whether a string has the right format to be a VK

◆ 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 336 of file SGImplSvc.cxx.

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

426{
428 assert(0 != pAddress);
429
430 CLID dataID = pAddress->clID();
431
432 string gK = (pAddress->par())[1]; // transient name by convention
433 if (gK.empty()) gK = (pAddress->par())[0]; // FIXME backward compatibility
434 if (gK.empty()) gK = createKey(dataID);
435
436 return this->recordAddress(gK, std::move(pAddress), clearAddressFlag, bases);
437}
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 810 of file SGImplSvc.cxx.

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

◆ recycle()

void SGImplSvc::recycle ( DataObject * pBadDObj)
private

put a bad (unrecordable) dobj away

Definition at line 1326 of file SGImplSvc.cxx.

1326 {
1327 assert(pBadDObj);
1328 pBadDObj->addRef();
1329 m_trash.push_back(pBadDObj);
1330}

◆ 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 1428 of file SGImplSvc.cxx.

1431{
1433 if (!m_stringpool.registerKey (key, str, clid)) {
1434 CLID clid2;
1435 const std::string* str2 = m_stringpool.keyToString (key, clid2);
1436 REPORT_MESSAGE (MSG::WARNING) << "The numeric key " << key
1437 << " maps to multiple string key/CLID pairs: "
1438 << *str2 << "/" << clid2 << " and "
1439 << str << "/" << clid;
1440 }
1441}
#define REPORT_MESSAGE(LVL)
Report a message.

◆ reinitialize()

StatusCode SGImplSvc::reinitialize ( )
finaloverridevirtual

Service reinitialization.

Definition at line 324 of file SGImplSvc.cxx.

324 {
325 verbose() << "Reinitializing " << name() << endmsg ;
326 const bool FORCEREMOVE(true);
327 clearStore(FORCEREMOVE).ignore();
328 //not in v20r2p2! return Service::reinitialize();
329 return StatusCode::SUCCESS;
330}

◆ 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 1468 of file SGImplSvc.cxx.

1468 {
1470 DataProxy *pP(0);
1471 if (0 != (pP = proxy(id, key))) {
1472 // remove all entries from t2p map
1473 SG::DataProxy::CLIDCont_t clids = pP->transientID();
1474 SG::DataProxy::CLIDCont_t::const_iterator i(clids.begin()), e(clids.end());
1475 while (i != e) t2pRemove(SG::DataProxy_cast (pP, *i++));
1476 DataBucketBase *pDBB(dynamic_cast<DataBucketBase*>(pP->object()));
1477 //tell the bucket to let go of the data object
1478 if (0 != pDBB) pDBB->relinquish(); //somebody else better took ownership
1479 bool hard_reset = (m_numSlots > 1);
1480 pP->reset (hard_reset);
1481 }
1482}

◆ 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 1513 of file SGImplSvc.cxx.

1516{
1518 SG::RemapImpl::remap_t payload;
1519 payload.target = target;
1520 payload.index_offset = index_offset;
1521 m_remap_impl->m_remaps[source] = payload;
1522}

◆ remove()

StatusCode SGImplSvc::remove ( const void * pObject)

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

Definition at line 1309 of file SGImplSvc.cxx.

1310{
1312 return removeProxy(proxy(pObject), pObject);
1313}
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 1318 of file SGImplSvc.cxx.

1319{
1321 const bool FORCEREMOVE(true);
1322 return removeProxy(proxy(pObject), pObject, FORCEREMOVE);
1323}

◆ 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 1227 of file SGImplSvc.cxx.

1229{
1231 // check if valid proxy
1232 if (0 == proxy) return StatusCode::FAILURE;
1233
1234 if (0 == pTrans) {
1235 DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(proxy->object());
1236 if (bucket) pTrans = bucket->object();
1237 }
1238
1239 // remove all entries from t2p map
1240 // --- only if the proxy actually has an object!
1241 // otherwise, we can trigger I/O.
1242 // besides being useless here, we can get deadlocks if we
1243 // call into the I/O code while holding the SG lock.
1244 if (proxy->isValidObject()) {
1245 this->t2pRemove(pTrans);
1246 SG::DataProxy::CLIDCont_t clids = proxy->transientID();
1247 for (SG::DataProxy::CLIDCont_t::const_iterator i = clids.begin();
1248 i != clids.end();
1249 ++i)
1250 {
1251 void* ptr = SG::DataProxy_cast (proxy, *i);
1252 this->t2pRemove(ptr);
1253 }
1254 }
1255
1256 // remove from store
1257 return m_pStore->removeProxy(proxy, forceRemove, true);
1258}
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 1772 of file SGImplSvc.cxx.

1775{
1779
1780 if (!(proxyRange(clid,first,end)).isSuccess()) {
1781 std::string typnam;
1782 m_pCLIDSvc->getTypeNameOfID(clid, typnam).ignore();
1783 SG_MSG_DEBUG("retrieve(range): no object found "
1784 << " of type " << typnam
1785 << "(CLID " << clid << ')');
1786 }
1787
1788 (ciend.setState(end, end, true)).ignore();
1789
1790 if (!(cibegin.setState(first, end, true)).isSuccess()) {
1791 std::string typnam;
1792 m_pCLIDSvc->getTypeNameOfID(clid, typnam).ignore();
1793 SG_MSG_DEBUG("retrieve(range): Can't initialize iterator for object range "
1794 << " of type " << typnam
1795 << "(CLID " << clid << ')');
1796 return StatusCode::FAILURE;
1797 }
1798
1799 return StatusCode::SUCCESS;
1800}
StatusCode proxyRange(const CLID &id, SG::ConstProxyIterator &beg, SG::ConstProxyIterator &end) const
return a range to all proxies of a given CLID
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 636 of file SGImplSvc.cxx.

638{
640
641 SG::DataProxy* dp(0);
642 dp = proxy(clid, key);
643 if (0 == dp) {
644 error() << "setAlias: problem setting alias "
645 << std::string(aKey) << '\n'
646 << "DataObject does not exist, record before setting alias."
647 << endmsg;
648 return StatusCode::FAILURE;
649 }
650
651 StatusCode sc = addAlias(aKey, dp);
652 if (sc.isFailure()) {
653 error() << "setAlias: problem setting alias "
654 << (std::string)aKey << '\n'
655 << "DataObject does not exist, record before setting alias."
656 << endmsg;
657 return StatusCode::FAILURE;
658 }
659
660 return StatusCode::SUCCESS;
661}

◆ 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 609 of file SGImplSvc.cxx.

610{
612
613 SG::DataProxy* dp(0);
614 dp = proxy(pObject);
615 if (0 == dp) {
616 error() << "setAlias: problem setting alias "
617 << aliasKey << '\n'
618 << "DataObject does not exist, record before setting alias."
619 << endmsg;
620 return StatusCode::FAILURE;
621 }
622
623 StatusCode sc = addAlias(aliasKey, dp);
624 if (sc.isFailure()) {
625 error() << "setAlias: problem setting alias "
626 << aliasKey << '\n'
627 << "DataObject does not exist, record before setting alias."
628 << endmsg;
629 return StatusCode::FAILURE;
630 }
631
632 return StatusCode::SUCCESS;
633}

◆ 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 663 of file SGImplSvc.cxx.

664{
665 return addAlias( aliasKey, proxy );
666}

◆ setConst()

StatusCode SGImplSvc::setConst ( const void * pointer)

prevent downstream clients from modifying the pointed-at dobj

Definition at line 1289 of file SGImplSvc.cxx.

1290{
1292 // Check if DataProxy does not exist
1293 DataProxy * dp = proxy(pObject);
1294
1295 if (0 == dp)
1296 {
1297 warning() << "setConst: NO Proxy for the dobj you want to set const"
1298 << endmsg;
1299 return StatusCode::FAILURE;
1300 }
1301
1302 dp->setConst();
1303 return StatusCode::SUCCESS;
1304}

◆ 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 911 of file SGImplSvc.cxx.

912{
913 m_slotNumber = slot;
914 m_numSlots = numSlots;
915
916 SG::ArenaHeader* header = SG::ArenaHeader::defaultHeader();
917 header->setArenaForSlot (slot, &m_arena);
918}

◆ setStoreID()

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

set store ID. request forwarded to DataStore:

set store id in DataStore:

Definition at line 481 of file SGImplSvc.cxx.

482{
484 store()->setStoreID(id);
485}

◆ 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 439 of file SGImplSvc.cxx.

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

◆ 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 1754 of file SGImplSvc.cxx.

1755{
1757 SG::DataProxy* dp =proxy (ClassID_traits<DataHeader>::ID(), key, true);
1758 if (dp) {
1760 if (dh) {
1761 return dh->begin()->getToken()->dbID().toString();
1762 }
1763 }
1764 return "";
1765}
std::vector< DataHeaderElement >::const_iterator begin() const

◆ start()

StatusCode SGImplSvc::start ( )
finaloverridevirtual

Service start.

Definition at line 199 of file SGImplSvc.cxx.

199 {
200
201 verbose() << "Start " << name() << endmsg;
202 /*
203 // This will need regFcn clients to be updated first.
204 if ( 0 == m_pPPS || (m_pPPS->preLoadProxies(*m_pStore)).isFailure() ) {
205 debug() << " Failed to preLoad proxies"
206 << endmsg;
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 verbose() << "Stop " << name() << endmsg;
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 verbose() << "stop: setting service priority to " << pISM->getPriority(name())
226 << " so that event stores get finalized and cleared before other stores" <<endmsg;
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 551 of file SGImplSvc.cxx.

552{
553 return m_pStore;
554}

◆ store() [2/2]

const DataStore * SGImplSvc::store ( ) const
private

Definition at line 557 of file SGImplSvc.cxx.

558{
559 return m_pStore;
560}

◆ storeID()

StoreID::type SGImplSvc::storeID ( ) const

get store ID. request forwarded to DataStore:

get store id from DataStore:

Definition at line 487 of file SGImplSvc.cxx.

488{
490 return store()->storeID();
491}
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 1379 of file SGImplSvc.cxx.

1380{
1382 return m_stringpool.stringToKey (str, clid);
1383}

◆ 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 577 of file SGImplSvc.cxx.

578{
580 SG::DataProxy* dp(proxy(id, key, false));
581 // if symLink already exists, just return success
582 return isSymLinked(linkID,dp) ?
583 StatusCode::SUCCESS :
584 addSymLink(linkID,dp);
585}
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 566 of file SGImplSvc.cxx.

567{
569 SG::DataProxy* dp(proxy(pObject));
570
571 // if symLink already exists, just return success
572 return isSymLinked(linkID,dp) ?
573 StatusCode::SUCCESS :
574 addSymLink(linkID,dp);
575}

◆ t2pRegister()

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

forwarded to DataStore

Definition at line 1261 of file SGImplSvc.cxx.

1262{
1263 return m_pStore->t2pRegister(pTrans, pPers);
1264}

◆ t2pRemove()

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

forwarded to DataStore

Definition at line 1268 of file SGImplSvc.cxx.

1269{
1270 m_pStore->t2pRemove(pTrans);
1271}

◆ 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 698 of file SGImplSvc.cxx.

699{
700 try {
701 return (0 != transientProxy(id, key));
702 } catch(...) { return false; }
703}
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 953 of file SGImplSvc.cxx.

954{
956 DataProxy* dp(m_pStore->proxy(id, key));
957 return ( (0 != dp && dp->isValidObject()) ? dp : 0 );
958}

◆ 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 977 of file SGImplSvc.cxx.

979{
981 const bool checkValid = true;
982 DataProxy* a = proxy( id, keyA, checkValid );
983 DataProxy* b = proxy( id, keyB, checkValid );
984 if ( 0 == a || 0 == b ) { return false; }
985 DataObject* objA = a->accessData();
986 DataObject* objB = b->accessData();
987
988 if ( 0 == objA || 0 == objB ) { return false; }
989 // prevent 'accidental' release of DataObjects...
990 const unsigned int refCntA = objA->addRef();
991 const unsigned int refCntB = objB->addRef();
992 // in case swap is being specialized for DataObjects
993 using std::swap;
994 swap( objA, objB );
995 a->setObject( objA );
996 b->setObject( objB );
997 // and then restore old ref-count;
998 return ( (refCntA-1) == objA->release() &&
999 (refCntB-1) == objB->release() );
1000}
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 1533 of file SGImplSvc.cxx.

1535{
1537 SG::RemapImpl::remap_map_t::iterator i =
1538 m_remap_impl->m_remaps.find (sgkey_in);
1539 if (i == m_remap_impl->m_remaps.end())
1540 return false;
1541 const SG::RemapImpl::remap_t& payload = i->second;
1542 sgkey_out = payload.target;
1543 index_out = index_in + payload.index_offset;
1544 return true;
1545}

◆ typeCount()

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

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

Definition at line 681 of file SGImplSvc.cxx.

682{
684 return m_pStore->typeCount(id);
685}

◆ 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 1051 of file SGImplSvc.cxx.

1058{
1060 StatusCode sc(StatusCode::SUCCESS);
1061 SG::DataProxy* toRemove(proxy(clid, key, false));
1062 if (0 != toRemove) {
1063 toRemove->addRef();
1064 const bool FORCEREMOVE(true);
1065 sc =removeProxy(toRemove, (void*)0, FORCEREMOVE);
1066 }
1067 if (sc.isSuccess()) {
1068 const bool ALLOWOVERWRITE(true);
1069 const bool NORESET(false);
1070 if (record_impl( obj, key, raw_ptr, allowMods, NORESET, ALLOWOVERWRITE, tinfo) == nullptr)
1071 sc = StatusCode::FAILURE;
1072 else if ( m_ActivateHistory && noHist && store()->storeID() == StoreID::EVENT_STORE ) {
1073 sc = record_HistObj( obj->clID(), key, name(), allowMods, NORESET );
1074 }
1075 }
1076 //for detector store objects managed by IIOVSvc, replace the old proxy with the new one (#104311)
1077 if (toRemove && sc.isSuccess() && store()->storeID() == StoreID::DETECTOR_STORE) {
1078 sc = m_pIOVSvc->replaceProxy(toRemove, proxy(clid, key));
1079 }
1080 if (toRemove)
1081 toRemove->release();
1082 return sc;
1083}
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 1013 of file SGImplSvc.cxx.

1017{
1018 return typeless_record (obj, key, raw_ptr, allowMods, resetOnly, noHist,tinfo,
1019 nullptr, true);
1020}

◆ 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 1024 of file SGImplSvc.cxx.

1030{
1032 SG::DataProxy* proxy =
1033 record_impl( obj, key, raw_ptr, allowMods, resetOnly, !noOverwrite, tinfo);
1034 if ( proxy == nullptr )
1035 return StatusCode::FAILURE;
1036 if (proxy_ret)
1037 *proxy_ret = proxy;
1038
1039 if ( !m_ActivateHistory || noHist ) {
1040 return StatusCode::SUCCESS;
1041 }
1042
1043 if ( store()->storeID() != StoreID::EVENT_STORE ) {
1044 return StatusCode::SUCCESS;
1045 } else {
1046 return record_HistObj( obj->clID(), key, name(), allowMods, resetOnly );
1047 }
1048}

◆ 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 1003 of file SGImplSvc.cxx.

1006{
1007 return typeless_record (obj, key, raw_ptr, allowMods, resetOnly, noHist, 0,
1008 nullptr, true);
1009}

◆ typeless_retrievePrivateCopy()

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

Definition at line 1548 of file SGImplSvc.cxx.

1550{
1552 DataObject* obj = nullptr;
1553 SG::DataProxy* dp = proxy (clid, key);
1554 //we do not want anyone to mess up with our copy hence we release it immediately.
1555 if (dp && dp->isValid()) {
1556 obj = dp->object();
1557 obj->addRef();
1558 clearProxyPayload (dp);
1559 }
1560 return obj;
1561}
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 1691 of file SGImplSvc.cxx.

1692{
1693 std::vector<IResetable*>& v = m_newBoundHandles[std::this_thread::get_id()];
1694 std::vector<IResetable*>::iterator it =
1695 std::find (v.begin(), v.end(), handle);
1696 if (it != v.end())
1697 v.erase (it);
1698}

◆ ActiveStoreSvc

friend class ActiveStoreSvc
friend

Definition at line 643 of file SGImplSvc.h.

◆ AthenaInternal::py_sg_clearProxyPayload

◆ AthenaInternal::recordObjectToStore

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

◆ AthenaOutputStream

friend class AthenaOutputStream
friend

access proxyRange()

Definition at line 583 of file SGImplSvc.h.

◆ IOVDbSvc

friend class IOVDbSvc
friend

access clearProxyPayload

Definition at line 569 of file SGImplSvc.h.

◆ IOVSvcTool

friend class IOVSvcTool
friend

Definition at line 570 of file SGImplSvc.h.

◆ SG::VarHandleBase

friend class SG::VarHandleBase
friend

access typeless_record

Definition at line 591 of file SGImplSvc.h.

◆ StoreGateSvc

friend class StoreGateSvc
friend

Definition at line 589 of file SGImplSvc.h.

Member Data Documentation

◆ m_ActivateHistory

bool SGImplSvc::m_ActivateHistory
private

Activate the history service.

Definition at line 664 of file SGImplSvc.h.

◆ m_arena

SG::Arena SGImplSvc::m_arena
private

Allocation arena to associate with this store.

Definition at line 680 of file SGImplSvc.h.

◆ m_DumpArena

bool SGImplSvc::m_DumpArena
private

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

Definition at line 665 of file SGImplSvc.h.

◆ m_DumpStore

bool SGImplSvc::m_DumpStore
private

Dump Property flag: triggers dump() at EndEvent.

Definition at line 663 of file SGImplSvc.h.

◆ m_folderNameList

StringArrayProperty SGImplSvc::m_folderNameList
private

FolderNameList Property.

Definition at line 668 of file SGImplSvc.h.

◆ m_mutex

mutex_t SGImplSvc::m_mutex
mutableprivate

Definition at line 696 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 692 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 686 of file SGImplSvc.h.

◆ m_pCLIDSvc

ServiceHandle<IClassIDSvc> SGImplSvc::m_pCLIDSvc
private

Definition at line 649 of file SGImplSvc.h.

◆ m_pDataLoader

ServiceHandle<IConversionSvc> SGImplSvc::m_pDataLoader
private

Definition at line 650 of file SGImplSvc.h.

◆ m_pHistorySvc

ServiceHandle<IHistorySvc> SGImplSvc::m_pHistorySvc
private

Definition at line 657 of file SGImplSvc.h.

◆ m_pIncSvc

ServiceHandle<IIncidentSvc> SGImplSvc::m_pIncSvc
private

property

Definition at line 662 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 671 of file SGImplSvc.h.

◆ m_pPPS

IProxyProviderSvc* SGImplSvc::m_pPPS
private

Definition at line 655 of file SGImplSvc.h.

◆ m_pPPSHandle

ServiceHandle<IProxyProviderSvc> SGImplSvc::m_pPPSHandle
private

Definition at line 652 of file SGImplSvc.h.

◆ m_pStore

SG::DataStore* SGImplSvc::m_pStore
private

Definition at line 659 of file SGImplSvc.h.

◆ m_remap_impl

SG::RemapImpl* SGImplSvc::m_remap_impl
private

Definition at line 677 of file SGImplSvc.h.

◆ m_remapMutex

mutex_t SGImplSvc::m_remapMutex
mutableprivate

Definition at line 697 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 683 of file SGImplSvc.h.

◆ m_storeLoaded

bool SGImplSvc::m_storeLoaded
private

FIXME hack needed by loadEventProxies.

Definition at line 673 of file SGImplSvc.h.

◆ m_stringpool

SG::StringPool SGImplSvc::m_stringpool
private

Definition at line 675 of file SGImplSvc.h.

◆ m_stringPoolMutex

mutex_t SGImplSvc::m_stringPoolMutex
mutableprivate

Definition at line 698 of file SGImplSvc.h.

◆ m_trash

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

The Recycle Bin.

Definition at line 660 of file SGImplSvc.h.


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