ATLAS Offline Software
Loading...
Searching...
No Matches
SG::DataProxy Class Reference

#include <DataProxy.h>

Inheritance diagram for SG::DataProxy:

Public Types

enum  ErrNo {
  ALLOK , NOCNVSVC , NOIOA , CNVFAILED ,
  T2PREGFAILED , RECURSIVEREAD , NERRORS
}
typedef std::string name_type
typedef std::string id_type
typedef TransientAddress::TransientClidSet CLIDCont_t
typedef std::vector< std::string > AliasCont_t
typedef IStringPool::sgkey_t sgkey_t

Public Member Functions

 DataProxy ()
 DataProxy (TransientAddress *tAddr, IConverter *pDataLoader, bool constFlag=false, bool resetOnly=true)
 build from TransientAddress Takes ownership of tAddr.
 DataProxy (std::unique_ptr< TransientAddress > tAddr, IConverter *pDataLoader, bool constFlag=false, bool resetOnly=true)
 build from TransientAddress
 DataProxy (TransientAddress &&tAddr, IConverter *pDataLoader, bool constFlag=false, bool resetOnly=true)
 DataProxy (DataObject *dObject, TransientAddress *tAddr, bool constFlag=false, bool resetOnly=true)
 build from DataObject
 DataProxy (DataObject *dObject, TransientAddress &&tAddr, bool constFlag=false, bool resetOnly=true)
virtual ~DataProxy ()

IRegistry implementation

typedef std::vector< IResetable * > handleList_t
 list of bound DataHandles
typedef std::recursive_mutex mutex_t
typedef std::lock_guard< mutex_t > lock_t
typedef std::recursive_mutex objMutex_t
typedef std::lock_guard< objMutex_t > objLock_t
class SG::DataStore
 For access to requestRelease.
unsigned int m_refCount {}
bool m_resetFlag = true
 reset and not delete: default is true
bool m_boundHandles {}
 True if there are any bound handles.
std::atomic< bool > m_const {}
 Is the proxy currently const?
bool m_origConst {}
 Was the proxy created as const?
std::atomic< DataObject * > m_dObject = nullptr
TransientAddress m_tAddress
IConverter * m_dataLoader {}
T2pMap * m_t2p {}
handleList_t m_handles
mutex_t m_mutex
Athena::IMessageSvcHolder m_ims
std::atomic< IProxyDict * > m_store {}
 The store of which we are a part.
objMutex_t m_objMutex
virtual unsigned long addRef () override final
 Add reference to object.
virtual unsigned long release () override final
 release reference to object
unsigned long refCount () const
 return refCount
virtual const name_type & name () const override final
 Retrieve data object key == string.
virtual const id_type & identifier () const override final
 Retrieve data object key == string duplicated for Gaudi folks does same as name().
virtual DataObject *object ATLAS_NOT_CONST_THREAD_SAFE () const override final
 Retrieve DataObject.
virtual void setAddress (IOpaqueAddress *ioa) override final
 set an IOpaqueAddress
void setAddress (CxxUtils::RefCountedPtr< IOpaqueAddress > ioa)
 set an IOpaqueAddress
virtual IOpaqueAddress * address () const override final
 Retrieve IOpaqueAddress.
virtual IDataProviderSvc * dataSvc () const override final
 set DataSvc (Gaudi-specific); do nothing for us
sgkey_t sgkey () const
 < Get the primary (hashed) SG key.
void setSGKey (sgkey_t sgkey)
 Return the ID of the store containing this proxy.
StoreID::type storeID () const
 check if it is a transient ID (primary or symLinked):
bool transientID (CLID id) const
 return the list of transient IDs (primary or symLinked):
CLIDCont_t transientID () const
void setTransientID (CLID id)
 Add a new transient ID.
AliasCont_t alias () const
 access set of proxy aliases Returns a COPY of the alias set.
bool hasAlias (const std::string &key) const
 Test to see if a given string is in the alias set.
void setAlias (const std::string &key)
 Add a new proxy alias.
bool removeAlias (const std::string &key)
 remove alias from proxy
IAddressProvider * provider ()
 Return the address provider.
void setProvider (IAddressProvider *provider, StoreID::type storeID)
 Set the address provider.
void setID (CLID id, const std::string &key)
 Set the CLID / key.
void reset (bool hard=false)
 Other methods of DataProxy (not in Interface IRegistry):
void finalReset ()
bool isValid () const
 called by destructor
bool isValidAddress () const
 is the address valid?
bool isValidObject () const
 is the object valid?
