ATLAS Offline Software
Loading...
Searching...
No Matches
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.
using ID_type = std::string
 Type of string keys.
using pointer_t = void*
 Generic pointer type.
using const_pointer_t = const void*
typedef void * castfn_t(SG::DataProxy *)
 Function casting from a SG::DataProxy to a pointer.

Public Member Functions

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

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.
static void resetCachedSource ()

Private Member Functions

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

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.

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 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}
SG::DataProxy * proxy(bool nothrow=false) const
Return the DataProxy for this link.

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

585{
586 if (m_proxy == other.m_proxy) return true;
587
588 // One could refer to an object directly by pointer, the other could
589 // have a proxy.
590
592 const DataProxy* proxy = 0;
593 if (isObjpointer() && !other.isObjpointer()) {
594 ptr = objpointer();
595 proxy = other.m_proxy;
596 }
597 else if (other.isObjpointer() && !isObjpointer()) {
598 ptr = other.objpointer();
599 proxy = m_proxy;
600 }
601 else
602 return false;
603
604 if (proxy->store()->proxy(ptr) == proxy)
605 return true;
606
607 return false;
608}
SG::DataProxy * m_proxy
The DataProxy referring to our object, if the LSB is clear; pointer to the object which we're referen...
bool isObjpointer() const
Test to see if we're pointing directly at an object.
pointer_t objpointer() const
Return a pointer to the object we're pointing at directly.
const void * const_pointer_t
void * ptr(T *p)
Definition SGImplSvc.cxx:74

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

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

◆ resetCachedSource()

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.

Definition at line 628 of file DataProxyHolder.cxx.

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

◆ 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()) {
264 throw SG::ExcConstStorable (m_proxy->clID(),
265 m_proxy->name(),
266 m_proxy->sgkey());
267 }
268
269 // Ok --- DataProxy is thread-safe.
270 SG::DataProxy* proxy_nc ATLAS_THREAD_SAFE = m_proxy;
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}
#define ATLAS_THREAD_SAFE
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies

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

507{
508 if (!sgkey) {
509 return false;
510 }
511
512 // Check for thinning.
513 if (thinningCache) {
514 const SG::ThinningDecisionBase* dec = thinningCache->thinning (sgkey);
515 if (dec) {
516 // Get the updated index:
517 const std::size_t persIdx = dec->index( index );
518
519 // If the object was thinned away, set the persistent variables to an
520 // invalid state. Otherwise update just the index variable.
521 if( persIdx == ThinningDecisionBase::RemovedIdx ) {
522 sgkey = 0;
523 index = 0;
524 return true;
525 }
526 else {
527 if (index != persIdx) {
528 index = persIdx;
529 return true;
530 }
531 }
532 }
533 }
534
535 return false;
536}
const ThinningDecisionBase * thinning(const std::string &key) const
Return thinning for key.
static const std::size_t RemovedIdx
Flag used to show that an index has been thinned away.
size_t index(size_t ndxOrig) const
Return the index corresponding to ndxOrig after thinning.
size_t index() const
Return the index of this element within its container.
sgkey(tool)
Definition common.py:1027

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

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

◆ 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)
131 sg = SG::CurrentEventStore::store();
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}
virtual StatusCode addToStore(CLID id, SG::DataProxy *proxy)=0
Add a new proxy to the store.
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
virtual sgkey_t stringToKey(const std::string &str, CLID clid)=0
Find the key for a string/CLID pair.
IProxyDict * source1()
Return the data source for this reference.
const ID_type & dataID() const
Return the SG key that we reference, as a string.

◆ 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)
179 sg = SG::CurrentEventStore::store();
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.
202 SG::TransientAddress tad;
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}
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const =0
Get proxy given a hashed key+clid.
virtual const std::string * keyToString(sgkey_t key) const =0
Find the string corresponding to a given key.
void setSGKey(sgkey_t sgkey)
check if it is a transient ID (primary or symLinked):

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

454{
455 toPersistentNoRemap (sgkey);
456 size_t index_s = index;
457 bool ret = tryRemap (sgkey, index_s);
458 if (ret)
459 index = static_cast<uint32_t>(index_s);
460 return ret;
461}
void toPersistentNoRemap(sgkey_t &sgkey)
Prepare this link for writing.
bool tryRemap(sgkey_t &sgkey, size_t &index)
Test to see if the link has been remapped.
setEventNumber uint32_t

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

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

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

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

◆ 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)
72 sg = SG::CurrentEventStore::store();
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.
80 storeObjpointer (obj);
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}
SG::sgkey_t sgkey_t
Type of hashed keys.
void storeObjpointer(const_pointer_t p)
Store a direct pointer to an object.

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

365{
366 // Find the store to use.
367 if (sg == 0)
368 sg = this->source1();
369 if (sg == 0)
370 sg = SG::CurrentEventStore::store();
371
372 sgkey_t sgkey = sg->stringToKey (dataID, link_clid);
373 toTransient (sgkey, sg);
374 return sgkey;
375}
void toTransient(sgkey_t sgkey, IProxyDict *sg=0)
Finish initialization after link has been read.

◆ 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)
332 sg = SG::CurrentEventStore::store();
333
334 // Do input renaming.
335 if (s_inputRenameMap) {
337 Athena::RCURead<InputRenameMap_t> r (*s_inputRenameMap);
338 auto it = r->find (sgkey);
339 if (it != r->end())
340 sgkey = it->second.m_sgkey;
341 }
342
343 if (sgkey)
344 toIdentifiedObject (sgkey, CLID_NULL, sg);
345}
sgkey_t toIdentifiedObject(const ID_type &dataID, CLID link_clid, IProxyDict *sg)
Set the link to an object given by a string key.
int r
Definition globals.cxx:22
SG::SGKeyMap< InputRenameEntry > InputRenameMap_t

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

475{
476 if (sgkey) {
477 // Check for remapping.
478 sgkey_t sgkey_out;
479 size_t index_out = 0;
480 IProxyDict* sg = this->source();
481 if (sg && sg->tryELRemap (sgkey, index, sgkey_out, index_out)) {
482 this->toIdentifiedObject (sgkey_out, CLID_NULL, this->source());
483 sgkey = sgkey_out;
484 index = index_out;
485 return true;
486 }
487 }
488
489 return false;
490}
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.
IProxyDict * source() const
Return the data source for this reference.

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: