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

using sgkey_t = SG::sgkey_t
 Type of hashed keys. More...
 
using ID_type = std::string
 Type of string keys. More...
 
using pointer_t = void *
 Generic pointer type. More...
 
using const_pointer_t = const void *
 
typedef void * castfn_t(SG::DataProxy *)
 Function casting from a SG::DataProxy to a pointer. More...
 

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 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 61 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 75 of file DataProxyHolder.h.

◆ const_pointer_t

Definition at line 72 of file DataProxyHolder.h.

◆ ID_type

using SG::DataProxyHolder::ID_type = std::string

Type of string keys.

Definition at line 68 of file DataProxyHolder.h.

◆ pointer_t

Generic pointer type.

Definition at line 71 of file DataProxyHolder.h.

◆ sgkey_t

Type of hashed keys.

Definition at line 65 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

◆ 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 229 of file DataProxyHolder.cxx.

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

◆ 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 586 of file DataProxyHolder.cxx.

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

◆ 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 571 of file DataProxyHolder.cxx.

572 {
573  const_pointer_t obj = reinterpret_cast<const_pointer_t>
574  (reinterpret_cast<unsigned long> (m_proxy) & ~1UL);
576  if (proxy == 0 && !nothrow)
577  throw SG::ExcPointerNotInSG (obj);
578  return proxy;
579 }

◆ 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 305 of file DataProxyHolder.cxx.

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

◆ 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.

Definition at line 630 of file DataProxyHolder.cxx.

631 {
632  if (!m_proxy || isObjpointer()) {
633  return 0;
634  }
635  return m_proxy->store();
636 }

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

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

◆ 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 507 of file DataProxyHolder.cxx.

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

◆ 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 547 of file DataProxyHolder.cxx.

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

◆ 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 125 of file DataProxyHolder.cxx.

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

◆ 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 171 of file DataProxyHolder.cxx.

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

◆ 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 455 of file DataProxyHolder.cxx.

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

◆ 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 424 of file DataProxyHolder.cxx.

425 {
427  size_t index_s = index;
428  bool ret = tryRemap (sgkey, index_s);
429  if (ret)
430  index = index_s;
431  return ret;
432 }

◆ 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 395 of file DataProxyHolder.cxx.

396 {
397  if (!sgkey && m_proxy) {
398  m_proxy = proxy(); // May throw.
399  sgkey = m_proxy->sgkey();
400  }
401 }

◆ 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 60 of file DataProxyHolder.cxx.

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

◆ 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 364 of file DataProxyHolder.cxx.

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

◆ 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 326 of file DataProxyHolder.cxx.

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

◆ 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 476 of file DataProxyHolder.cxx.

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

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 443 of file DataProxyHolder.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
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:401
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::sgkey_t
SG::sgkey_t sgkey_t
Type of hashed keys.
Definition: DataProxyHolder.h:65
SG::DataProxyHolder::toTransient
void toTransient(sgkey_t sgkey, IProxyDict *sg=0)
Finish initialization after link has been read.
Definition: DataProxyHolder.cxx:326
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:395
Athena::InputRenameMap_t
SG::SGKeyMap< InputRenameEntry > InputRenameMap_t
Definition: InputRenameMap.h:32
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:32
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::source1
IProxyDict * source1()
Return the data source for this reference.
Definition: DataProxyHolder.cxx:630
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:125
SG::DataProxyHolder::source
IProxyDict * source() const
Return the data source for this reference.
Definition: DataProxyHolder.cxx:305
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:476
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::DataProxy::transientID
bool transientID(CLID id) const
return the list of transient IDs (primary or symLinked):
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::const_pointer_t
const void * const_pointer_t
Definition: DataProxyHolder.h:72
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:229
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::DataProxy
Definition: DataProxy.h:45
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:443
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37