bool updateAddress ()
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.
DataObject * accessData ()
 Access DataObject on-demand using conversion service.
ErrNo errNo () const
CLID clID () const
 Retrieve clid.
bool isConst () const
 Check if it is a const object.
void setConst ()
 Mark this object as const.
void resetOnly (const bool &flag)
 set the reset only flag: Clear Store will reset and not delete.
bool isResetOnly () const
 Check reset only:
bool bindHandle (IResetable *ir)
void unbindHandle (IResetable *ir)
void setT2p (T2pMap *t2p)
virtual void registerTransient (void *p) override final
 Register a transient object in a t2p map.
void setStore (IProxyDict *store)
 Set the store of which we're a part.
IProxyDict * store ()
 Return the store of which we're a part.
const IProxyDict * store () const
 Return the store of which we're a part.
void resetBoundHandles (bool hard)
 reset the bound DataHandles If HARD is true, then the bound objects should also clear any data that depends on the identity of the current event store.
IConverter * loader ()
std::unique_ptr< DataObject > readData ()
 Read in a new copy of the object referenced by this proxy.
 DataProxy (const DataProxy &)=delete
DataProxy & operator= (const DataProxy &)=delete
DataObject * accessDataOol ()
 Out-of-line part of accessData().
bool requestRelease (bool force, bool hard)
 Reset/release a proxy at the end of an event.
void resetRef ()
 Drop the reference to the data object.
void lock (objLock_t &, DataObject *dobj)
 Lock the data object we're holding, if any.
std::unique_ptr< DataObject > readData (objLock_t &objLock, ErrNo *errNo)
 Read in a new copy of the object referenced by this proxy.
void setObject (objLock_t &objLock, DataObject *obj, bool doreg)
 set DataObject If doreg is true, then call setRegistry to set the backpointer from obj to the proxt.
const EventContext & contextFromStore () const
 Retrieve the EventContext saved in the owning store.

Detailed Description

Definition at line 44 of file DataProxy.h.

Member Typedef Documentation

◆ AliasCont_t

typedef std::vector<std::string> SG::DataProxy::AliasCont_t

Definition at line 55 of file DataProxy.h.

◆ CLIDCont_t

◆ handleList_t

typedef std::vector<IResetable*> SG::DataProxy::handleList_t
private

list of bound DataHandles

Definition at line 332 of file DataProxy.h.

◆ id_type

typedef std::string SG::DataProxy::id_type

Definition at line 53 of file DataProxy.h.

◆ lock_t

typedef std::lock_guard<mutex_t> SG::DataProxy::lock_t
private

Definition at line 341 of file DataProxy.h.

◆ mutex_t

typedef std::recursive_mutex SG::DataProxy::mutex_t
private

Definition at line 340 of file DataProxy.h.

◆ name_type

typedef std::string SG::DataProxy::name_type

Definition at line 52 of file DataProxy.h.

◆ objLock_t

typedef std::lock_guard<objMutex_t> SG::DataProxy::objLock_t
private

Definition at line 355 of file DataProxy.h.

◆ objMutex_t

typedef std::recursive_mutex SG::DataProxy::objMutex_t
private

Definition at line 354 of file DataProxy.h.

◆ sgkey_t

Definition at line 56 of file DataProxy.h.

Member Enumeration Documentation

◆ ErrNo

Enumerator
ALLOK 
NOCNVSVC 
NOIOA 
CNVFAILED 
T2PREGFAILED 
RECURSIVEREAD 
NERRORS 

Definition at line 48 of file DataProxy.h.

Constructor & Destructor Documentation

◆ DataProxy() [1/7]

DataProxy::DataProxy ( )

Definition at line 93 of file DataProxy.cxx.

94{
95}

◆ DataProxy() [2/7]

DataProxy::DataProxy ( TransientAddress * tAddr,
IConverter * pDataLoader,
bool constFlag = false,
bool resetOnly = true )

build from TransientAddress Takes ownership of tAddr.

Definition at line 99 of file DataProxy.cxx.

102 : DataProxy (std::move(*tAddr),
103 svc, constFlag, resetOnly)
104{
105 delete tAddr;
106}
void resetOnly(const bool &flag)
set the reset only flag: Clear Store will reset and not delete.

◆ DataProxy() [3/7]

DataProxy::DataProxy ( std::unique_ptr< TransientAddress > tAddr,
IConverter * pDataLoader,
bool constFlag = false,
bool resetOnly = true )

build from TransientAddress

Definition at line 110 of file DataProxy.cxx.

113 : DataProxy (std::move(*tAddr), svc, constFlag, resetOnly)
114{
115 //assert( tAddr->clID() != 0 );
116 if (svc) svc->addRef();
117}
AthROOTErrorHandlerSvc * svc

◆ DataProxy() [4/7]

DataProxy::DataProxy ( TransientAddress && tAddr,
IConverter * pDataLoader,
bool constFlag = false,
bool resetOnly = true )

Definition at line 119 of file DataProxy.cxx.

121 :
123 m_const(constFlag),
124 m_origConst(constFlag),
125 m_tAddress(std::move(tAddr)),
126 m_dataLoader(svc)
127{
128 //assert( tAddr->clID() != 0 );
129 if (svc) svc->addRef();
130}
IConverter * m_dataLoader
Definition DataProxy.h:327
bool m_resetFlag
reset and not delete: default is true
Definition DataProxy.h:309
TransientAddress m_tAddress
Definition DataProxy.h:325
std::atomic< bool > m_const
Is the proxy currently const?
Definition DataProxy.h:319
bool m_origConst
Was the proxy created as const?
Definition DataProxy.h:321

◆ DataProxy() [5/7]

DataProxy::DataProxy ( DataObject * dObject,
TransientAddress * tAddr,
bool constFlag = false,
bool resetOnly = true )

build from DataObject

Definition at line 134 of file DataProxy.cxx.

136 :
138 m_const(constFlag),
139 m_origConst(constFlag),
140 m_tAddress(std::move(*tAddr))
141{
142 setObject(dObject);
143 delete tAddr;
144}
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.

◆ DataProxy() [6/7]

DataProxy::DataProxy ( DataObject * dObject,
TransientAddress && tAddr,
bool constFlag = false,
bool resetOnly = true )

Definition at line 146 of file DataProxy.cxx.

148 :
150 m_const(constFlag),
151 m_origConst(constFlag),
152 m_tAddress(std::move(tAddr))
153{
154 setObject(dObject);
155}

◆ ~DataProxy()

DataProxy::~DataProxy ( )
virtual

Definition at line 158 of file DataProxy.cxx.

159{
160 finalReset();
161}
void finalReset()

◆ DataProxy() [7/7]

SG::DataProxy::DataProxy ( const DataProxy & )
privatedelete

Member Function Documentation

◆ accessData()

DataObject * SG::DataProxy::accessData ( )

Access DataObject on-demand using conversion service.

Exceptions
runtime_errorwhen converter fails

◆ accessDataOol()

DataObject * DataProxy::accessDataOol ( )
private

Out-of-line part of accessData().

Access DataObject on-demand using conversion service.

Definition at line 502 of file DataProxy.cxx.

503{
504 // This is done in the inlined accessData().
505 //if (0 != m_dObject) return m_dObject; // cached object
506
507 objLock_t objLock (m_objMutex);
508 // Check again after acquiring the lock.
509 if (0 != m_dObject) return m_dObject; // cached object
510
511 if (isValidAddress()) {
512 // An address provider called by isValidAddress may have set the object
513 // pointer directly, rather than filling in the address. So check
514 // the cached object pointer again.
515 if (0 != m_dObject) return m_dObject; // cached object
516 }
517
518 std::unique_ptr<DataObject> obju = readData (objLock, &m_errno);
519 if (!obju) {
520 if (m_errno == NOIOA) {
521 MsgStream gLog(m_ims, "DataProxy");
522 gLog << MSG::WARNING
523 << "accessData: IOA pointer not set" <<endmsg;
524 }
525 else if (m_errno == CNVFAILED) {
526 MsgStream gLog(m_ims, "DataProxy");
527 gLog << MSG::WARNING
528 << "accessData: conversion failed for data object "
529 <<m_tAddress.clID() << '/' << m_tAddress.name() << '\n'
530 <<" Returning NULL DataObject pointer " << endmsg;
531 }
532 setObject(objLock, 0, true);
533 return 0;
534 }
535
536 DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(obju.get());
537 if (m_t2p) {
538 if (bucket) {
539 void* payload = bucket->object();
540 m_t2p->t2pRegister(payload, this);
541 m_errno=ALLOK;
542
543 // Register bases as well.
544 const SG::BaseInfoBase* bi = SG::BaseInfoBase::find (m_tAddress.clID());
545 if (bi) {
546 std::vector<CLID> base_clids = bi->get_bases();
547 for (unsigned i=0; i < base_clids.size(); ++i) {
548 // nb. DataProxy_cast here will give an infinite recursion!
549 void* bobj = SG::Storable_cast (obju.get(), base_clids[i], nullptr, true);
550 if (bobj && bobj != payload)
551 m_t2p->t2pRegister (bobj, this);
552 }
553 }
554 }
555 else {
556 MsgStream gLog(m_ims, "DataProxy");
557 gLog << MSG::ERROR
558 << "accessData: ERROR registering object in t2p map"
559 <<m_tAddress.clID() << '/' << m_tAddress.name() << '\n'
560 <<" Returning NULL DataObject pointer " << endmsg;
561 obju.reset();
562 m_errno=T2PREGFAILED;
563 }
564 }
565
566 // Must get everything else set up before setting m_dObject, because
567 // once we set it, it's immediately visible to other threads.
568 // In particular, we were previously doing this before the t2p registration.
569 // This meant that another thread could retrieve the pointer from
570 // the proxy, but then fail trying to map the pointer back to the proxy.
571 // See ATEAM-1126.
572 std::atomic_thread_fence (std::memory_order_seq_cst);
573 setObject(objLock, obju.release(), true);
574
575 return m_dObject;
576}
#define endmsg
virtual void * object()=0
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
Definition BaseInfo.cxx:587
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Definition BaseInfo.cxx:307
std::lock_guard< objMutex_t > objLock_t
Definition DataProxy.h:355
std::unique_ptr< DataObject > readData()
Read in a new copy of the object referenced by this proxy.
bool isValidAddress() const
is the address valid?
Athena::IMessageSvcHolder m_ims
Definition DataProxy.h:344
std::atomic< DataObject * > m_dObject
Definition DataProxy.h:323
objMutex_t m_objMutex
Definition DataProxy.h:356
T2pMap * m_t2p
Definition DataProxy.h:329
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)

◆ addRef()

unsigned long DataProxy::addRef ( )
finaloverridevirtual

Add reference to object.

Definition at line 290 of file DataProxy.cxx.

291{
293 return ++m_refCount;
294}
unsigned int m_refCount
Definition DataProxy.h:306
std::lock_guard< mutex_t > lock_t
Definition DataProxy.h:341
mutex_t m_mutex
Definition DataProxy.h:342
virtual void lock() override
Lock the container.

◆ address()

virtual IOpaqueAddress * SG::DataProxy::address ( ) const
finaloverridevirtual

Retrieve IOpaqueAddress.

◆ alias()

AliasCont_t SG::DataProxy::alias ( ) const

access set of proxy aliases Returns a COPY of the alias set.

◆ ATLAS_NOT_CONST_THREAD_SAFE()

virtual DataObject *object SG::DataProxy::ATLAS_NOT_CONST_THREAD_SAFE ( ) const
finaloverridevirtual

Retrieve DataObject.

◆ bindHandle()

bool DataProxy::bindHandle ( IResetable * ir)

Definition at line 186 of file DataProxy.cxx.

186 {
187 assert(ir);
189 if (ir->isSet()) {
190 return false;
191 } else {
192 m_handles.push_back(ir);
193 m_boundHandles = true;
194 if (IProxyDict* store = m_store)
195 store->boundHandle(ir);
196 return true;
197 }
198}
handleList_t m_handles
Definition DataProxy.h:333
bool m_boundHandles
True if there are any bound handles.
Definition DataProxy.h:316
IProxyDict * store()
Return the store of which we're a part.
std::atomic< IProxyDict * > m_store
The store of which we are a part.
Definition DataProxy.h:347
int ir
counter of the current depth
Definition fastadd.cxx:49

◆ clID()

CLID SG::DataProxy::clID ( ) const

Retrieve clid.

◆ contextFromStore()

const EventContext & DataProxy::contextFromStore ( ) const
private

Retrieve the EventContext saved in the owning store.

Retrieve the EventContext saved in the parent store.

If there is no context recorded in the store, return a default-initialized context.

Do not call this holding m_mutex, or we could deadlock (ATEAM-755). (The store lock must be acquired before the DataProxy lock.)

Definition at line 710 of file DataProxy.cxx.

711{
712 IProxyDict* store = m_store;
713 if (store) {
714 static const SG::sgkey_t ctxkey =
715 store->stringToKey ("EventContext", ClassID_traits<EventContext>::ID());
716 SG::DataProxy* proxy = store->proxy_exact (ctxkey);
717 if (proxy && proxy->object()) {
718 EventContext* ctx = SG::DataProxy_cast<EventContext> (proxy);
719 if (ctx) return *ctx;
720 }
721 }
722 static const EventContext emptyContext;
723 return emptyContext;
724}
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32

◆ dataSvc()

virtual IDataProviderSvc * SG::DataProxy::dataSvc ( ) const
finaloverridevirtual

set DataSvc (Gaudi-specific); do nothing for us

◆ errNo()

ErrNo SG::DataProxy::errNo ( ) const

◆ finalReset()

void DataProxy::finalReset ( )

Definition at line 227 of file DataProxy.cxx.

228{
229 handleList_t handles;
230 {
231 objLock_t objLock (m_objMutex);
233 m_const=false; //hack to force the resetting of proxy ptr in VarHandleBase
234
235 handles = m_handles;
236
237 DataObject* dobj = m_dObject;
238 resetGaudiRef(dobj);
239 m_dObject = dobj;
240 resetGaudiRef(m_dataLoader);
241
242 if (m_handles.empty()) {
243 m_boundHandles = false;
244 }
245 }
246
247 for (auto ih: handles) {
248 if (0 != ih) ih->finalReset();
249 }
250}
std::vector< IResetable * > handleList_t
list of bound DataHandles
Definition DataProxy.h:332

◆ hasAlias()

bool SG::DataProxy::hasAlias ( const std::string & key) const

Test to see if a given string is in the alias set.

◆ identifier()

virtual const id_type & SG::DataProxy::identifier ( ) const
finaloverridevirtual

Retrieve data object key == string duplicated for Gaudi folks does same as name().

◆ isConst()

bool SG::DataProxy::isConst ( ) const

Check if it is a const object.

◆ isResetOnly()

bool SG::DataProxy::isResetOnly ( ) const

Check reset only:

◆ isValid()

bool SG::DataProxy::isValid ( ) const

called by destructor

am I valid?

◆ isValidAddress()

bool DataProxy::isValidAddress ( ) const

is the address valid?

Definition at line 580 of file DataProxy.cxx.

581{
582 // Looking up the context is relatively expensive.
583 // So first try isValid() without the context.
584 {
586 if (const_cast<DataProxy*>(this)->m_tAddress.isValid(nullptr)) {
587 return true;
588 }
589 }
590 // Get the context. (Must not be holding m_mutex here.)
591 const EventContext& ctx = contextFromStore();
592 // Try again with the context.
594 return const_cast<DataProxy*>(this)->m_tAddress.isValid(&ctx);
595}
const EventContext & contextFromStore() const
Retrieve the EventContext saved in the owning store.

◆ isValidObject()

bool SG::DataProxy::isValidObject ( ) const

is the object valid?

◆ loader()

IConverter * SG::DataProxy::loader ( )

◆ lock()

void DataProxy::lock ( objLock_t & ,
DataObject * dobj )
private

Lock the data object we're holding, if any.

Parameters
dobjThe data object.

Should be called with the mutex held.

Should be called with the mutex held.

Definition at line 693 of file DataProxy.cxx.

694{
695 DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(dobj);
696 if (bucket)
697 bucket->lock();
698}
virtual void lock()=0
If the held object derives from ILockable, call lock() on it.

◆ name()

virtual const name_type & SG::DataProxy::name ( ) const
finaloverridevirtual

Retrieve data object key == string.

◆ operator=()

DataProxy & SG::DataProxy::operator= ( const DataProxy & )
privatedelete

◆ provider()

IAddressProvider * SG::DataProxy::provider ( )

Return the address provider.

◆ readData() [1/2]

std::unique_ptr< DataObject > DataProxy::readData ( )

Read in a new copy of the object referenced by this proxy.

If this proxy has an associated loader and address, then load a new copy of the object and return it. Any existing copy held by the proxy is unaffected.

This will fail if the proxy does not refer to an object read from an input file.

Returns a null pointer on failure.

Definition at line 409 of file DataProxy.cxx.

410{
411 // Public wrapper for readData().
412 objLock_t objLock (m_objMutex);
413 return readData (objLock, nullptr);
414}

◆ readData() [2/2]

std::unique_ptr< DataObject > DataProxy::readData ( objLock_t & objLock,
ErrNo * errNo )
private

Read in a new copy of the object referenced by this proxy.

Parameters
errNoIf non-null, set to the resulting error code.

If this proxy has an associated loader and address, then load a new copy of the object and return it. Any existing copy held by the proxy is unaffected.

This will fail if the proxy does not refer to an object read from an input file.

Definition at line 428 of file DataProxy.cxx.

429{
430 if (errNo) {
431 if (*errNo == RECURSIVEREAD) {
432 // This can end up being called from noexcept functions.
433 // Creating a MsgStream can throw an exception --- don't let
434 // it escape.
435 try {
436 MsgStream gLog(m_ims, "DataProxy");
437 gLog << MSG::ERROR
438 << "readData: ERROR recursive read for object"
439 <<m_tAddress.clID() << '/' << m_tAddress.name() << '\n'
440 <<" Returning NULL DataObject pointer " << endmsg;
441 }
442 catch (const GaudiException&) {
443 std::println (std::cerr, "DataProxy::readData: Problem creating MsgStream");
444 }
445 return nullptr;
446 }
448 }
449
450 IConverter* dataLoader;
451 IProxyDict* store;
452 IOpaqueAddress* address;
453 {
455 if (0 == m_dataLoader) {
456 //MsgStream gLog(m_ims, "DataProxy");
457 //gLog << MSG::WARNING
458 // << "accessData: IConverter ptr not set" <<endmsg;
459 if (errNo) *errNo=NOCNVSVC;
460 return nullptr;
461 }
462
463 dataLoader = m_dataLoader;
464 store = m_store;
465 address = m_tAddress.address();
466 }
467
468 if (!isValidAddress()) {
469 //MsgStream gLog(m_ims, "DataProxy");
470 //gLog << MSG::WARNING
471 // << "accessData: IOA pointer not set" <<endmsg;
472 if (errNo) *errNo=NOIOA;
473 return nullptr;
474 }
475
476 SG::CurrentEventStore::Push push (store);
477
478 DataObject* obj = nullptr;
480 if (store)
481 sc = store->createObj (dataLoader, address, obj);
482 else
483 sc = dataLoader->createObj (address, obj);
484 if (sc.isSuccess()) {
485 if (errNo && *errNo == RECURSIVEREAD) *errNo = ALLOK;
486 return std::unique_ptr<DataObject>(obj);
487 }
488 if (!address) {
489 MsgStream gLog(m_ims, "DataProxy");
490 gLog << MSG::ERROR
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."
494 << endmsg;
495 }
496 if (errNo) *errNo = CNVFAILED;
497 return nullptr;
498}
static Double_t sc
CLID clID() const
Retrieve clid.
virtual const name_type & name() const override final
Retrieve data object key == string.
ErrNo errNo() const
virtual IOpaqueAddress * address() const override final
Retrieve IOpaqueAddress.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ refCount()

unsigned long DataProxy::refCount ( ) const

return refCount

Definition at line 283 of file DataProxy.cxx.

284{
286 return m_refCount;
287}

◆ registerTransient()

void DataProxy::registerTransient ( void * p)
finaloverridevirtual

Register a transient object in a t2p map.

Parameters
transThe object to register.

(IRegisterTransient interface.)

Parameters
transThe object to register.

Implements SG::IRegisterTransient.

Definition at line 680 of file DataProxy.cxx.

681{
683 if (m_t2p)
684 m_t2p->t2pRegister (p, this);
685}

◆ release()

unsigned long DataProxy::release ( )
finaloverridevirtual

release reference to object

Definition at line 297 of file DataProxy.cxx.

298{
299 unsigned long count;
300 {
302 count = --m_refCount;
303 }
304 if ( 0 == count ) delete this;
305 return count;
306}
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148

◆ removeAlias()

bool SG::DataProxy::removeAlias ( const std::string & key)

remove alias from proxy

◆ requestRelease()

bool DataProxy::requestRelease ( bool force,
bool hard )
private

Reset/release a proxy at the end of an event.

Parameters
forceIf true, force a release rather than a reset.
hardDo a hard reset if true.
Returns
True if the caller should release the proxy.

This is usually called at the end of an event. No locking is done, so there should be no other threads accessing this proxy.

Release' means that we want to remove the proxy from the store. Reset' means that we keep the proxy, but remove the data object that it references. Each proxy has a flag saying whether it wants to do a release or a reset. This can be forced via the FORCE argument; this would typically be done when deleting the store. This function does not actually release the proxy. If it returns true, the caller is expected to release the proxy.

See AthenaKernel/IResetable.h for the meaning of HARD.

Definition at line 330 of file DataProxy.cxx.

330 {
331
332 if (m_boundHandles) {
333 resetBoundHandles(hard);
334 }
335 bool canRelease = force;
336 if (!m_resetFlag) canRelease = true;
337#if 0
338 MsgStream gLog(m_ims, "DataProxy");
339 if (gLog.level() <= MSG::VERBOSE) {
340 gLog << MSG::VERBOSE << "requestRelease(): "
341 << (canRelease ? " release " : " reset")
342 <<" object "
343 << name() << " CLID " << clID() << " address " << MSG::hex
344 << object() << MSG::dec << endmsg;
345 }
346#endif
347 if (!canRelease) {
348 resetRef();
349 }
350 return canRelease;
351}
void resetBoundHandles(bool hard)
reset the bound DataHandles If HARD is true, then the bound objects should also clear any data that d...
void resetRef()
Drop the reference to the data object.
bool force
Definition calibdata.py:18

◆ reset()

void DataProxy::reset ( bool hard = false)

Other methods of DataProxy (not in Interface IRegistry):

Reset DataObject, Handles and IOpaqueAddress: If HARD is true, then the bound objects should also clear any data that depends on the identity of the current event store. (See IResetable.h.)

Definition at line 217 of file DataProxy.cxx.

218{
219 resetBoundHandles (hard);
220
221 objLock_t objLock (m_objMutex);
223 resetRef();
224}

◆ resetBoundHandles()

void DataProxy::resetBoundHandles ( bool hard)

reset the bound DataHandles If HARD is true, then the bound objects should also clear any data that depends on the identity of the current event store.

don't need no comment

(See IResetable.h.)

Definition at line 253 of file DataProxy.cxx.

253 {
254 handleList_t handles;
255 {
257 // Early exit if the list is empty.
258 if (!m_boundHandles) return;
259
260 // Make a copy and drop the lock, so we're not holding the lock
261 // during the callback.
262 handles = m_handles;
263 }
264
265 for (IResetable* h : handles) {
266 h->reset(hard);
267 }
268}

◆ resetOnly()

void SG::DataProxy::resetOnly ( const bool & flag)

set the reset only flag: Clear Store will reset and not delete.

◆ resetRef()

void DataProxy::resetRef ( )
inlineprivate

Drop the reference to the data object.

Definition at line 203 of file DataProxy.cxx.

204{
205 // Skip calling resetGaudiRef for the case where the proxy has never
206 // been defererenced.
207 if (m_dObject) {
208 DataObject* dobj = m_dObject;
209 resetGaudiRef(dobj);
210 m_dObject = dobj;
211 }
212 m_tAddress.reset();
214}

◆ setAddress() [1/2]

void DataProxy::setAddress ( CxxUtils::RefCountedPtr< IOpaqueAddress > ioa)

set an IOpaqueAddress

Definition at line 389 of file DataProxy.cxx.

390{
392 m_tAddress.setAddress(std::move(address));
393}

◆ setAddress() [2/2]

void DataProxy::setAddress ( IOpaqueAddress * ioa)
finaloverridevirtual

set an IOpaqueAddress

Definition at line 382 of file DataProxy.cxx.

383{
385 m_tAddress.setAddress(address);
386}

◆ setAlias()

void SG::DataProxy::setAlias ( const std::string & key)

Add a new proxy alias.

◆ setConst()

void DataProxy::setConst ( )

Mark this object as const.

(Lock the object.)

If the object held that derives from ILockable, then we also call lock on the object.

Definition at line 176 of file DataProxy.cxx.

177{
178 objLock_t objLock (m_objMutex);
180 if (!m_const) {
181 m_const = true;
182 this->lock (objLock, m_dObject);
183 }
184}

◆ setID()

void SG::DataProxy::setID ( CLID id,
const std::string & key )

Set the CLID / key.

This will only succeed if the clid/key are currently clear.

◆ setObject() [1/2]

void DataProxy::setObject ( DataObject * obj,
bool doreg = true )

set DataObject If doreg is true, then call setRegistry to set the backpointer from obj to the proxt.

set a DataObject address

Definition at line 374 of file DataProxy.cxx.

375{
376 objLock_t objLock (m_objMutex);
377 setObject (objLock, dObject, doreg);
378}

◆ setObject() [2/2]

void DataProxy::setObject ( objLock_t & objLock,
DataObject * obj,
bool doreg )
private

set DataObject If doreg is true, then call setRegistry to set the backpointer from obj to the proxt.

set a DataObject address If doreg is true, then call setRegistry to set the backpointer from obj to the proxt.

Definition at line 356 of file DataProxy.cxx.

357{
358 DataObject* dobj = m_dObject.exchange (nullptr);
359 std::atomic_thread_fence (std::memory_order_seq_cst);
360 setGaudiRef(dObject, dobj);
361 if (0 != dobj) {
362 if (doreg) dobj->setRegistry(this);
363 if (m_const) this->lock (objLock, dobj);
364 }
365 // Be sure the settings above happen before we set m_dObject.
366 // Otherwise other threads may be able to see the object before those
367 // settings have been made.
368 std::atomic_thread_fence (std::memory_order_seq_cst);
369 m_dObject = dobj;
370}

◆ setProvider()

void SG::DataProxy::setProvider ( IAddressProvider * provider,
StoreID::type storeID )

Set the address provider.

◆ setSGKey()

void SG::DataProxy::setSGKey ( sgkey_t sgkey)

Return the ID of the store containing this proxy.

◆ setStore()

void SG::DataProxy::setStore ( IProxyDict * store)

Set the store of which we're a part.

◆ setT2p()

void DataProxy::setT2p ( T2pMap * t2p)

Definition at line 163 of file DataProxy.cxx.

164{
166 m_t2p = t2p;
167}

◆ setTransientID()

void SG::DataProxy::setTransientID ( CLID id)

Add a new transient ID.

◆ sgkey()

sgkey_t SG::DataProxy::sgkey ( ) const

< Get the primary (hashed) SG key.

Set the primary (hashed) SG key.

◆ store() [1/2]

IProxyDict * SG::DataProxy::store ( )

Return the store of which we're a part.

◆ store() [2/2]

const IProxyDict * SG::DataProxy::store ( ) const

Return the store of which we're a part.

◆ storeID()

StoreID::type SG::DataProxy::storeID ( ) const

check if it is a transient ID (primary or symLinked):

◆ transientID() [1/2]

CLIDCont_t SG::DataProxy::transientID ( ) const

◆ transientID() [2/2]

bool SG::DataProxy::transientID ( CLID id) const

return the list of transient IDs (primary or symLinked):

◆ unbindHandle()

void DataProxy::unbindHandle ( IResetable * ir)

Definition at line 270 of file DataProxy.cxx.

270 {
271 assert(ir);
273 auto ifr = find(m_handles.begin(), m_handles.end(), ir );
274 if (ifr != m_handles.end()) {
275 m_handles.erase(ifr);
276 if (IProxyDict* store = m_store)
277 store->unboundHandle(ir);
278 }
279 m_boundHandles = !m_handles.empty();
280}
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140

◆ updateAddress()

bool DataProxy::updateAddress ( )

Definition at line 597 of file DataProxy.cxx.

598{
599 // Be sure to get the context before acquiring the lock.
600 const EventContext& ctx = contextFromStore();
602 return m_tAddress.isValid(&ctx, true);
603}

◆ SG::DataStore

friend class SG::DataStore
friend

For access to requestRelease.

Definition at line 265 of file DataProxy.h.

Member Data Documentation

◆ m_boundHandles

bool SG::DataProxy::m_boundHandles {}
private

True if there are any bound handles.

Definition at line 316 of file DataProxy.h.

316{};

◆ m_const

std::atomic<bool> SG::DataProxy::m_const {}
private

Is the proxy currently const?

Definition at line 319 of file DataProxy.h.

319{};

◆ m_dataLoader

IConverter* SG::DataProxy::m_dataLoader {}
private

Definition at line 327 of file DataProxy.h.

327{};

◆ m_dObject

std::atomic<DataObject*> SG::DataProxy::m_dObject = nullptr
private

Definition at line 323 of file DataProxy.h.

◆ m_handles

handleList_t SG::DataProxy::m_handles
private

Definition at line 333 of file DataProxy.h.

◆ m_ims

Athena::IMessageSvcHolder SG::DataProxy::m_ims
private

Definition at line 344 of file DataProxy.h.

◆ m_mutex

mutex_t SG::DataProxy::m_mutex
mutableprivate

Definition at line 342 of file DataProxy.h.

◆ m_objMutex

objMutex_t SG::DataProxy::m_objMutex
mutableprivate

Definition at line 356 of file DataProxy.h.

◆ m_origConst

bool SG::DataProxy::m_origConst {}
private

Was the proxy created as const?

Definition at line 321 of file DataProxy.h.

321{};

◆ m_refCount

unsigned int SG::DataProxy::m_refCount {}
private

Definition at line 306 of file DataProxy.h.

306{};

◆ m_resetFlag

bool SG::DataProxy::m_resetFlag = true
private

reset and not delete: default is true

Definition at line 309 of file DataProxy.h.

◆ m_store

std::atomic<IProxyDict*> SG::DataProxy::m_store {}
private

The store of which we are a part.

Definition at line 347 of file DataProxy.h.

347{};

◆ m_t2p

T2pMap* SG::DataProxy::m_t2p {}
private

Definition at line 329 of file DataProxy.h.

329{};

◆ m_tAddress

TransientAddress SG::DataProxy::m_tAddress
private

Definition at line 325 of file DataProxy.h.


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