ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
SG::DataProxyHolder Class Reference

Manage DataProxy reference in ElementLink/DataLink. More...

#include <DataProxyHolder.h>

Collaboration diagram for SG::DataProxyHolder:

Public Types

typedef IStringPool::sgkey_t sgkey_t
 Type of hashed keys. More...
 
typedef std::string ID_type
 Type of string keys. More...
 
typedef void * pointer_t
 Generic pointer type. More...
 
typedef const void * const_pointer_t
 
typedef void * castfn_t(SG::DataProxy *)
 Function casting from a SG::DataProxy to a pointer. More...
 
typedef Athena::IInputRename::InputRenameMap_t InputRenameMap_t
 Input renaming map. More...
 
typedef Athena::IInputRename::InputRenameRCU_t InputRenameRCU_t
 

Public Member Functions

 DataProxyHolder ()
 Default constructor. More...
 
template<class FROM_STORABLE , class TO_STORABLE >
 DataProxyHolder (const DataProxyHolder &other, FROM_STORABLE *, TO_STORABLE *)
 Constructor from a holder referencing a different type. More...
 
 DataProxyHolder (const DataProxyHolder &)=default
 
DataProxyHolderoperator= (const DataProxyHolder &)=default
 
void clear ()
 Reset the link to null. More...
 
sgkey_t toStorableObject (const_pointer_t obj, CLID link_clid, IProxyDict *sg)
 Set the link to an object given by a pointer. More...
 
sgkey_t toIdentifiedObject (const ID_type &dataID, CLID link_clid, IProxyDict *sg)
 Set the link to an object given by a string key. More...
 
void toIdentifiedObject (sgkey_t key, CLID link_clid, IProxyDict *sg)
 Set the link to an object given by a hashed key. More...
 
bool isDefault () const
 Test to see if this is a null link. More...
 
const ID_typedataID () const
 Return the SG key that we reference, as a string. More...
 
void * storableBase (castfn_t *castfn, CLID clid, bool isConst) const
 Return a pointer to the currently-referenced object. More...
 
SG::DataProxyproxy (bool nothrow=false) const
 Return the DataProxy for this link. More...
 
IProxyDictsource () const
 Return the data source for this reference. More...
 
void toTransient (sgkey_t sgkey, IProxyDict *sg=0)
 Finish initialization after link has been read. More...
 
sgkey_t toTransient (const ID_type &dataID, CLID link_clid, IProxyDict *sg=0)
 Finish initialization after link has been read. More...
 
void toPersistentNoRemap (sgkey_t &sgkey)
 Prepare this link for writing. More...
 
bool toPersistent (sgkey_t &sgkey, uint64_t &index)
 Prepare this link for writing. More...
 
bool toPersistent (sgkey_t &sgkey, uint32_t &index)
 Prepare this link for writing. More...
 
template<class T >
bool toPersistent (sgkey_t &sgkey, const T &)
 Prepare this link for writing. More...
 
bool operator== (const DataProxyHolder &other) const
 Compare for equality. More...
 
void throwInvalidLink (sgkey_t sgkey) const
 Throw a ExcInvalidLink exception for this link. More...
 

Static Public Member Functions

static bool thin (sgkey_t &sgkey, size_t &index, const SG::ThinningCache *thinningCache)
 Adjust for thinning, with explicitly provided thinning cache. More...
 
static void setInputRenameMap ATLAS_NOT_THREAD_SAFE (const InputRenameRCU_t *map)
 Set map used for performing input renaming in toTransient. More...
 
static void resetCachedSource ()
 

Private Member Functions

bool isObjpointer () const
 Test to see if we're pointing directly at an object. More...
 
pointer_t objpointer () const
 Return a pointer to the object we're pointing at directly. More...
 
void storeObjpointer (const_pointer_t p)
 Store a direct pointer to an object. More...
 
SG::DataProxyproxy1 (bool nothrow) const
 Helper for proxy(), for the case of a direct object pointer. More...
 
IProxyDictsource1 ()
 Return the data source for this reference. More...
 
bool tryRemap (sgkey_t &sgkey, size_t &index)
 Test to see if the link has been remapped. More...
 

Private Attributes

SG::DataProxym_proxy
 The DataProxy referring to our object, if the LSB is clear; pointer to the object which we're referencing directly if the LSB is set. More...
 

Detailed Description

Manage DataProxy reference in ElementLink/DataLink.

This class factors out operations on DataProxy that are common between ElementLink and DataLink, and holds a pointer to the proxy. This pointer is transient; the (persistent) SG key field is stored in the class that holds this one, and is passed as a parameter where needed.

We can be initialized either with a key or with a pointer to an object. In the former case, we try immediately to look up the proxy for that key. If we find it, then we use it; otherwise, we create a dummy DataProxy for that key and add it to our store. If we're given a pointer, we again immediately try to look up the corresponding proxy. If we don't find it, then we store the pointer directly in the proxy member, with a flag to identify this case. Subsequent operations that require a proxy will again try to look up the proxy in the store; if that fails, then an exception will be thrown.

When we create a new link, the store by default is taken from the global default given by SG::CurrentEventStore::store(). This is a thread-specific value, so fetching it can be expensive. If you are creating links inside a loop, it is best to fetch the default before the loop and then passing the result explicitly when you create the links.

Definition at line 60 of file DataProxyHolder.h.

Member Typedef Documentation

◆ castfn_t

typedef void* SG::DataProxyHolder::castfn_t(SG::DataProxy *)

Function casting from a SG::DataProxy to a pointer.

Definition at line 74 of file DataProxyHolder.h.

◆ const_pointer_t

Definition at line 71 of file DataProxyHolder.h.

◆ ID_type

typedef std::string SG::DataProxyHolder::ID_type

Type of string keys.

Definition at line 67 of file DataProxyHolder.h.

◆ InputRenameMap_t

Input renaming map.

Definition at line 77 of file DataProxyHolder.h.

◆ InputRenameRCU_t

Definition at line 78 of file DataProxyHolder.h.

◆ pointer_t

Generic pointer type.

Definition at line 70 of file DataProxyHolder.h.

◆ sgkey_t

Type of hashed keys.

Definition at line 64 of file DataProxyHolder.h.

Constructor & Destructor Documentation

◆ DataProxyHolder() [1/3]

SG::DataProxyHolder::DataProxyHolder ( )

Default constructor.

Make a null link.

◆ DataProxyHolder() [2/3]

template<class FROM_STORABLE , class TO_STORABLE >
SG::DataProxyHolder::DataProxyHolder ( const DataProxyHolder other,
FROM_STORABLE *  ,
TO_STORABLE *   
)

Constructor from a holder referencing a different type.

Parameters
otherThe object from which to copy.

FROM_STORABLE is the storable class to which other refers; TO_STORABLE is the storable class for this object. The actual pointer values are not used, just the types are used. Default conversions for the storable pointer (i.e., derived->base) are allowed.

◆ DataProxyHolder() [3/3]

SG::DataProxyHolder::DataProxyHolder ( const DataProxyHolder )
default

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

static void setInputRenameMap SG::DataProxyHolder::ATLAS_NOT_THREAD_SAFE ( const InputRenameRCU_t map)
static

Set map used for performing input renaming in toTransient.

Parameters
mapThe new map, or nullptr for no renmaing.

◆ clear()

void SG::DataProxyHolder::clear ( )

Reset the link to null.

◆ dataID()

const DataProxyHolder::ID_type & SG::DataProxyHolder::dataID ( ) const

Return the SG key that we reference, as a string.

Returns a null string on failure.

Definition at line 227 of file DataProxyHolder.cxx.

228 {
229  SG::DataProxy* dp = proxy (true);
230  if (dp)
231  return dp->name();
232 
233  static const std::string dummy;
234  return dummy;
235 }

◆ isDefault()

bool SG::DataProxyHolder::isDefault ( ) const

Test to see if this is a null link.

◆ isObjpointer()

bool SG::DataProxyHolder::isObjpointer ( ) const
private

Test to see if we're pointing directly at an object.

Returns
True if we're pointing directly at an object, false if we're pointing at a DataProxy (or the link is null).

◆ objpointer()

pointer_t SG::DataProxyHolder::objpointer ( ) const
private

Return a pointer to the object we're pointing at directly.

Should be used only if isObjpointer() is true.

◆ operator=()

DataProxyHolder& SG::DataProxyHolder::operator= ( const DataProxyHolder )
default

◆ operator==()

bool SG::DataProxyHolder::operator== ( const DataProxyHolder other) const

Compare for equality.

Definition at line 583 of file DataProxyHolder.cxx.

584 {
585  if (m_proxy == other.m_proxy) return true;
586 
587  // One could refer to an object directly by pointer, the other could
588  // have a proxy.
589 
590  const_pointer_t ptr = 0;
591  const DataProxy* proxy = 0;
592  if (isObjpointer() && !other.isObjpointer()) {
593  ptr = objpointer();
594  proxy = other.m_proxy;
595  }
596  else if (other.isObjpointer() && !isObjpointer()) {
597  ptr = other.objpointer();
598  proxy = m_proxy;
599  }
600  else
601  return false;
602 
603  if (proxy->store()->proxy(ptr) == proxy)
604  return true;
605 
606  return false;
607 }

◆ proxy()

SG::DataProxy* SG::DataProxyHolder::proxy ( bool  nothrow = false) const

Return the DataProxy for this link.

Parameters
nothrowIf true, return 0 on failure instead of throwing an exception.

If this is a null link, we return 0. Otherwise, if we're pointing at a DataProxy, return it. Otherwise, we're pointing at an object directly. Try to look up the corresponding DataProxy using the default store. Return it if we find it; otherwise, either throw ExcPointerNotInSG or return 0, depending on the nothrow parameter.

◆ proxy1()

SG::DataProxy * SG::DataProxyHolder::proxy1 ( bool  nothrow) const
private

Helper for proxy(), for the case of a direct object pointer.

Parameters
nothrowIf true, return 0 on failure instead of throwing an exception.

This is the out-of-line portion of proxy(), called if this link is directly pointing at an object. Try to look up the corresponding DataProxy using the default store. Return it if we find it; otherwise, either throw ExcPointerNotInSG or return 0, depending on the nothrow parameter.

Definition at line 568 of file DataProxyHolder.cxx.

569 {
570  const_pointer_t obj = reinterpret_cast<const_pointer_t>
571  (reinterpret_cast<unsigned long> (m_proxy) & ~1UL);
573  if (proxy == 0 && !nothrow)
574  throw SG::ExcPointerNotInSG (obj);
575  return proxy;
576 }

◆ resetCachedSource()

static void SG::DataProxyHolder::resetCachedSource ( )
static

◆ source()

IProxyDict * SG::DataProxyHolder::source ( ) const

Return the data source for this reference.

If the link is null, return 0. If we're pointing at an object directly, then we return the default store if the object is found in SG; otherwise, throw ExcPointerNotInSG.

Definition at line 303 of file DataProxyHolder.cxx.

304 {
305  SG::DataProxy* dp = proxy();
306  if (!dp)
307  return 0;
308  return dp->store();
309 }

◆ source1()

IProxyDict* SG::DataProxyHolder::source1 ( )
private

Return the data source for this reference.

If we're holding a pointer directly, rather than a proxy, then return 0 rather than raising an exception.

◆ storableBase()

void * SG::DataProxyHolder::storableBase ( castfn_t castfn,
CLID  clid,
bool  isConst 
) const

Return a pointer to the currently-referenced object.

Parameters
castfnFunction to do the cast from data proxy to object. If 0, use a dynamic cast.
clidThe CLID of the desired object. This is used to determine how the returned pointer is to be converted.
isConstTrue if the returned object will be treated as const.
Returns
A pointer to an object of the type given by clid, or null on a failure (or if the reference is null).

Definition at line 249 of file DataProxyHolder.cxx.

252 {
253  // Test for null link.
254  if (!m_proxy)
255  return 0;
256 
257  // Test for direct pointer to an object.
258  if (isObjpointer())
259  return objpointer();
260 
261  // We have a proxy. Check that we're not trying to use an object
262  // that's been marked const in SG in a non-const way.
263  if (!isConst && m_proxy->isConst()) {
265  m_proxy->name(),
266  m_proxy->sgkey());
267  }
268 
269  // Ok --- DataProxy is thread-safe.
271 
272  // Get the object pointer from the proxy.
273  // We have to take care of converting to the proper return type, though
274  // (as requested by clid).
275  void* obj = castfn ? castfn (m_proxy) : SG::DataProxy_cast (proxy_nc, clid);
276  if (obj)
277  return obj;
278 
279  // We failed. It may be that we don't have a conversion
280  // between clid and the object type: it may have been stored
281  // using a hard cast. Check to see if this object has actually
282  // been registered under the requested clid.
283  if (m_proxy->transientID (clid)) {
284  DataBucketBase* db =
285  dynamic_cast<DataBucketBase*> (proxy_nc->accessData());
286 
287  // Do a hard cast...
288  if (db)
289  return db->object();
290  }
291 
292  return 0;
293 }

◆ storeObjpointer()

void SG::DataProxyHolder::storeObjpointer ( const_pointer_t  p)
private

Store a direct pointer to an object.

Parameters
pPointer to the object that we're referencing.

This will overwrite m_proxy with the reference to the object.

◆ thin()

bool SG::DataProxyHolder::thin ( sgkey_t sgkey,
size_t &  index,
const SG::ThinningCache thinningCache 
)
static

Adjust for thinning, with explicitly provided thinning cache.

Adjust for thinning.

Parameters
sgkeyReference to the hashed SG key.
indexIndex of this link.
thinningCacheThinning cache for the current stream (may be null).

If this link points to a container that has been thinned, sgkey and index will be adjusted accordingly.

Returns true if the index was changed; false otherwise.

Definition at line 504 of file DataProxyHolder.cxx.

506 {
507  if (!sgkey) {
508  return false;
509  }
510 
511  // Check for thinning.
512  if (thinningCache) {
513  const SG::ThinningDecisionBase* dec = thinningCache->thinning (sgkey);
514  if (dec) {
515  // Get the updated index:
516  const std::size_t persIdx = dec->index( index );
517 
518  // If the object was thinned away, set the persistent variables to an
519  // invalid state. Otherwise update just the index variable.
520  if( persIdx == ThinningDecisionBase::RemovedIdx ) {
521  sgkey = 0;
522  index = 0;
523  return true;
524  }
525  else {
526  if (index != persIdx) {
527  index = persIdx;
528  return true;
529  }
530  }
531  }
532  }
533 
534  return false;
535 }

◆ throwInvalidLink()

void SG::DataProxyHolder::throwInvalidLink ( sgkey_t  sgkey) const

Throw a ExcInvalidLink exception for this link.

Parameters
sgkeyThe hashed key for this link.

This will fill in parameters for the exception message from the proxy.

Definition at line 544 of file DataProxyHolder.cxx.

545 {
546  CLID clid = CLID_NULL;
547  std::string key;
548  SG::DataProxy* dp = proxy();
549  if (dp) {
550  clid = dp->clID();
551  key = dp->name();
552  }
553  throw SG::ExcInvalidLink (clid, key, sgkey);
554 }

◆ toIdentifiedObject() [1/2]

DataProxyHolder::sgkey_t SG::DataProxyHolder::toIdentifiedObject ( const ID_type dataID,
CLID  link_clid,
IProxyDict sg 
)

Set the link to an object given by a string key.

Parameters
dataIDKey of the object.
link_clidCLID of the link being set.
sgAssociated store.
Returns
The SG key for this object.

This will try to look up the proxy for dataID. If that succeeds, then we store the pointer to the proxy. Otherwise, we create a dummy proxy and add it to the store. We return the SG key in either case.

If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.

Definition at line 123 of file DataProxyHolder.cxx.

126 {
127  // Find the store to use.
128  if (sg == 0)
129  sg = this->source1();
130  if (sg == 0)
132 
133  if (!sg)
134  return 0;
135 
136  // Look up the proxy.
137  m_proxy = sg->proxy (link_clid, dataID);
138  if (m_proxy == 0) {
139  // Didn't find a proxy; make a dummy.
140  SG::TransientAddress tad (link_clid, dataID);
141  tad.setSGKey (sg->stringToKey (dataID, link_clid));
142  m_proxy = new SG::DataProxy (std::move(tad), static_cast<IConverter*>(nullptr));
143  if (sg->addToStore (link_clid, m_proxy).isFailure())
144  std::abort();
145  }
146 
147  // Return the proxy's sgkey.
148  return m_proxy->sgkey();
149 }

◆ toIdentifiedObject() [2/2]

void SG::DataProxyHolder::toIdentifiedObject ( sgkey_t  sgkey,
CLID  link_clid,
IProxyDict sg 
)

Set the link to an object given by a hashed key.

Parameters
keyHashed key of the object.
link_clidCLID of the link being set.
sgAssociated store.

This will try to look up the proxy for key. If that succeeds, then we store the pointer to the proxy. Otherwise, we create a dummy proxy and add it to the store.

If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.

May throw ExcCLIDMismatch.

Definition at line 169 of file DataProxyHolder.cxx.

172 {
173  if (!sgkey) return;
174 
175  // Find the store to use.
176  if (sg == 0)
177  sg = this->source1();
178  if (sg == 0)
180 
181  if (!sg)
182  return;
183 
184  // Look up the proxy.
185  m_proxy = sg->proxy_exact (sgkey);
186 
187  CLID clid = CLID_NULL;
188  const std::string* key = nullptr;
189  if (m_proxy == 0) {
190  // Didn't find it --- have SG query proxy providers.
191  // Try to turn the hashed key into a string key + clid.
192  key = sg->keyToString (sgkey, clid);
193  if (key) {
194  if (link_clid != CLID_NULL && clid != link_clid)
195  throw SG::ExcCLIDMismatch (clid, link_clid);
196  m_proxy = sg->proxy (clid, *key);
197  }
198  }
199 
200  if (m_proxy == 0) {
201  // Still didn't find it --- make a dummy.
203  if (key) {
204  tad = SG::TransientAddress (clid, *key);
205  }
206  tad.setSGKey (sgkey);
207  m_proxy = new SG::DataProxy (std::move(tad), static_cast<IConverter*>(nullptr));
208  if (sg->addToStore (clid, m_proxy).isFailure())
209  std::abort();
210  }
211  else if (link_clid != CLID_NULL &&
212  m_proxy->clID() != CLID_NULL &&
213  !m_proxy->transientID(link_clid))
214  {
215  // Found a proxy, but types don't match.
216  throw SG::ExcCLIDMismatch (m_proxy->clID(), link_clid);
217  }
218 }

◆ toPersistent() [1/3]

template<class T >
bool SG::DataProxyHolder::toPersistent ( sgkey_t sgkey,
const T &   
)

Prepare this link for writing.

Parameters
sgkeyReference to the hashed SG key.
indexIndex of this link.

One of the toPersistent methods should be called before trying to write the link with root.

This takes a reference to the hashed SG key. In the case where we're referencing an object directly by pointer, the hashed key will be 0. In that case, we try to look up the object in the default store. If we find it, the hashed key is updated appropriately; otherwise, we throw ExcPointerNotInSG.

This version is for the case where indices are not given by size_t. No remapping will be performed for this case; this function will always return false.

◆ toPersistent() [2/3]

bool SG::DataProxyHolder::toPersistent ( sgkey_t sgkey,
uint32_t &  index 
)

Prepare this link for writing.

Parameters
sgkeyReference to the hashed SG key.
indexIndex of this link.

One of the toPersistent methods should be called before trying to write the link with root.

This takes a reference to the hashed SG key. In the case where we're referencing an object directly by pointer, the hashed key will be 0. In that case, we try to look up the object in the default store. If we find it, the hashed key is updated appropriately; otherwise, we throw ExcPointerNotInSG.

If the target of the link has been remapped, then the sgkey and index parameters will be updated to reflect that, and true will be returned. Otherwise, if there was no remapping, then false will be returned.

This version is for the case where indices are given by uint32_t.

Definition at line 452 of file DataProxyHolder.cxx.

453 {
455  size_t index_s = index;
456  bool ret = tryRemap (sgkey, index_s);
457  if (ret)
458  index = static_cast<uint32_t>(index_s);
459  return ret;
460 }

◆ toPersistent() [3/3]

bool SG::DataProxyHolder::toPersistent ( sgkey_t sgkey,
uint64_t &  index 
)

Prepare this link for writing.

Parameters
sgkeyReference to the hashed SG key.
indexIndex of this link.

One of the toPersistent methods should be called before trying to write the link with root.

This takes a reference to the hashed SG key. In the case where we're referencing an object directly by pointer, the hashed key will be 0. In that case, we try to look up the object in the default store. If we find it, the hashed key is updated appropriately; otherwise, we throw ExcPointerNotInSG.

If the target of the link has been remapped, then the sgkey and index parameters will be updated to reflect that, and true will be returned. Otherwise, if there was no remapping, then false will be returned.

This version is for the case where indices are given by uint64_t.

Definition at line 421 of file DataProxyHolder.cxx.

422 {
424  size_t index_s = index;
425  bool ret = tryRemap (sgkey, index_s);
426  if (ret)
427  index = index_s;
428  return ret;
429 }

◆ toPersistentNoRemap()

void SG::DataProxyHolder::toPersistentNoRemap ( sgkey_t sgkey)

Prepare this link for writing.

Parameters
sgkeyReference to the hashed SG key.

One of the toPersistent methods should be called before trying to write the link with root.

This takes a reference to the hashed SG key. In the case where we're referencing an object directly by pointer, the hashed key will be 0. In that case, we try to look up the object in the default store. If we find it, the hashed key is updated appropriately; otherwise, we throw ExcPointerNotInSG.

This version does not perform link remapping.

Definition at line 392 of file DataProxyHolder.cxx.

393 {
394  if (!sgkey && m_proxy) {
395  m_proxy = proxy(); // May throw.
396  sgkey = m_proxy->sgkey();
397  }
398 }

◆ toStorableObject()

DataProxyHolder::sgkey_t SG::DataProxyHolder::toStorableObject ( const_pointer_t  obj,
CLID  link_clid,
IProxyDict sg 
)

Set the link to an object given by a pointer.

Parameters
objPointer to the object.
link_clidCLID of the link being set.
sgAssociated store.
Returns
The SG key for this object.

This will try to look up the proxy for obj. If that succeeds, then we store the pointer to the proxy and return the SG key. Otherwise, we store a pointer to the object itself, flagging this case with the low bit, and return 0.

If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.

May throw ExcCLIDMismatch.

Parameters
objPointer to the object.
link_clidCLID of the link being set.
sgAssociated store.
Returns
The SG key for this object.

This will try to look up the proxy for obj. If that succeeds, then we store the pointer to the proxy and return the SG key. Otherwise, we store a pointer to the object itself, flagging this case with the low bit, and return 0.

If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.

Definition at line 58 of file DataProxyHolder.cxx.

61 {
62  sgkey_t key = 0;
63  if (obj == 0) {
64  // Setting the link to null.
65  m_proxy = 0;
66  }
67  else {
68  // Find the store to use.
69  if (sg == 0)
70  sg = this->source1();
71  if (sg == 0)
73 
74  if (sg) {
75  m_proxy = sg->proxy (obj);
76  }
77  if (m_proxy == 0) {
78  // Didn't find a proxy for this object.
79  // Store the object pointer directly, and return 0.
81  }
82  else {
83  // Found a proxy. Fetch the SG key and check that the type of the object
84  // is consistent with the link type.
85  key = m_proxy->sgkey();
86  if (link_clid != m_proxy->clID() && !m_proxy->transientID (link_clid)) {
87  if (m_proxy->clID() != CLID_NULL)
88  throw SG::ExcCLIDMismatch (m_proxy->clID(), link_clid);
89 
90  // Transient clid was null.
91  // This can happen when reading a view vector with xAODRootAccess
92  // in an athena build, where the TAD may not get a CLID set.
93  // Check based on key.
94  if (sg) {
95  sgkey_t link_sgkey = sg->stringToKey (m_proxy->name(), link_clid);
96  if (link_sgkey != m_proxy->sgkey())
97  throw SG::ExcCLIDMismatch (m_proxy->clID(), link_clid);
98  }
99  }
100  }
101  }
102  return key;
103 }

◆ toTransient() [1/2]

DataProxyHolder::sgkey_t SG::DataProxyHolder::toTransient ( const ID_type dataID,
CLID  link_clid,
IProxyDict sg = 0 
)

Finish initialization after link has been read.

Parameters
dataIDKey of the object.
link_clidCLID of the link being set.
sgAssociated store.
Returns
The hashed SG key for this object.

This should be called after a link has been read by root in order to set the proxy pointer. It calls toIdentifiedObject with the provided hashed key.

If sg is 0, then we use the global default store.

Definition at line 361 of file DataProxyHolder.cxx.

364 {
365  // Find the store to use.
366  if (sg == 0)
367  sg = this->source1();
368  if (sg == 0)
370 
371  sgkey_t sgkey = sg->stringToKey (dataID, link_clid);
372  toTransient (sgkey, sg);
373  return sgkey;
374 }

◆ toTransient() [2/2]

void SG::DataProxyHolder::toTransient ( sgkey_t  sgkey,
IProxyDict sg = 0 
)

Finish initialization after link has been read.

Parameters
sgkeyHashed SG key.
sgAssociated store.

This should be called after a link has been read by root in order to set the proxy pointer. It calls toIdentifiedObject with the provided hashed key.

If sg is 0, then we use the global default store.

Definition at line 324 of file DataProxyHolder.cxx.

325 {
326  m_proxy = 0;
327 
328  // Find the store to use.
329  if (sg == 0)
330  sg = this->source1();
331  if (sg == 0)
333 
334  // Do input renaming.
335  if (s_inputRenameMap) {
336  Athena::RCURead<InputRenameMap_t> r (*s_inputRenameMap);
337  auto it = r->find (sgkey);
338  if (it != r->end())
339  sgkey = it->second.m_sgkey;
340  }
341 
342  if (sgkey)
343  toIdentifiedObject (sgkey, CLID_NULL, sg);
344 }

◆ tryRemap()

bool SG::DataProxyHolder::tryRemap ( sgkey_t sgkey,
size_t &  index 
)
private

Test to see if the link has been remapped.

Parameters
sgkeyReference to the hashed SG key.
indexIndex of this link.

If this link has been remapped, sgkey and index will be adjusted accordingly.

Returns true if the link was remapped, false otherwise.

Definition at line 473 of file DataProxyHolder.cxx.

474 {
475  if (sgkey) {
476  // Check for remapping.
477  sgkey_t sgkey_out;
478  size_t index_out = 0;
479  IProxyDict* sg = this->source();
480  if (sg && sg->tryELRemap (sgkey, index, sgkey_out, index_out)) {
481  this->toIdentifiedObject (sgkey_out, CLID_NULL, this->source());
482  sgkey = sgkey_out;
483  index = index_out;
484  return true;
485  }
486  }
487 
488  return false;
489 }

Member Data Documentation

◆ m_proxy

SG::DataProxy* SG::DataProxyHolder::m_proxy
private

The DataProxy referring to our object, if the LSB is clear; pointer to the object which we're referencing directly if the LSB is set.

Definition at line 453 of file DataProxyHolder.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
common.sgkey
def sgkey(tool)
Definition: common.py:1028
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
SG::DataProxyHolder::storeObjpointer
void storeObjpointer(const_pointer_t p)
Store a direct pointer to an object.
SG::DataProxyHolder::objpointer
pointer_t objpointer() const
Return a pointer to the object we're pointing at directly.
IProxyDict::proxy
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::DataProxy::isConst
bool isConst() const
Check if it is a const object.
SG::DataProxy::sgkey
sgkey_t sgkey() const
< Get the primary (hashed) SG key.
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.
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
IProxyDict::addToStore
virtual StatusCode addToStore(CLID id, SG::DataProxy *proxy)=0
Add a new proxy to the store.
SG::ThinningDecisionBase
Hold thinning decisions for one container.
Definition: ThinningDecisionBase.h:39
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SG::ExcPointerNotInSG
Exception — The object referenced by a DataLink / ElementLink is not registered in SG.
Definition: Control/AthLinks/AthLinks/exceptions.h:37
SG::TransientAddress
Definition: TransientAddress.h:32
SG::CurrentEventStore::store
static IProxyDict * store()
Fetch the current store.
SG::DataProxyHolder::isObjpointer
bool isObjpointer() const
Test to see if we're pointing directly at an object.
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
SG::ExcConstStorable
Exception – Tried to retrieve const storable as a non-const pointer.
Definition: Control/AthLinks/AthLinks/exceptions.h:272
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::DataProxyHolder::toTransient
void toTransient(sgkey_t sgkey, IProxyDict *sg=0)
Finish initialization after link has been read.
Definition: DataProxyHolder.cxx:324
IProxyDict::proxy_exact
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const =0
Get proxy given a hashed key+clid.
SG::DataProxyHolder::toPersistentNoRemap
void toPersistentNoRemap(sgkey_t &sgkey)
Prepare this link for writing.
Definition: DataProxyHolder.cxx:392
IProxyDict::tryELRemap
virtual bool tryELRemap(sgkey_t sgkey_in, size_t index_in, sgkey_t &sgkey_out, size_t &index_out)
Test to see if the target of an ElementLink has moved.
Definition: IProxyDict.cxx:48
Athena::RCURead
Helper to read data from a RCUObject.
Definition: RCUObject.h:136
DataProxy
DataProxy provides the registry services for StoreGate.
Definition: DataProxy.h:31
python.xAODType.dummy
dummy
Definition: xAODType.py:4
SG::DataProxy::store
IProxyDict * store()
Return the store of which we're a part.
SG::ThinningDecisionBase::RemovedIdx
static const std::size_t RemovedIdx
Flag used to show that an index has been thinned away.
Definition: ThinningDecisionBase.h:42
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::DataProxy::clID
CLID clID() const
Retrieve clid.
SG::DataProxyHolder::toIdentifiedObject
sgkey_t toIdentifiedObject(const ID_type &dataID, CLID link_clid, IProxyDict *sg)
Set the link to an object given by a string key.
Definition: DataProxyHolder.cxx:123
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
SG::DataProxyHolder::source
IProxyDict * source() const
Return the data source for this reference.
Definition: DataProxyHolder.cxx:303
SG::DataProxy::name
virtual const name_type & name() const override final
Retrieve data object key == string.
SG::ExcCLIDMismatch
Exception — Attempt to set DataLink / ElementLink with CLID <clid> to object with CLID <clid>.
Definition: Control/AthLinks/AthLinks/exceptions.h:59
SG::DataProxyHolder::tryRemap
bool tryRemap(sgkey_t &sgkey, size_t &index)
Test to see if the link has been remapped.
Definition: DataProxyHolder.cxx:473
SG::ThinningDecisionBase::index
size_t index(size_t ndxOrig) const
Return the index corresponding to ndxOrig after thinning.
DeMoScan.index
string index
Definition: DeMoScan.py:364
SG::ThinningCache::thinning
const ThinningDecisionBase * thinning(const std::string &key) const
Return thinning for key.
Definition: ThinningCache.cxx:36
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::DataProxyHolder::const_pointer_t
const void * const_pointer_t
Definition: DataProxyHolder.h:71
SG::DataProxy::transientID
bool transientID(CLID id) const
return the list of transient IDs (primary or symLinked):
SG::DataProxyHolder::source1
IProxyDict * source1()
Return the data source for this reference.
IStringPool::keyToString
virtual const std::string * keyToString(sgkey_t key) const =0
Find the string corresponding to a given key.
SG::TransientAddress::setSGKey
void setSGKey(sgkey_t sgkey)
check if it is a transient ID (primary or symLinked):
Definition: TransientAddress.h:229
SG::DataProxyHolder::sgkey_t
IStringPool::sgkey_t sgkey_t
Type of hashed keys.
Definition: DataProxyHolder.h:64
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
SG::DataProxyHolder::dataID
const ID_type & dataID() const
Return the SG key that we reference, as a string.
Definition: DataProxyHolder.cxx:227
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::DataProxy
Definition: DataProxy.h:44
SG::DataProxyHolder::proxy
SG::DataProxy * proxy(bool nothrow=false) const
Return the DataProxy for this link.
SG::DataProxyHolder::m_proxy
SG::DataProxy * m_proxy
The DataProxy referring to our object, if the LSB is clear; pointer to the object which we're referen...
Definition: DataProxyHolder.h:453
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37