Generic base class for ElementLinks.
More...
#include <DataLinkBase.h>
Inherited by ElementLink< STORABLE >, ElementLink< Analysis::MuonContainer >, ElementLink< AthExParticles >, ElementLink< CaloCellContainer >, ElementLink< CaloCellLinkContainer >, ElementLink< CaloClusterCellLinkContainer >, ElementLink< CaloClusterContainer >, ElementLink< CaloRingsContainer >, ElementLink< CaloShowerContainer >, ElementLink< CONT >, ElementLink< CONTAINER >, ElementLink< Container >, ElementLink< DataVector >, ElementLink< DataVector< Muon::MuonPatternCombination > >, ElementLink< DataVector< Trk::Track > >, ElementLink< DOBJ >, ElementLink< egammaContainer >, ElementLink< ElectronContainer >, ElementLink< EMShowerMinimalContainer >, ElementLink< ExampleHitContainer >, ElementLink< INavigable4MomentumCollection >, ElementLink< InDet::PixelClusterContainer >, ElementLink< InDet::SCT_ClusterContainer >, ElementLink< InDet::TRT_DriftCircleContainer >, ElementLink< IParticleContainer >, ElementLink< JetCollection >, ElementLink< MasterContainer_t >, ElementLink< McEventCollection >, ElementLink< Muon::CscPrepDataContainer >, ElementLink< Muon::MdtPrepDataContainer >, ElementLink< Muon::MMPrepDataContainer >, ElementLink< Muon::RpcPrepDataContainer >, ElementLink< Muon::sTgcPrepDataContainer >, ElementLink< Muon::TgcPrepDataContainer >, ElementLink< MuonCaloEnergyContainer >, ElementLink< MuonFeatureContainer >, ElementLink< MVFVxContainer >, ElementLink< PhotonContainer >, ElementLink< Rec::MuonSpShowerContainer >, ElementLink< Rec::TrackParticleContainer >, ElementLink< RingerRingsContainer >, ElementLink< std::vector< SGTutorial::MyElement > >, ElementLink< T >, ElementLink< TBADCRawCont >, ElementLink< TBTDCRawCont >, ElementLink< TileMuFeatureContainer >, ElementLink< TrackCollection >, ElementLink< TrackParticleBaseCollection >, ElementLink< TrigEFBphysContainer >, ElementLink< TrigEMClusterContainer >, ElementLink< TrigInDetTrackCollection >, ElementLink< TrigL2BphysContainer >, ElementLink< TrigMuonEFInfoContainer >, ElementLink< TrigRoiDescriptorCollection >, ElementLink< TrigTauClusterDetailsContainer >, ElementLink< Trk::PrepRawDataContainer >, ElementLink< TruthEtIsolationsContainer >, ElementLink< TruthParticleContainer >, ElementLink< V0Container >, ElementLink< VxContainer >, ElementLink< xAOD::IParticleContainer >, ElementLink< xAOD::MissingETContainer_v1 >, ElementLink< xAOD::NeutralParticleContainer >, and ElementLink< xAOD::TrackParticleContainer >.
|
| GenericElementLinkBase () |
| Default constructor. More...
|
|
| GenericElementLinkBase (const ID_type &dataID, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Construct a link from a string key and an index. More...
|
|
| GenericElementLinkBase (sgkey_t key, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Construct a link from a hashed key and an index. More...
|
|
| GenericElementLinkBase (const ID_type &dataID, CLID link_clid, const index_type &elemID, const ElementType &elt, IProxyDict *sg) |
| Construct a link from a string key, index, AND pointer to element. More...
|
|
| GenericElementLinkBase (sgkey_t key, CLID link_clid, const index_type &elemID, const ElementType &elt, IProxyDict *sg) |
| Construct a link from a hashed key, index, AND pointer to element. More...
|
|
| GenericElementLinkBase (const_pointer_t obj, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Construct a link from an index and pointer to the container. More...
|
|
| GenericElementLinkBase (const GenericElementLinkBase &other, const index_type &elemID) |
| Construct a link from another link, changing the index. More...
|
|
| GenericElementLinkBase (const DataLinkBase &dlink, const index_type &index) |
| Construct a link from a DataLink and an index. More...
|
|
template<class OTHER_INDEXING_POLICY , class FROM_TRAITS , class TO_TRAITS > |
| GenericElementLinkBase (const GenericElementLinkBase< OTHER_INDEXING_POLICY > &other, FROM_TRAITS *, TO_TRAITS *) |
| Constructor from a link referencing a different type. More...
|
|
| GenericElementLinkBase (const GenericElementLinkBase &)=default |
|
GenericElementLinkBase & | operator= (const GenericElementLinkBase &)=default |
|
void * | storableBase (castfn_t *castfn, const CLID &clid, bool isConst) const |
| Return a pointer to the currently-referenced container object. More...
|
|
bool | setStorableObject (const_pointer_t data, CLID link_clid, bool replace, IProxyDict *sg) |
| Set the container referenced by the link to data . More...
|
|
bool | toIndexedElement (const_pointer_t obj, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Set the to an element given by index and pointer to container. More...
|
|
void | resetWithKeyAndIndex (const ID_type &dataID, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Set the link to an element given by string key and index. More...
|
|
void | resetWithKeyAndIndex (sgkey_t key, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Set the link to an element given by string key and index. More...
|
|
void | setIndex (const index_type &index) |
| Set the index part of the link. More...
|
|
const stored_index_type & | storedIndex () const |
| Return the stored representation of the link index. More...
|
|
void | setCachedElement (const ElementType &elt) const |
| Set the cached element stored in the link. More...
|
|
void | storeCachedElement (const ElementType &elt) |
| Set the cached element stored in the link. More...
|
|
bool | getCachedElement (ElementConstPointer &elt) const |
| Retrieve the cached element from the link. More...
|
|
const SG::DataProxyHolder & | proxyHolder () const |
| Return the internal proxy holder object. More...
|
|
|
template<class INDEX > |
| requires (std::convertible_to< INDEX, size_t > &&std::convertible_to< size_t, INDEX >) bool thin1(INDEX &persIndex |
| Adjust for thinning. More...
|
|
template<class INDEX > |
| requires (!(std::convertible_to< INDEX, size_t > &&std::convertible_to< size_t, INDEX >)) bool thin1(INDEX &persIndex |
| Adjust for thinning. More...
|
|
template<class INDEXING_POLICY>
struct SG::GenericElementLinkBase< INDEXING_POLICY >
Generic base class for ElementLinks.
The part of ElementLink
that doesn't directly depend on the particular container class is factored out here. We do, however, need to know both the index and element types. We get these from the indexing policy (so we do have an indirect dependence on the container type).
This class holds all the state of the ElementLink
. The persistent part is the hashed SG key of the container and the index of the element within the container. We also store a transient DataProxyHolder
, which encapsulates the pointer to the DataProxy
and factors out code shared with DataLink
. Further, we store a (transient and mutable) copy of the element to which this link refers, as well as a flag to tell if the cached element is valid.
The main reason for breaking out the base class like this is that for the common case where the container has vector-like indexing and the element is a pointer type we actually use the non-templated class ElementLinkBase
instead of this one. ElementLinkBase
is essentially the same as this, but specialized for the case of the index being an unsigned int and the element being a pointer. This factorization makes direct ROOT persistency easier for this common case.
See ElementLinkTraits.h for a summary of the requirements for these base classes.
Definition at line 24 of file AthLinks/DataLinkBase.h.
◆ castfn_t
template<class INDEXING_POLICY >
◆ const_pointer_t
template<class INDEXING_POLICY >
◆ DictSel
template<class INDEXING_POLICY >
◆ ElementConstPointer
template<class INDEXING_POLICY >
◆ ElementType
template<class INDEXING_POLICY >
◆ ID_type
template<class INDEXING_POLICY >
◆ index_type
template<class INDEXING_POLICY >
◆ self
template<class INDEXING_POLICY >
◆ sgkey_t
template<class INDEXING_POLICY >
◆ stored_index_type
template<class INDEXING_POLICY >
◆ GenericElementLinkBase() [1/10]
template<class INDEXING_POLICY >
Default constructor.
Makes a null link.
◆ GenericElementLinkBase() [2/10]
template<class INDEXING_POLICY >
Construct a link from a string key and an index.
- Parameters
-
dataID | Key of the object. |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
sg | Associated store. |
If sg
is 0, we take the global default.
◆ GenericElementLinkBase() [3/10]
template<class INDEXING_POLICY >
Construct a link from a hashed key and an index.
- Parameters
-
key | Hashed key of the object. |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
sg | Associated store. |
If sg
is 0, we take the global default.
◆ GenericElementLinkBase() [4/10]
template<class INDEXING_POLICY >
Construct a link from a string key, index, AND pointer to element.
- Parameters
-
dataID | Key of the object. |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
elt | Pointer to the element. |
sg | Associated store. |
USE CAREFULLY: no coherency checks, we just trust you!
If sg
is 0, we take the global default.
◆ GenericElementLinkBase() [5/10]
template<class INDEXING_POLICY >
Construct a link from a hashed key, index, AND pointer to element.
- Parameters
-
key | Hashed key of the object. |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
elt | Pointer to the element. |
sg | Associated store. |
USE CAREFULLY: no coherency checks, we just trust you!
If sg
is 0, we take the global default.
◆ GenericElementLinkBase() [6/10]
template<class INDEXING_POLICY >
Construct a link from an index and pointer to the container.
- Parameters
-
obj | Pointer to the container (storable). |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
sg | Associated store. |
If sg
is 0, we take the global default.
◆ GenericElementLinkBase() [7/10]
template<class INDEXING_POLICY >
Construct a link from another link, changing the index.
- Parameters
-
other | The source link. |
elemID | The index for the new link. |
The index being constructed will reference the same container as other
, but it will refer to element elemID
.
◆ GenericElementLinkBase() [8/10]
template<class INDEXING_POLICY >
Construct a link from a DataLink and an index.
- Parameters
-
dlink | Link to the container. |
index | The index of the element within the container. |
◆ GenericElementLinkBase() [9/10]
template<class INDEXING_POLICY >
template<class OTHER_INDEXING_POLICY , class FROM_TRAITS , class TO_TRAITS >
Constructor from a link referencing a different type.
- Parameters
-
other | The object from which to copy. |
FROM_TRAITS
is the ElementLinkTraits
class for other
; TO_TRAITS
is the traits 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.
◆ GenericElementLinkBase() [10/10]
template<class INDEXING_POLICY >
◆ dataID()
template<class INDEXING_POLICY >
Return the SG key that we reference, as a string.
Returns a null string on failure.
◆ getCachedElement()
template<class INDEXING_POLICY >
Retrieve the cached element from the link.
- Parameters
-
elt[out] | The cached element. |
- Returns
- True if an element was cached; false otherwise.
elt
is left unmodified if there is no cached element.
◆ hasCachedElement()
template<class INDEXING_POLICY >
Test to see if this link has a cached element pointer.
◆ index()
template<class INDEXING_POLICY >
Return the index of the link.
◆ isDefault()
template<class INDEXING_POLICY >
Test to see if this link is in the default state.
◆ isDefaultIndex()
template<class INDEXING_POLICY >
Test the index validity.
- Returns
- True if the index is not valid (in default state).
◆ key()
template<class INDEXING_POLICY >
Return the SG key that we reference, as a hash.
Returns 0 on failure.
◆ operator=()
template<class INDEXING_POLICY >
◆ proxy()
template<class INDEXING_POLICY >
Return the SG proxy for the container holding this element.
If this is a null link, we return 0. If we're directly referencing an object that's not in StoreGate, either return 0 or throw ExcPointerNotInSG
, depending on nothrow
. Otherwise, return the proxy for the object we're referencing.
◆ proxyHolder()
template<class INDEXING_POLICY >
Return the internal proxy holder object.
◆ requires() [1/2]
template<class INDEXING_POLICY >
template<class INDEX >
SG::GenericElementLinkBase< INDEXING_POLICY >::requires |
( |
! |
std::convertible_to< INDEX, size_t > && std::convertible_to< size_t, INDEX > | ) |
& |
|
private |
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
- Parameters
-
Index | of the element. |
thinningCache | Thinning cache for the current stream (may be null). |
Returns true
if the link was changed; false
otherwise.
This overload will be used for the case where thinning is not supported.
◆ requires() [2/2]
template<class INDEXING_POLICY >
template<class INDEX >
SG::GenericElementLinkBase< INDEXING_POLICY >::requires |
( |
std::convertible_to< INDEX, size_t > &&std::convertible_to< size_t, INDEX > |
| ) |
& |
|
private |
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
- Parameters
-
Index | of the element. |
thinningCache | Thinning cache for the current stream (may be null). |
Returns true
if the link was changed; false
otherwise.
This overload will be used for the case where thinning is supported: the index can be interconverted with size_t.
◆ reset()
template<class INDEXING_POLICY >
Reset the link to a null state.
◆ resetWithKeyAndIndex() [1/2]
template<class INDEXING_POLICY >
Set the link to an element given by string key and index.
- Parameters
-
dataID | Key of the object. |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
sg | Associated 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.
◆ resetWithKeyAndIndex() [2/2]
template<class INDEXING_POLICY >
Set the link to an element given by string key and index.
- Parameters
-
key | Hashed key of the object. |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
sg | Associated 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.
◆ setCachedElement()
template<class INDEXING_POLICY >
Set the cached element stored in the link.
- Parameters
-
elt | New value for the cached element. |
◆ setIndex()
template<class INDEXING_POLICY >
Set the index part of the link.
- Parameters
-
◆ setStorableObject()
template<class INDEXING_POLICY >
Set the container referenced by the link to data
.
- Parameters
-
data | Pointer to the new container. |
link_clid | CLID of the link being set. |
replace | True if we can change an existing link. |
sg | Associated store. |
- Returns
- True if the link was changed.
If the link is already set, this will return false and leave the link unchanged unless replace
is set. The replace
argument should be set if the element is now in a new storable container; e.g. element ptr has been put in a new view container.
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.
◆ source()
template<class INDEXING_POLICY >
Return the data source for this reference.
◆ storableBase()
template<class INDEXING_POLICY >
Return a pointer to the currently-referenced container object.
- Parameters
-
castfn | Function to do the cast from data proxy to object. If 0, use a dynamic cast. |
clid | The CLID of the desired object. This is used to determine how the returned pointer is to be converted. |
isConst | True 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).
◆ storeCachedElement()
template<class INDEXING_POLICY >
Set the cached element stored in the link.
- Parameters
-
elt | New value for the cached element. |
◆ storedIndex()
template<class INDEXING_POLICY >
Return the stored representation of the link index.
◆ thin() [1/2]
template<class INDEXING_POLICY >
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
Returns true
if the link was changed; false
otherwise.
◆ thin() [2/2]
template<class INDEXING_POLICY >
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
- Parameters
-
thinningCache | Thinning cache for the current stream (may be null). |
Returns true
if the link was changed; false
otherwise.
◆ toIndexedElement()
template<class INDEXING_POLICY >
Set the to an element given by index and pointer to container.
- Parameters
-
obj | Pointer to the container (storable). |
link_clid | CLID of the link being set. |
elemID | The index of the element within the container. |
sg | Associated store. |
- Returns
- True if the link was changed.
If the link is already set, this will return false and leave the link unchanged.
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.
◆ toPersistent()
template<class INDEXING_POLICY >
Prepare this link for writing.
This method should be called before trying to write the link with root. It will make sure the persistent fields of the link are valid. It will also perform remapping if needed.
Will return true on success. Will return false if either the container or the element index has not been specified. Will throw ExcPointerNotInSG
if the link is referencing a container that is not in SG.
◆ toTransient()
template<class INDEXING_POLICY >
Finish initialization after link has been read.
- Parameters
-
This should be called after a link has been read by root in order to set the proxy pointer. Returns true.
If sg
is 0, then we use the global default store.
◆ ::ElementLinkBaseT_test
template<class INDEXING_POLICY >
template<class POLICY >
◆ GenericElementLinkBase
template<class INDEXING_POLICY >
template<class OTHER_POLICY >
◆ m_cacheValid
template<class INDEXING_POLICY >
◆ m_element [1/2]
template<class INDEXING_POLICY >
◆ m_element [2/2]
template<class INDEXING_POLICY >
◆ m_index
template<class INDEXING_POLICY >
◆ m_key
template<class INDEXING_POLICY >
◆ m_proxy [1/2]
template<class INDEXING_POLICY >
◆ m_proxy [2/2]
template<class INDEXING_POLICY >
◆ thinningCache
template<class INDEXING_POLICY >
The documentation for this struct was generated from the following files: