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 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. 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
 
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...
 
objMutex_t m_objMutex
 
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 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

Definition at line 54 of file DataProxy.h.

◆ handleList_t

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

list of bound DataHandles

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

◆ mutex_t

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

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

◆ objMutex_t

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

Definition at line 351 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 92 of file DataProxy.cxx.

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

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

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

◆ DataProxy() [3/7]

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

build from TransientAddress

Definition at line 119 of file DataProxy.cxx.

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

◆ DataProxy() [4/7]

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

Definition at line 128 of file DataProxy.cxx.

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

◆ DataProxy() [5/7]

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

build from DataObject

Definition at line 149 of file DataProxy.cxx.

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

◆ DataProxy() [6/7]

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

Definition at line 168 of file DataProxy.cxx.

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

◆ ~DataProxy()

DataProxy::~DataProxy ( )
virtual

Definition at line 187 of file DataProxy.cxx.

188 {
189  finalReset();
190 }

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

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

◆ addRef()

unsigned long DataProxy::addRef ( )
finaloverridevirtual

Add reference to object.

Definition at line 314 of file DataProxy.cxx.

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

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

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

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

707 {
709  if (store) {
710  static const SG::sgkey_t ctxkey =
712  SG::DataProxy* proxy = store->proxy_exact (ctxkey);
713  if (proxy && proxy->object()) {
714  EventContext* ctx = SG::DataProxy_cast<EventContext> (proxy);
715  if (ctx) return *ctx;
716  }
717  }
718  static const EventContext emptyContext;
719  return emptyContext;
720 }

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

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

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

576 {
577  // Looking up the context is relatively expensive.
578  // So first try isValid() without the context.
579  {
580  lock_t lock (m_mutex);
581  if (const_cast<DataProxy*>(this)->m_tAddress.isValid(nullptr)) {
582  return true;
583  }
584  }
585  // Get the context. (Must not be holding m_mutex here.)
586  const EventContext& ctx = contextFromStore();
587  // Try again with the context.
588  lock_t lock (m_mutex);
589  return const_cast<DataProxy*>(this)->m_tAddress.isValid(&ctx);
590 }

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

689 {
690  DataObject* dobj = m_dObject;
691  DataBucketBase* bucket = dynamic_cast<DataBucketBase*>(dobj);
692  if (bucket)
693  bucket->lock();
694 }

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

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

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

441 {
442  if (errNo) {
443  if (*errNo == RECURSIVEREAD) {
444  // This can end up being called from noexcept functions.
445  // Creating a MsgStream can throw an exception --- don't let
446  // it escape.
447  try {
448  MsgStream gLog(m_ims, "DataProxy");
449  gLog << MSG::ERROR
450  << "readData: ERROR recursive read for object"
451  <<m_tAddress.clID() << '/' << m_tAddress.name() << '\n'
452  <<" Returning NULL DataObject pointer " << endmsg;
453  }
454  catch (const GaudiException&) {
455  std::cerr << "DataProxy::readData: Problem creating MsgStream\n";
456  }
457  return nullptr;
458  }
459  *errNo = RECURSIVEREAD;
460  }
461 
462  IConverter* dataLoader;
463  IProxyDict* store;
464  IOpaqueAddress* address;
465  {
466  lock_t lock (m_mutex);
467  if (0 == m_dataLoader) {
468  //MsgStream gLog(m_ims, "DataProxy");
469  //gLog << MSG::WARNING
470  // << "accessData: IConverter ptr not set" <<endmsg;
471  if (errNo) *errNo=NOCNVSVC;
472  return nullptr;
473  }
474 
475  dataLoader = m_dataLoader;
476  store = m_store;
477  address = m_tAddress.address();
478  }
479 
480  if (!isValidAddress()) {
481  //MsgStream gLog(m_ims, "DataProxy");
482  //gLog << MSG::WARNING
483  // << "accessData: IOA pointer not set" <<endmsg;
484  if (errNo) *errNo=NOIOA;
485  return nullptr;
486  }
487 
489 
490  DataObject* obj = nullptr;
491  StatusCode sc;
492  if (store)
493  sc = store->createObj (dataLoader, address, obj);
494  else
495  sc = dataLoader->createObj (address, obj);
496  if (sc.isSuccess()) {
497  if (errNo && *errNo == RECURSIVEREAD) *errNo = ALLOK;
498  return std::unique_ptr<DataObject>(obj);
499  }
500  if (errNo) *errNo = CNVFAILED;
501  return nullptr;
502 }

◆ refCount()

unsigned long DataProxy::refCount ( ) const

return refCount

Definition at line 307 of file DataProxy.cxx.

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

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

676 {
677  lock_t lock (m_mutex);
678  if (m_t2p)
679  m_t2p->t2pRegister (p, this);
680 }

◆ release()

unsigned long DataProxy::release ( )
finaloverridevirtual

release reference to object

Definition at line 321 of file DataProxy.cxx.

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

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

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

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

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

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

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

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

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

◆ setAddress()

void DataProxy::setAddress ( IOpaqueAddress *  ioa)
finaloverridevirtual

set an IOpaqueAddress

Definition at line 401 of file DataProxy.cxx.

402 {
403  lock_t lock (m_mutex);
405 }

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

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

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

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

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

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

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

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

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

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

◆ updateAddress()

bool DataProxy::updateAddress ( )

Definition at line 592 of file DataProxy.cxx.

593 {
594  // Be sure to get the context before acquiring the lock.
595  const EventContext& ctx = contextFromStore();
596  lock_t lock (m_mutex);
597  return m_tAddress.isValid(&ctx, true);
598 }

Friends And Related Function Documentation

◆ SG::DataStore

friend class SG::DataStore
friend

For access to requestRelease.

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

◆ m_const

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

Is the proxy currently const?

Definition at line 316 of file DataProxy.h.

◆ m_dataLoader

IConverter* SG::DataProxy::m_dataLoader
private

Definition at line 324 of file DataProxy.h.

◆ m_dObject

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

Definition at line 320 of file DataProxy.h.

◆ m_errno

enum ErrNo SG::DataProxy::m_errno
private

errno-style error code for accessData

Definition at line 344 of file DataProxy.h.

◆ m_handles

handleList_t SG::DataProxy::m_handles
private

Definition at line 330 of file DataProxy.h.

◆ m_ims

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

Definition at line 341 of file DataProxy.h.

◆ m_mutex

mutex_t SG::DataProxy::m_mutex
mutableprivate

Definition at line 339 of file DataProxy.h.

◆ m_objMutex

objMutex_t SG::DataProxy::m_objMutex
mutableprivate

Definition at line 353 of file DataProxy.h.

◆ m_origConst

bool SG::DataProxy::m_origConst
private

Was the proxy created as const?

Definition at line 318 of file DataProxy.h.

◆ m_refCount

unsigned int SG::DataProxy::m_refCount
private

Definition at line 303 of file DataProxy.h.

◆ m_resetFlag

bool SG::DataProxy::m_resetFlag
private

reset and not delete: default is true

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

◆ m_t2p

T2pMap* SG::DataProxy::m_t2p
private

Definition at line 326 of file DataProxy.h.

◆ m_tAddress

TransientAddress SG::DataProxy::m_tAddress
private

Definition at line 322 of file DataProxy.h.


The documentation for this class was generated from the following files:
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
Definition: DataProxy_cast.h:53
SG::DataProxy::handleList_t
std::vector< IResetable * > handleList_t
list of bound DataHandles
Definition: DataProxy.h:329
SG::DataProxy::m_boundHandles
bool m_boundHandles
True if there are any bound handles.
Definition: DataProxy.h:313
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:407
SG::DataProxy::m_store
std::atomic< IProxyDict * > m_store
The store of which we are a part.
Definition: DataProxy.h:344
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:277
calibdata.force
bool force
Definition: calibdata.py:18
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:326
SG::DataProxy::m_ims
Athena::IMessageSvcHolder m_ims
Definition: DataProxy.h:341
SG::DataProxy::objLock_t
std::lock_guard< objMutex_t > objLock_t
Definition: DataProxy.h:352
SG::CurrentEventStore::Push
Temporarily change the current store.
Definition: SGTools/SGTools/CurrentEventStore.h:58
SG::DataProxy::RECURSIVEREAD
@ RECURSIVEREAD
Definition: DataProxy.h:49
SG::TransientAddress::reset
void reset()
Retrieve IOpaqueAddress.
Definition: TransientAddress.h:196
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:48
SG::DataProxy::lock
void lock(objLock_t &)
Lock the data object we're holding, if any.
Definition: DataProxy.cxx:688
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:47
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
SG::DataProxy::NOIOA
@ NOIOA
Definition: DataProxy.h:48
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:217
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
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
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:706
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:85
SG::DataProxy::m_objMutex
objMutex_t m_objMutex
Definition: DataProxy.h:353
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:320
SG::DataProxy::lock_t
std::lock_guard< mutex_t > lock_t
Definition: DataProxy.h:338
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:210
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:201
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
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:318
SG::DataProxy::m_const
std::atomic< bool > m_const
Is the proxy currently const?
Definition: DataProxy.h:316
SG::DataProxy::T2PREGFAILED
@ T2PREGFAILED
Definition: DataProxy.h:48
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:303
SG::DataProxy::clID
CLID clID() const
Retrieve clid.
SG::DataProxy::ALLOK
@ ALLOK
Definition: DataProxy.h:48
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:393
SG::DataProxy::DataProxy
DataProxy()
Definition: DataProxy.cxx:92
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:570
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:231
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:194
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:306
SG::DataProxy::NERRORS
@ NERRORS
Definition: DataProxy.h:49
SG::BaseInfoBase
The non-template portion of the BaseInfo implementation.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:451
SG::DataProxy::CNVFAILED
@ CNVFAILED
Definition: DataProxy.h:48
SG::DataProxy::isValidAddress
bool isValidAddress() const
is the address valid?
Definition: DataProxy.cxx:575
pickleTool.object
object
Definition: pickleTool.py:29
SG::DataProxy::m_errno
enum ErrNo m_errno
errno-style error code for accessData
Definition: DataProxy.h:347
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
SG::DataProxy::finalReset
void finalReset()
Definition: DataProxy.cxx:251
SG::DataProxy::m_tAddress
TransientAddress m_tAddress
Definition: DataProxy.h:322
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::DataProxy::errNo
ErrNo errNo() const
SG::DataProxy::m_mutex
mutex_t m_mutex
Definition: DataProxy.h:339
SG::DataProxy
Definition: DataProxy.h:45
SG::DataProxy::readData
std::unique_ptr< DataObject > readData()
Read in a new copy of the object referenced by this proxy.
Definition: DataProxy.cxx:421
SG::DataProxy::m_dataLoader
IConverter * m_dataLoader
Definition: DataProxy.h:324
SG::DataProxy::m_handles
handleList_t m_handles
Definition: DataProxy.h:330