11#include "GaudiKernel/DataObject.h"
12#include "GaudiKernel/IConverter.h"
13#include "GaudiKernel/GenericAddress.h"
14#include "GaudiKernel/MsgStream.h"
15#include "GaudiKernel/EventContext.h"
16#include "GaudiKernel/GaudiException.h"
52 static std::string storeName =
"StoreGateSvc";
53 m_storePtr = (*SG::getDataSourcePointerFunc) (storeName);
54 m_store = *m_storePtr;
55 if (store && store != m_store) {
63 if (*m_storePtr != m_store) {
64 *m_storePtr = m_store;
70 IProxyDict** m_storePtr;
79 template <
class GAUDIREF>
80 void setGaudiRef(GAUDIREF* pgref, GAUDIREF*& pMember) {
81 if (0 != pgref) pgref->addRef();
82 if (0 != pMember) pMember->release();
87 template <
class GAUDIREF>
88 void resetGaudiRef(GAUDIREF*& pMember) { setGaudiRef((GAUDIREF*)0, pMember); }
116 if (svc) svc->addRef();
129 if (svc) svc->addRef();
247 for (
auto ih: handles) {
248 if (0 != ih) ih->finalReset();
304 if ( 0 ==
count )
delete this;
335 bool canRelease = force;
338 MsgStream gLog(
m_ims,
"DataProxy");
339 if (gLog.level() <= MSG::VERBOSE) {
340 gLog << MSG::VERBOSE <<
"requestRelease(): "
341 << (canRelease ?
" release " :
" reset")
343 <<
name() <<
" CLID " <<
clID() <<
" address " << MSG::hex
344 << object() << MSG::dec <<
endmsg;
358 DataObject* dobj =
m_dObject.exchange (
nullptr);
359 std::atomic_thread_fence (std::memory_order_seq_cst);
360 setGaudiRef(dObject, dobj);
362 if (doreg) dobj->setRegistry(
this);
368 std::atomic_thread_fence (std::memory_order_seq_cst);
436 MsgStream gLog(
m_ims,
"DataProxy");
438 <<
"readData: ERROR recursive read for object"
440 <<
" Returning NULL DataObject pointer " <<
endmsg;
442 catch (
const GaudiException&) {
443 std::println (std::cerr,
"DataProxy::readData: Problem creating MsgStream");
450 IConverter* dataLoader;
476 SG::CurrentEventStore::Push push (
store);
478 DataObject* obj =
nullptr;
483 sc = dataLoader->createObj (
address, obj);
484 if (
sc.isSuccess()) {
486 return std::unique_ptr<DataObject>(obj);
489 MsgStream gLog(
m_ims,
"DataProxy");
491 <<
"readData: no address for " <<
clID() <<
"/" <<
name()
492 <<
" but validAddress returned true. You may be trying to retrieve"
493 <<
" alignments during initialization without having defined a campaign."
518 std::unique_ptr<DataObject> obju =
readData (objLock, &m_errno);
520 if (m_errno ==
NOIOA) {
521 MsgStream gLog(
m_ims,
"DataProxy");
523 <<
"accessData: IOA pointer not set" <<
endmsg;
526 MsgStream gLog(
m_ims,
"DataProxy");
528 <<
"accessData: conversion failed for data object "
530 <<
" Returning NULL DataObject pointer " <<
endmsg;
539 void* payload = bucket->
object();
540 m_t2p->t2pRegister(payload,
this);
546 std::vector<CLID> base_clids = bi->
get_bases();
547 for (
unsigned i=0; i < base_clids.size(); ++i) {
550 if (bobj && bobj != payload)
551 m_t2p->t2pRegister (bobj,
this);
556 MsgStream gLog(
m_ims,
"DataProxy");
558 <<
"accessData: ERROR registering object in t2p map"
560 <<
" Returning NULL DataObject pointer " <<
endmsg;
572 std::atomic_thread_fence (std::memory_order_seq_cst);
573 setObject(objLock, obju.release(),
true);
616 if (
nullptr == proxy || !proxy->isValid()) {
620 DataObject* pObject = proxy->accessData();
621 if (
nullptr == pObject) {
625 <<
"this proxy " << MSG::hex << proxy
626 << MSG::dec <<
" has a NULL data object ptr" <<
endmsg;
631 void* result =
SG::Storable_cast (pObject, clid, tinfo,
true, proxy, proxy->isConst());
632 if (
nullptr == result) {
637 if (proxy->transientID(clid) &&
645 if (!proxy->isConst() &&
651 <<
"Request for a non-const object via copying conversion; "
652 <<
"requested CLID = " << clid
653 <<
", proxy primary ID is " << proxy->clID() <<
endmsg ;
658 result = db->object();
665 <<
"Request for an invalid object; requested CLID = "
667 <<
", proxy primary ID is " << proxy->clID() <<
endmsg ;
684 m_t2p->t2pRegister (p,
this);
717 if (proxy && proxy->object()) {
719 if (ctx)
return *ctx;
722 static const EventContext emptyContext;
Hold a pointer to the current event store.
Helpers for retrieving the payload held by a DataProxy.
Assign a CLID to EventContext.
uint32_t CLID
The Class ID type.
Header file for AthHistogramAlgorithm.
Simple smart pointer for Gaudi-style refcounted objects.
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
virtual void lock()=0
If the held object derives from ILockable, call lock() on it.
virtual void * object()=0
The non-template portion of the BaseInfo implementation.
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Manage DataProxy reference in ElementLink/DataLink.
static void resetCachedSource()
CLID clID() const
Retrieve clid.
void resetBoundHandles(bool hard)
reset the bound DataHandles If HARD is true, then the bound objects should also clear any data that d...
std::lock_guard< objMutex_t > objLock_t
virtual const name_type & name() const override final
Retrieve data object key == string.
std::vector< IResetable * > handleList_t
list of bound DataHandles
IConverter * m_dataLoader
void setConst()
Mark this object as const.
DataObject * accessDataOol()
Out-of-line part of accessData().
bool requestRelease(bool force, bool hard)
Reset/release a proxy at the end of an event.
virtual void setAddress(IOpaqueAddress *ioa) override final
set an IOpaqueAddress
std::unique_ptr< DataObject > readData()
Read in a new copy of the object referenced by this proxy.
bool m_resetFlag
reset and not delete: default is true
bool m_boundHandles
True if there are any bound handles.
virtual void registerTransient(void *p) override final
Register a transient object in a t2p map.
virtual IOpaqueAddress * address() const override final
Retrieve IOpaqueAddress.
virtual unsigned long release() override final
release reference to object
void reset(bool hard=false)
Other methods of DataProxy (not in Interface IRegistry):
void setObject(DataObject *obj, bool doreg=true)
set DataObject If doreg is true, then call setRegistry to set the backpointer from obj to the proxt.
IProxyDict * store()
Return the store of which we're a part.
bool isValidAddress() const
is the address valid?
void resetRef()
Drop the reference to the data object.
TransientAddress m_tAddress
void resetOnly(const bool &flag)
set the reset only flag: Clear Store will reset and not delete.
void lock(objLock_t &, DataObject *dobj)
Lock the data object we're holding, if any.
std::atomic< IProxyDict * > m_store
The store of which we are a part.
Athena::IMessageSvcHolder m_ims
std::atomic< DataObject * > m_dObject
void unbindHandle(IResetable *ir)
std::atomic< bool > m_const
Is the proxy currently const?
unsigned long refCount() const
return refCount
bool m_origConst
Was the proxy created as const?
bool bindHandle(IResetable *ir)
const EventContext & contextFromStore() const
Retrieve the EventContext saved in the owning store.
std::lock_guard< mutex_t > lock_t
virtual unsigned long addRef() override final
Add reference to object.
int ir
counter of the current depth
singleton-like access to IMessageSvc via open function and helper
std::string find(const std::string &s)
return a remapped string
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
IMessageSvc * getMessageSvc(bool quiet=false)
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
IProxyDict ** getDataSourcePointerFunc_t(const std::string &)
getDataSourcePointerFunc_t * getDataSourcePointerFunc
virtual void lock() override
Lock the container.
static constexpr CLID ID()