ATLAS Offline Software
Public Types | Public Member Functions | List of all members
SG::DataProxy Class Reference

#include <DataProxy.h>

Inheritance diagram for SG::DataProxy:
Collaboration 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 TransientAddress::TransientAliasSet 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. More...
 
 DataProxy (std::unique_ptr< TransientAddress > tAddr, IConverter *pDataLoader, bool constFlag=false, bool resetOnly=true)
 build from TransientAddress More...
 
 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 More...
 
 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 More...
 
typedef std::recursive_mutex mutex_t
 
typedef std::lock_guard< mutex_tlock_t
 
typedef std::recursive_mutex objMutex_t
 
typedef std::lock_guard< objMutex_tobjLock_t
 
class SG::DataStore
 For access to requestRelease. More...
 
unsigned int m_refCount
 
bool m_resetFlag
 reset and not delete: default is true More...
 
bool m_boundHandles
 True if there are any bound handles. More...
 
std::atomic< bool > m_const
 Is the proxy currently const? More...
 
bool m_origConst
 Was the proxy created as const? More...
 
std::atomic< DataObject * > m_dObject
 
TransientAddress m_tAddress
 
IConverter * m_dataLoader
 
T2pMapm_t2p
 
handleList_t m_handles
 
mutex_t m_mutex
 
objMutex_t m_objMutex
 
Athena::IMessageSvcHolder m_ims
 
std::atomic< IProxyDict * > m_store
 The store of which we are a part. More...
 
enum ErrNo m_errno
 errno-style error code for accessData More...
 
virtual unsigned long addRef () override final
 Add reference to object. More...
 
virtual unsigned long release () override final
 release reference to object More...
 
unsigned long refCount () const
 return refCount More...
 
virtual const name_typename () const override final
 Retrieve data object key == string. More...
 
virtual const id_typeidentifier () const override final
 Retrieve data object key == string duplicated for Gaudi folks does same as name() More...
 
virtual DataObject *object ATLAS_NOT_CONST_THREAD_SAFE () const override final
 Retrieve DataObject. More...
 
virtual void setAddress (IOpaqueAddress *ioa) override final
 set an IOpaqueAddress More...
 
virtual IOpaqueAddress * address () const override final
 Retrieve IOpaqueAddress. More...
 
virtual IDataProviderSvc * dataSvc () const override final
 set DataSvc (Gaudi-specific); do nothing for us More...
 
sgkey_t sgkey () const
 < Get the primary (hashed) SG key. More...
 
void setSGKey (sgkey_t sgkey)
 Return the ID of the store containing this proxy. More...
 
StoreID::type storeID () const
 check if it is a transient ID (primary or symLinked): More...
 
bool transientID (CLID id) const
 return the list of transient IDs (primary or symLinked): More...
 
CLIDCont_t transientID () const
 
void setTransientID (CLID id)
 Add a new transient ID. More...
 
AliasCont_t alias () const
 access set of proxy aliases Returns a COPY of the alias set. More...
 
bool hasAlias (const std::string &key) const
 Test to see if a given string is in the alias set. More...
 
void setAlias (const std::string &key)
 Add a new proxy alias. More...
 
bool removeAlias (const std::string &key)
 remove alias from proxy More...
 
IAddressProviderprovider ()
 Return the address provider. More...
 
void setProvider (IAddressProvider *provider, StoreID::type storeID)
 Set the address provider. More...
 
void setID (CLID id, const std::string &key)
 Set the CLID / key. More...
 
void reset (bool hard=false)
 Other methods of DataProxy (not in Interface IRegistry): More...
 
void finalReset ()
 
bool isValid () const
 called by destructor More...
 
bool isValidAddress () const
 is the address valid? More...
 
bool isValidObject () const
 is the object valid? More...
 
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. More...
 
DataObject * accessData ()
 Access DataObject on-demand using conversion service. More...
 
ErrNo errNo () const
 
CLID clID () const
 Retrieve clid. More...
 
bool isConst () const
 Check if it is a const object. More...
 
void setConst ()
 Mark this object as const. More...
 
void resetOnly (const bool &flag)
 set the reset only flag: Clear Store will reset and not delete. More...
 
bool isResetOnly () const
 Check reset only: More...
 
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. More...
 
void setStore (IProxyDict *store)
 Set the store of which we're a part. More...
 
IProxyDictstore ()
 Return the store of which we're a part. More...
 
const IProxyDictstore () const
 Return the store of which we're a part. More...
 
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. More...
 
IConverter * loader ()
 
std::unique_ptr< DataObject > readData ()
 Read in a new copy of the object referenced by this proxy. More...
 
 DataProxy (const DataProxy &)=delete
 
DataProxyoperator= (const DataProxy &)=delete
 
DataObject * accessDataOol ()
 Out-of-line part of accessData(). More...
 
bool requestRelease (bool force, bool hard)
 Reset/release a proxy at the end of an event. More...
 
void resetRef ()
 Drop the reference to the data object. More...
 
void lock (objLock_t &)
 Lock the data object we're holding, if any. More...
 
std::unique_ptr< DataObject > readData (objLock_t &objLock, ErrNo *errNo)
 Read in a new copy of the object referenced by this proxy. More...
 
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. More...
 
const EventContext & contextFromStore () const
 Retrieve the EventContext saved in the owning store. More...
 

Detailed Description

Definition at line 43 of file DataProxy.h.

Member Typedef Documentation

◆ AliasCont_t

Definition at line 54 of file DataProxy.h.

◆ CLIDCont_t

Definition at line 53 of file DataProxy.h.

◆ handleList_t

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

list of bound DataHandles

Definition at line 328 of file DataProxy.h.

◆ id_type

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

Definition at line 52 of file DataProxy.h.

◆ lock_t

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

Definition at line 337 of file DataProxy.h.

◆ mutex_t

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

Definition at line 336 of file DataProxy.h.

◆ name_type

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

Definition at line 51 of file DataProxy.h.

◆ objLock_t

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

Definition at line 342 of file DataProxy.h.

◆ objMutex_t

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

Definition at line 341 of file DataProxy.h.

◆ sgkey_t

Definition at line 55 of file DataProxy.h.

Member Enumeration Documentation

◆ ErrNo

Enumerator
ALLOK 
NOCNVSVC 
NOIOA 
CNVFAILED 
T2PREGFAILED 
RECURSIVEREAD 
NERRORS 

Definition at line 47 of file DataProxy.h.

Constructor & Destructor Documentation

◆ DataProxy() [1/7]

DataProxy::DataProxy ( )

Definition at line 91 of file DataProxy.cxx.

91  :
92  m_refCount(0),
93  m_resetFlag(true),
94  m_boundHandles(false),
95  m_const(false),
96  m_origConst(false),
97  m_dObject(nullptr),
98  m_dataLoader(nullptr),
99  m_t2p(nullptr),
100  m_store(nullptr),
101  m_errno(ALLOK)
102 {
103 }

◆ 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 107 of file DataProxy.cxx.

110  : DataProxy (std::move(*tAddr),
111  svc, constFlag, resetOnly)
112 {
113  delete tAddr;
114 }

◆ DataProxy() [3/7]

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

build from TransientAddress

Definition at line 118 of file DataProxy.cxx.

121  : DataProxy (std::move(*tAddr), svc, constFlag, resetOnly)
122 {
123  //assert( tAddr->clID() != 0 );
124  if (svc) svc->addRef();
125 }

◆ DataProxy() [4/7]

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

Definition at line 127 of file DataProxy.cxx.

129  :
130  m_refCount(0),
132  m_boundHandles(false),
133  m_const(constFlag),
134  m_origConst(constFlag),
135  m_dObject(0),
136  m_tAddress(std::move(tAddr)),
137  m_dataLoader(svc),
138  m_t2p(nullptr),
139  m_store(nullptr),
140  m_errno(ALLOK)
141 {
142  //assert( tAddr->clID() != 0 );
143  if (svc) svc->addRef();
144 }

◆ DataProxy() [5/7]

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

build from DataObject

Definition at line 148 of file DataProxy.cxx.

150  :
151  m_refCount(0),
153  m_boundHandles(false),
154  m_const(constFlag),
155  m_origConst(constFlag),
156  m_dObject(0),
157  m_tAddress(std::move(*tAddr)),
158  m_dataLoader(nullptr),
159  m_t2p(nullptr),
160  m_store(nullptr),
161  m_errno(ALLOK)
162 {
163  setObject(dObject);
164  delete tAddr;
165 }

◆ DataProxy() [6/7]

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

Definition at line 167 of file DataProxy.cxx.

169  :
170  m_refCount(0),
172  m_boundHandles(false),
173  m_const(constFlag),
174  m_origConst(constFlag),
175  m_dObject(0),
176  m_tAddress(std::move(tAddr)),
177  m_dataLoader(nullptr),
178  m_t2p(nullptr),
179  m_store(nullptr),
180  m_errno(ALLOK)
181 {
182  setObject(dObject);
183 }

◆ ~DataProxy()

DataProxy::~DataProxy ( )
virtual

Definition at line 186 of file DataProxy.cxx.

187 {
188  finalReset();
189 }

◆ 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 497 of file DataProxy.cxx.

498 {
499  // This is done in the inlined accessData().
500  //if (0 != m_dObject) return m_dObject; // cached object
501 
502  objLock_t objLock (m_objMutex);
503 
504  if (isValidAddress()) {
505  // An address provider called by isValidAddress may have set the object
506  // pointer directly, rather than filling in the address. So check
507  // the cached object pointer again.
508  if (0 != m_dObject) return m_dObject; // cached object
509  }
510 
511  std::unique_ptr<DataObject> obju = readData (objLock, &m_errno);
512  if (!obju) {
513  if (m_errno == NOIOA) {
514  MsgStream gLog(m_ims, "DataProxy");
515  gLog << MSG::WARNING
516  << "accessData: IOA pointer not set" <<endmsg;
517  }
518  else if (m_errno == CNVFAILED) {
519  MsgStream gLog(m_ims, "DataProxy");
520  gLog << MSG::WARNING
521  << "accessData: conversion failed for data object "
522  <<m_tAddress.clID() << '/' << m_tAddress.name() << '\n'
523  <<" Returning NULL DataObject pointer " << endmsg;
524  }
525  setObject(objLock, 0, true);
526  return 0;
527  }
528 
529  DataObject* obj = obju.release();
530  setObject(objLock, obj, true);
531  DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(obj);
532  if (m_t2p) {
533  if (bucket) {
534  void* payload = bucket->object();
535  m_t2p->t2pRegister(payload, this);
536  m_errno=ALLOK;
537 
538  // Register bases as well.
540  if (bi) {
541  std::vector<CLID> base_clids = bi->get_bases();
542  for (unsigned i=0; i < base_clids.size(); ++i) {
543  void* bobj = SG::DataProxy_cast (this, base_clids[i]);
544  if (bobj && bobj != payload)
545  m_t2p->t2pRegister (bobj, this);
546  }
547  }
548  }
549  else {
550  MsgStream gLog(m_ims, "DataProxy");
551  gLog << MSG::ERROR
552  << "accessData: ERROR registering object in t2p map"
553  <<m_tAddress.clID() << '/' << m_tAddress.name() << '\n'
554  <<" Returning NULL DataObject pointer " << endmsg;
555  obj=0;
556  setObject(objLock, 0, true);
558  }
559  }
560 
561  return obj;
562 }

◆ addRef()

unsigned long DataProxy::addRef ( )
finaloverridevirtual

Add reference to object.

Definition at line 313 of file DataProxy.cxx.

314 {
315  lock_t lock (m_mutex);
316  return ++m_refCount;
317 }

◆ 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 214 of file DataProxy.cxx.

214  {
215  assert(ir);
216  lock_t lock (m_mutex);
217  if (ir->isSet()) {
218  return false;
219  } else {
220  m_handles.push_back(ir);
221  m_boundHandles = true;
222  if (IProxyDict* store = m_store)
223  store->boundHandle(ir);
224  return true;
225  }
226 }

◆ 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 646 of file DataProxy.cxx.

647 {
649  if (store) {
650  static const SG::sgkey_t ctxkey =
652  SG::DataProxy* proxy = store->proxy_exact (ctxkey);
653  if (proxy && proxy->object()) {
654  EventContext* ctx = SG::DataProxy_cast<EventContext> (proxy);
655  if (ctx) return *ctx;
656  }
657  }
658  static const EventContext emptyContext;
659  return emptyContext;
660 }

◆ 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 250 of file DataProxy.cxx.

251 {
252  handleList_t handles;
253  {
254  objLock_t objLock (m_objMutex);
255  lock_t lock (m_mutex);
256  m_const=false; //hack to force the resetting of proxy ptr in VarHandleBase
257 
258  handles = m_handles;
259 
260  DataObject* dobj = m_dObject;
261  resetGaudiRef(dobj);
262  m_dObject = dobj;
263  resetGaudiRef(m_dataLoader);
264 
265  if (m_handles.empty()) {
266  m_boundHandles = false;
267  }
268  }
269 
270  for (auto ih: handles) {
271  if (0 != ih) ih->finalReset();
272  }
273 }

◆ 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 566 of file DataProxy.cxx.

567 {
568  // Looking up the context is relatively expensive.
569  // So first try isValid() without the context.
570  {
571  lock_t lock (m_mutex);
572  if (const_cast<DataProxy*>(this)->m_tAddress.isValid(nullptr)) {
573  return true;
574  }
575  }
576  // Get the context. (Must not be holding m_mutex here.)
577  const EventContext& ctx = contextFromStore();
578  // Try again with the context.
579  lock_t lock (m_mutex);
580  return const_cast<DataProxy*>(this)->m_tAddress.isValid(&ctx);
581 }

◆ isValidObject()

bool SG::DataProxy::isValidObject ( ) const

is the object valid?

◆ loader()

IConverter* SG::DataProxy::loader ( )

◆ lock()

void DataProxy::lock ( objLock_t )
private

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

Should be called with the mutex held.

Definition at line 628 of file DataProxy.cxx.

629 {
630  DataObject* dobj = m_dObject;
631  DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(dobj);
632  if (bucket)
633  bucket->lock();
634 }

◆ 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 420 of file DataProxy.cxx.

421 {
422  // Public wrapper for readData().
423  objLock_t objLock (m_objMutex);
424  return readData (objLock, nullptr);
425 }

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

440 {
441  if (errNo) {
442  if (*errNo == RECURSIVEREAD) {
443  MsgStream gLog(m_ims, "DataProxy");
444  gLog << MSG::ERROR
445  << "readData: ERROR recursive read for object"
446  <<m_tAddress.clID() << '/' << m_tAddress.name() << '\n'
447  <<" Returning NULL DataObject pointer " << endmsg;
448  return nullptr;
449  }
450  *errNo = RECURSIVEREAD;
451  }
452 
453  IConverter* dataLoader;
454  IProxyDict* store;
455  IOpaqueAddress* address;
456  {
457  lock_t lock (m_mutex);
458  if (0 == m_dataLoader) {
459  //MsgStream gLog(m_ims, "DataProxy");
460  //gLog << MSG::WARNING
461  // << "accessData: IConverter ptr not set" <<endmsg;
462  if (errNo) *errNo=NOCNVSVC;
463  return nullptr;
464  }
465 
466  dataLoader = m_dataLoader;
467  store = m_store;
468  address = m_tAddress.address();
469  }
470 
471  if (!isValidAddress()) {
472  //MsgStream gLog(m_ims, "DataProxy");
473  //gLog << MSG::WARNING
474  // << "accessData: IOA pointer not set" <<endmsg;
475  if (errNo) *errNo=NOIOA;
476  return nullptr;
477  }
478 
480 
481  DataObject* obj = nullptr;
482  StatusCode sc;
483  if (store)
484  sc = store->createObj (dataLoader, address, obj);
485  else
486  sc = dataLoader->createObj (address, obj);
487  if (sc.isSuccess()) {
488  if (errNo && *errNo == RECURSIVEREAD) *errNo = ALLOK;
489  return std::unique_ptr<DataObject>(obj);
490  }
491  if (errNo) *errNo = CNVFAILED;
492  return nullptr;
493 }

◆ refCount()

unsigned long DataProxy::refCount ( ) const

return refCount

Definition at line 306 of file DataProxy.cxx.

307 {
308  lock_t lock (m_mutex);
309  return m_refCount;
310 }

◆ 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 615 of file DataProxy.cxx.

616 {
617  lock_t lock (m_mutex);
618  if (m_t2p)
619  m_t2p->t2pRegister (p, this);
620 }

◆ release()

unsigned long DataProxy::release ( )
finaloverridevirtual

release reference to object

Definition at line 320 of file DataProxy.cxx.

321 {
322  unsigned long count;
323  {
324  lock_t lock (m_mutex);
325  count = --m_refCount;
326  }
327  if ( 0 == count ) delete this;
328  return count;
329 }

◆ 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 353 of file DataProxy.cxx.

353  {
354 
355  if (m_boundHandles) {
356  resetBoundHandles(hard);
357  }
358  bool canRelease = force;
359  if (!m_resetFlag) canRelease = true;
360 #ifndef NDEBUG
361  MsgStream gLog(m_ims, "DataProxy");
362  if (gLog.level() <= MSG::VERBOSE) {
363  gLog << MSG::VERBOSE << "requestRelease(): "
364  << (canRelease ? " release " : " reset")
365  <<" object "
366  << name() << " CLID " << clID() << " address " << MSG::hex
367  << object() << MSG::dec << endmsg;
368  }
369 #endif
370  if (!canRelease) {
371  resetRef();
372  }
373  return canRelease;
374 }

◆ 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 240 of file DataProxy.cxx.

241 {
242  resetBoundHandles (hard);
243 
244  objLock_t objLock (m_objMutex);
245  lock_t lock (m_mutex);
246  resetRef();
247 }

◆ 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 276 of file DataProxy.cxx.

276  {
277  handleList_t handles;
278  {
279  lock_t lock (m_mutex);
280  // Early exit if the list is empty.
281  if (!m_boundHandles) return;
282 
283  // Make a copy and drop the lock, so we're not holding the lock
284  // during the callback.
285  handles = m_handles;
286  }
287 
288  for (IResetable* h : handles) {
289  h->reset(hard);
290  }
291 }

◆ resetOnly()

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

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

◆ resetRef()

void DataProxy::resetRef ( )
private

Drop the reference to the data object.

Definition at line 230 of file DataProxy.cxx.

231 {
232  DataObject* dobj = m_dObject;
233  resetGaudiRef(dobj);
234  m_dObject = dobj;
235  m_tAddress.reset();
237 }

◆ setAddress()

void DataProxy::setAddress ( IOpaqueAddress *  ioa)
finaloverridevirtual

set an IOpaqueAddress

Definition at line 400 of file DataProxy.cxx.

401 {
402  lock_t lock (m_mutex);
404 }

◆ 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 204 of file DataProxy.cxx.

205 {
206  objLock_t objLock (m_objMutex);
207  lock_t lock (m_mutex);
208  if (!m_const) {
209  m_const = true;
210  this->lock (objLock);
211  }
212 }

◆ 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 392 of file DataProxy.cxx.

393 {
394  objLock_t objLock (m_objMutex);
395  setObject (objLock, dObject, doreg);
396 }

◆ 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 379 of file DataProxy.cxx.

380 {
381  DataObject* dobj = m_dObject;
382  setGaudiRef(dObject, dobj);
383  m_dObject = dobj;
384  if (0 != dobj) {
385  if (doreg) dobj->setRegistry(this);
386  if (m_const) this->lock (objLock);
387  }
388 }

◆ 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 191 of file DataProxy.cxx.

192 {
193  lock_t lock (m_mutex);
194  m_t2p = t2p;
195 }

◆ 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 293 of file DataProxy.cxx.

293  {
294  assert(ir);
295  lock_t lock (m_mutex);
296  auto ifr = find(m_handles.begin(), m_handles.end(), ir );
297  if (ifr != m_handles.end()) {
298  m_handles.erase(ifr);
299  if (IProxyDict* store = m_store)
301  }
302  m_boundHandles = !m_handles.empty();
303 }

◆ updateAddress()

bool DataProxy::updateAddress ( )

Definition at line 583 of file DataProxy.cxx.

584 {
585  // Be sure to get the context before acquiring the lock.
586  const EventContext& ctx = contextFromStore();
587  lock_t lock (m_mutex);
588  return m_tAddress.isValid(&ctx, true);
589 }

Friends And Related Function Documentation

◆ SG::DataStore

friend class SG::DataStore
friend

For access to requestRelease.

Definition at line 261 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 312 of file DataProxy.h.

◆ m_const

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

Is the proxy currently const?

Definition at line 315 of file DataProxy.h.

◆ m_dataLoader

IConverter* SG::DataProxy::m_dataLoader
private

Definition at line 323 of file DataProxy.h.

◆ m_dObject

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

Definition at line 319 of file DataProxy.h.

◆ m_errno

enum ErrNo SG::DataProxy::m_errno
private

errno-style error code for accessData

Definition at line 349 of file DataProxy.h.

◆ m_handles

handleList_t SG::DataProxy::m_handles
private

Definition at line 329 of file DataProxy.h.

◆ m_ims

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

Definition at line 346 of file DataProxy.h.

◆ m_mutex

mutex_t SG::DataProxy::m_mutex
mutableprivate

Definition at line 338 of file DataProxy.h.

◆ m_objMutex

objMutex_t SG::DataProxy::m_objMutex
mutableprivate

Definition at line 343 of file DataProxy.h.

◆ m_origConst

bool SG::DataProxy::m_origConst
private

Was the proxy created as const?

Definition at line 317 of file DataProxy.h.

◆ m_refCount

unsigned int SG::DataProxy::m_refCount
private

Definition at line 302 of file DataProxy.h.

◆ m_resetFlag

bool SG::DataProxy::m_resetFlag
private

reset and not delete: default is true

Definition at line 305 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 349 of file DataProxy.h.

◆ m_t2p

T2pMap* SG::DataProxy::m_t2p
private

Definition at line 325 of file DataProxy.h.

◆ m_tAddress

TransientAddress SG::DataProxy::m_tAddress
private

Definition at line 321 of file DataProxy.h.


The documentation for this class was generated from the following files:
SG::DataProxy::handleList_t
std::vector< IResetable * > handleList_t
list of bound DataHandles
Definition: DataProxy.h:328
SG::DataProxy::m_boundHandles
bool m_boundHandles
True if there are any bound handles.
Definition: DataProxy.h:312
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::DataProxy::m_store
std::atomic< IProxyDict * > m_store
The store of which we are a part.
Definition: DataProxy.h:349
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
DataBucketBase::lock
virtual void lock()=0
If the held object derives from ILockable, call lock() on it.
SG::DataProxy::resetBoundHandles
void resetBoundHandles(bool hard)
reset the bound DataHandles If HARD is true, then the bound objects should also clear any data that d...
Definition: DataProxy.cxx:276
calibdata.force
bool force
Definition: calibdata.py:19
DataBucketBase
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
Definition: DataBucketBase.h:24
IStringPool::stringToKey
virtual sgkey_t stringToKey(const std::string &str, CLID clid)=0
Find the key for a string/CLID pair.
DataBucketBase::object
virtual void * object()=0
SG::DataProxy::m_t2p
T2pMap * m_t2p
Definition: DataProxy.h:325
SG::DataProxy::m_ims
Athena::IMessageSvcHolder m_ims
Definition: DataProxy.h:346
SG::DataProxy::objLock_t
std::lock_guard< objMutex_t > objLock_t
Definition: DataProxy.h:342
SG::CurrentEventStore::Push
Temporarily change the current store.
Definition: SGTools/SGTools/CurrentEventStore.h:58
SG::DataProxy::RECURSIVEREAD
@ RECURSIVEREAD
Definition: DataProxy.h:48
SG::TransientAddress::reset
void reset()
Retrieve IOpaqueAddress.
Definition: TransientAddress.h:187
SG::BaseInfoBase::get_bases
const std::vector< CLID > & get_bases() const
Return the class IDs of all known bases of T (that have class IDs).
Definition: BaseInfo.cxx:304
SG::DataProxy::NOCNVSVC
@ NOCNVSVC
Definition: DataProxy.h:47
SG::DataProxy::lock
void lock(objLock_t &)
Lock the data object we're holding, if any.
Definition: DataProxy.cxx:628
IProxyDict::createObj
virtual StatusCode createObj(IConverter *cvt, IOpaqueAddress *addr, DataObject *&refpObject)
Call converter to create an object, possibly with locking.
Definition: IProxyDict.cxx:70
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:51
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
SG::DataProxy::NOIOA
@ NOIOA
Definition: DataProxy.h:47
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:208
IProxyDict::proxy_exact
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const =0
Get proxy given a hashed key+clid.
IResetable
a resetable object (e.g. a SG DataHandle)
Definition: IResetable.h:15
SG::DataProxy::address
virtual IOpaqueAddress * address() const override final
Retrieve IOpaqueAddress.
SG::DataProxy::contextFromStore
const EventContext & contextFromStore() const
Retrieve the EventContext saved in the owning store.
Definition: DataProxy.cxx:646
IProxyDict::boundHandle
virtual void boundHandle(IResetable *handle)
Tell the store that a handle has been bound to a proxy.
Definition: IProxyDict.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:92
SG::DataProxy::m_objMutex
objMutex_t m_objMutex
Definition: DataProxy.h:343
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::DataProxy::m_dObject
std::atomic< DataObject * > m_dObject
Definition: DataProxy.h:319
SG::DataProxy::lock_t
std::lock_guard< mutex_t > lock_t
Definition: DataProxy.h:337
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:201
SG::TransientAddress::isValid
bool isValid(const EventContext *ctx, bool forceUpdate=false)
cache the pointer to the Address provider which can update this transient address
Definition: TransientAddress.cxx:179
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
SG::T2pMap::t2pRegister
bool t2pRegister(const void *const pTrans, DataProxy *const pPers)
Definition: T2pMap.h:34
SG::DataProxy::m_origConst
bool m_origConst
Was the proxy created as const?
Definition: DataProxy.h:317
SG::DataProxy::m_const
std::atomic< bool > m_const
Is the proxy currently const?
Definition: DataProxy.h:315
SG::DataProxy::T2PREGFAILED
@ T2PREGFAILED
Definition: DataProxy.h:47
SG::DataProxy::store
IProxyDict * store()
Return the store of which we're a part.
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
SG::DataProxy::m_refCount
unsigned int m_refCount
Definition: DataProxy.h:302
SG::DataProxy::clID
CLID clID() const
Retrieve clid.
SG::DataProxy::ALLOK
@ ALLOK
Definition: DataProxy.h:47
SG::DataProxy::setObject
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.
Definition: DataProxy.cxx:392
SG::DataProxy::DataProxy
DataProxy()
Definition: DataProxy.cxx:91
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
IProxyDict::unboundHandle
virtual void unboundHandle(IResetable *handle)
Tell the store that a handle has been unbound from a proxy.
Definition: IProxyDict.cxx:33
SG::BaseInfoBase::find
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
Definition: BaseInfo.cxx:569
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
SG::DataProxy::name
virtual const name_type & name() const override final
Retrieve data object key == string.
SG::DataProxy::resetRef
void resetRef()
Drop the reference to the data object.
Definition: DataProxy.cxx:230
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
SG::TransientAddress::setAddress
void setAddress(IOpaqueAddress *pAddress)
Retrieve primary clid.
Definition: TransientAddress.cxx:172
ir
int ir
counter of the current depth
Definition: fastadd.cxx:49
h
SG::DataProxy::resetOnly
void resetOnly(const bool &flag)
set the reset only flag: Clear Store will reset and not delete.
SG::DataProxy::m_resetFlag
bool m_resetFlag
reset and not delete: default is true
Definition: DataProxy.h:305
SG::DataProxy::NERRORS
@ NERRORS
Definition: DataProxy.h:48
SG::BaseInfoBase
The non-template portion of the BaseInfo implementation.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:451
SG::DataProxy::CNVFAILED
@ CNVFAILED
Definition: DataProxy.h:47
SG::DataProxy::isValidAddress
bool isValidAddress() const
is the address valid?
Definition: DataProxy.cxx:566
pickleTool.object
object
Definition: pickleTool.py:30
SG::DataProxy::m_errno
enum ErrNo m_errno
errno-style error code for accessData
Definition: DataProxy.h:352
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
SG::DataProxy::finalReset
void finalReset()
Definition: DataProxy.cxx:250
SG::DataProxy::m_tAddress
TransientAddress m_tAddress
Definition: DataProxy.h:321
python.PyAthena.obj
obj
Definition: PyAthena.py:135
SG::DataProxy::errNo
ErrNo errNo() const
SG::DataProxy::m_mutex
mutex_t m_mutex
Definition: DataProxy.h:338
SG::DataProxy
Definition: DataProxy.h:44
SG::DataProxy::readData
std::unique_ptr< DataObject > readData()
Read in a new copy of the object referenced by this proxy.
Definition: DataProxy.cxx:420
SG::DataProxy::m_dataLoader
IConverter * m_dataLoader
Definition: DataProxy.h:323
SG::DataProxy::m_handles
handleList_t m_handles
Definition: DataProxy.h:329