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
DataProxyHolder & operator= (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_type & dataID () 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::DataProxy * proxy (bool nothrow=false) const
 Return the DataProxy for this link.
IProxyDict * source () const
 Return the data source for this reference.
void toTransient (sgkey_t sgkey, IProxyDict *sg=nullptr, bool noDummy=false)
 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::DataProxy * proxy1 (bool nothrow) const
 Helper for proxy(), for the case of a direct object pointer.
IProxyDict * source1 ()
 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::DataProxy * m_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 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

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

Type of string keys.

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

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

595{
596 if (m_proxy == other.m_proxy) return true;
597
598 // One could refer to an object directly by pointer, the other could
599 // have a proxy.
600
602 const DataProxy* proxy = 0;
603 if (isObjpointer() && !other.isObjpointer()) {
604 ptr = objpointer();
605 proxy = other.m_proxy;
606 }
607 else if (other.isObjpointer() && !isObjpointer()) {
608 ptr = other.objpointer();
609 proxy = m_proxy;
610 }
611 else
612 return false;
613
614 if (proxy->store()->proxy(ptr) == proxy)
615 return true;
616
617 return false;
618}
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:76

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

580{
581 const_pointer_t obj = reinterpret_cast<const_pointer_t>
582 (reinterpret_cast<unsigned long> (m_proxy) & ~1UL);
583 SG::DataProxy* proxy = SG::CurrentEventStore::store()->proxy (obj);
584 if (proxy == 0 && !nothrow)
585 throw SG::ExcPointerNotInSG (obj);
586 return proxy;
587}

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

639{
640 if (!m_proxy || isObjpointer()) {
641 return 0;
642 }
643 return m_proxy->store();
644}

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

517{
518 if (!sgkey) {
519 return false;
520 }
521
522 // Check for thinning.
523 if (thinningCache) {
524 const SG::ThinningDecisionBase* dec = thinningCache->thinning (sgkey);
525 if (dec) {
526 // Get the updated index:
527 const std::size_t persIdx = dec->index( index );
528
529 // If the object was thinned away, set the persistent variables to an
530 // invalid state. Otherwise update just the index variable.
531 if( persIdx == ThinningDecisionBase::RemovedIdx ) {
532 sgkey = 0;
533 index = 0;
534 return true;
535 }
536 else {
537 if (index != persIdx) {
538 index = persIdx;
539 return true;
540 }
541 }
542 }
543 }
544
545 return false;
546}
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 555 of file DataProxyHolder.cxx.

556{
557 CLID clid = CLID_NULL;
558 std::string key;
559 SG::DataProxy* dp = proxy();
560 if (dp) {
561 clid = dp->clID();
562 key = dp->name();
563 }
564 throw SG::ExcInvalidLink (clid, key, sgkey);
565}
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 463 of file DataProxyHolder.cxx.

464{
465 toPersistentNoRemap (sgkey);
466 size_t index_s = index;
467 bool ret = tryRemap (sgkey, index_s);
468 if (ret)
469 index = static_cast<uint32_t>(index_s);
470 return ret;
471}
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 432 of file DataProxyHolder.cxx.

433{
434 toPersistentNoRemap (sgkey);
435 size_t index_s = index;
436 bool ret = tryRemap (sgkey, index_s);
437 if (ret)
438 index = index_s;
439 return ret;
440}

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

404{
405 if (!sgkey && m_proxy) {
406 m_proxy = proxy(); // May throw.
407 sgkey = m_proxy->sgkey();
408 }
409}

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

375{
376 // Find the store to use.
377 if (sg == 0)
378 sg = this->source1();
379 if (sg == 0)
380 sg = SG::CurrentEventStore::store();
381
382 sgkey_t sgkey = sg->stringToKey (dataID, link_clid);
383 toTransient (sgkey, sg);
384 return sgkey;
385}
void toTransient(sgkey_t sgkey, IProxyDict *sg=nullptr, bool noDummy=false)
Finish initialization after link has been read.

◆ toTransient() [2/2]

void SG::DataProxyHolder::toTransient ( sgkey_t sgkey,
IProxyDict * sg = nullptr,
bool noDummy = false )

Finish initialization after link has been read.

Parameters
sgkeyHashed SG key.
sgAssociated store.
noDummyIf true, then if we don't find a proxy, just leave the link null rather than making a dummy.

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 nullptr, then we use the global default store.

Definition at line 326 of file DataProxyHolder.cxx.

329{
330 m_proxy = nullptr;
331
332 // Find the store to use.
333 if (sg == nullptr)
334 sg = this->source1();
335 if (sg == nullptr)
336 sg = SG::CurrentEventStore::store();
337
338 // Do input renaming.
339 if (s_inputRenameMap) {
341 Athena::RCURead<InputRenameMap_t> r (*s_inputRenameMap);
342 auto it = r->find (sgkey);
343 if (it != r->end())
344 sgkey = it->second.m_sgkey;
345 }
346
347 if (sgkey) {
348 if (noDummy) {
349 m_proxy = sg->proxy_exact (sgkey);
350 }
351 else {
352 toIdentifiedObject (sgkey, CLID_NULL, sg);
353 }
354 }
355}
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 484 of file DataProxyHolder.cxx.

485{
486 if (sgkey) {
487 // Check for remapping.
488 sgkey_t sgkey_out;
489 size_t index_out = 0;
490 IProxyDict* sg = this->source();
491 if (sg && sg->tryELRemap (sgkey, index, sgkey_out, index_out)) {
492 this->toIdentifiedObject (sgkey_out, CLID_NULL, this->source());
493 sgkey = sgkey_out;
494 index = index_out;
495 return true;
496 }
497 }
498
499 return false;
500}
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 446 of file DataProxyHolder.h.


The documentation for this class was generated from the following files: