ATLAS Offline Software
Loading...
Searching...
No Matches
ElementLink< STORABLE > Class Template Reference

ElementLink implementation for ROOT usage. More...

#include <ElementLink.h>

Inheritance diagram for ElementLink< STORABLE >:
Collaboration diagram for ElementLink< STORABLE >:

Public Types

typedef uint32_t stored_index_type
 The type of the index as it is stored internally.
typedef void * castfn_t(SG::DataProxy *)
 Function casting from a SG::DataProxy to a pointer.
Type definitions taken from the StoreGate-based implementation
typedef std::string ID_type
 Type of the "regular" identifiers in the event.
typedef uint32_t sgkey_t
 Integer identifier for the object in the event.
typedef const STORABLE & BaseConstReference
 Constant reference to the container.
typedef const STORABLE * BaseConstPointer
 Constant pointer to the container.
typedef size_t index_type
 Type of the index used on the container.
typedef STORABLE::value_type value_type
 Type of the values inside the container.
typedef STORABLE::const_iterator const_iterator
 Constant iterator type for the container.
typedef TypeTools::Copy< value_type >::type ElementType
 Type of the elements in the container.
typedef TypeTools::Copy< value_type >::const_reference ElementConstReference
 Constant reference to an element in the container.
typedef TypeTools::Copy< value_type >::const_pointer ElementConstPointer
 Constant pointer to an element in the container.

Public Member Functions

ElementLinkoperator= (const ElementLink &rhs)
 Assignment operator.
xAOD::TVirtualEventsource () const
 Get the data source for the reference.
bool toPersistent ()
 Dummy function provinding the offline interface.
bool isDefaultIndex () const
 Test the index validity.
bool isDefault () const
 Test to see if this link is in the default state.
bool isDefault () const
 Is the link in the default state.
stored_index_type persIndex () const
 Return the index of the link.
uint32_t persIndex () const
 Get the index of the referenced object in the container.
sgkey_t persKey () const
 Return the SG key that we reference, as a hash.
uint32_t persKey () const
 Get the key/identifier of the referenced container.
const SG::DataProxyproxy () const
 Return the SG proxy for the container holding this element.
bool toTransient (IProxyDict *sg=0)
 Finish initialization after link has been read.
bool thin ()
 Adjust for thinning.
bool thin (const SG::ThinningCache *thinningCache)
 Adjust for thinning.
void setPersKey (uint32_t key)
 Set the key/identifier of the referenced container.
void setPersIndex (uint32_t index)
 Set the index of the referenced object in the container.
Constructors
 ElementLink ()
 Default constructor.
 ElementLink (xAOD::TVirtualEvent *event)
 Constructor setting up the link with a specific event object.
 ElementLink (const ID_type &key, index_type index, xAOD::TVirtualEvent *event=0)
 Construct object from storable key and element index (fast).
 ElementLink (sgkey_t id, index_type index, xAOD::TVirtualEvent *event=0)
 Construct object from storable id and element index (fastest).
 ElementLink (const ID_type &key, index_type index, ElementType element, xAOD::TVirtualEvent *event=0)
 Construct from a storable key and element index, taking the element object from the user.
 ElementLink (sgkey_t id, index_type index, ElementType element, xAOD::TVirtualEvent *event=0)
 Construct from a storable id and element index, taking the element object from the user.
 ElementLink (BaseConstReference container, index_type index, xAOD::TVirtualEvent *event=0)
 Construct from a container reference and element index (slower).
 ElementLink (ElementType element, BaseConstReference container, xAOD::TVirtualEvent *event=0)
 Construct from a container reference and element pointer (slowest).
 ElementLink (const ElementLink &parent)
 Copy-constructor.
Setter functions
bool toIndexedElement (BaseConstReference container, index_type index)
 Set link to point to given index (slower).
bool toContainedElement (BaseConstReference container, ElementType element)
 Set link to point to given element (slowest).
bool setElement (ElementType element)
 Set link to point to an Element (slowest).
bool setStorableObject (BaseConstReference data, bool replace=false)
 Set link storable to data object pointed by data (slower).
void resetWithKeyAndIndex (const ID_type &key, index_type index, xAOD::TVirtualEvent *event=0)
 Reset with storable key and element index (fast).
void resetWithKeyAndIndex (sgkey_t id, index_type index, xAOD::TVirtualEvent *event=0)
 Reset with storable id and element index (fastest).
void reset ()
 Reset to default state.
Accessor functions/operators
BaseConstPointer getStorableObjectPointer () const
 Retrieve storable object pointer.
BaseConstReference getStorableObjectRef () const
 Retrieve storable object reference.
index_type index () const
 Get the index of the element inside of its container.
const ID_typedataID () const
 Get the key that we reference, as a string.
sgkey_t key () const
 Get the key that we reference, as a hash.
bool operator== (const ElementLink &rhs) const
 Comparison operator.
bool operator!= (const ElementLink &rhs) const
 Comparison operator.
ElementConstReference operator* () const
 Get a reference to the object in question.
ElementConstPointer operator-> () const
 Access the object as a smart pointer.
 operator ElementConstPointer () const
 Auto-convert to the element type.
ElementConstPointer cptr () const
 Get a constant pointer to the referenced object.
bool isValid () const
 Check if the element can be found.
bool operator! () const
 Operator checking the validity of the link.
ElementType cachedElement () const
 Access the currently cached element. Doesn't trigger lookup.
bool hasCachedElement () const
 Check if the link has a cached element pointer.

Protected Member Functions

void * storableBase (castfn_t *castfn, CLID clid, bool isConst) const
 Return a pointer to the currently-referenced container object.
bool setStorableObject (const_pointer_t data, CLID link_clid, bool replace, IProxyDict *sg)
 Set the container referenced by the link to data.
bool toIndexedElement (const_pointer_t obj, CLID link_clid, index_type elemID, IProxyDict *sg)
 Set the link to an element given by index and pointer to container.
void resetWithKeyAndIndex (const ID_type &dataID, CLID link_clid, index_type elemID, IProxyDict *sg)
 Set the link to an element given by string key and index.
void resetWithKeyAndIndex (sgkey_t key, CLID link_clid, index_type elemID, IProxyDict *sg)
 Set the link to an element given by string key and index.
void setIndex (index_type index)
 Set the index part of the link.
const stored_index_typestoredIndex () const
 Return the stored representation of the link index.
void setCachedElement (ElementType elt) const
 Set the cached element stored in the link, assuming the cached element is null.
void storeCachedElement (ElementType elt)
 Set the cached element stored in the link.
template<class T>
bool getCachedElement (const T *&elt) const
 Retrieve the cached element from the link.
const SG::DataProxyHolderproxyHolder () const
 Return the internal proxy holder object.

Protected Attributes

uint32_t m_persKey
 Key/identifier of the referenced container.
uint32_t m_persIndex
 Index of the referenced object in the container.
bool m_isDirectIO
 A transient variable signalling when direct I/O is happening.

Private Types

typedef ROOT::Meta::Selection::ElementLink< STORABLE >::self DictSel
 Needed to take the Reflex/Cling specifications into account.
typedef SG::DataProxyHolder::const_pointer_t const_pointer_t
 Generic pointer to the container (storable).

Private Member Functions

virtual bool toTransient ()
 Reset the object's internal cache.
void findIdentifier ()
 Find the identifier of the object being pointed to.
void findIndex ()
 Find the index of an element inside the container.
void clearCachedElement ()
 Clear the currently-cached element.

Private Attributes

BaseConstPointer m_container
 Cached pointer to the container.
ElementType m_element
 Cached pointer to the object.
bool m_elementCached
 Status of the cached pointer.
xAOD::TVirtualEventm_event
 Pointer to the event object.
SG::sgkey_t m_persKey
 The hashed key for this link.
stored_index_type m_persIndex
 The index of the element within the container for this link.
SG::DataProxyHolder m_proxy
 SG proxy for this link.

Static Private Attributes

static const uint32_t INVALID = static_cast<uint32_t> (-1)
 Value to mark an invalid index.
static constexpr uint32_t INVALID = static_cast<uint32_t> (-1)
 Value to mark a default index.

Detailed Description

template<typename STORABLE>
class ElementLink< STORABLE >

ElementLink implementation for ROOT usage.

a persistable pointer to an element of a STORABLE (data object)

This class follows the interface of the offline implementation of ElementLink as closely as reasonably possible. Its functions are supposed to behave the same way as the functions of the offline ElementLink class.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Parameters
STORABLEhost object type (e,g. vector<Elem>, NOT Elem),

An ElementLink maintains a reference to a container that can be in StoreGate (a la DataLink) and an index within that container. This then identifies an element within the container.

The preferred way to initialize an ElementLink is with the StoreGate key and index. However, the link may also be initialized using the container directly instead of the key, or with the element directly. In the latter case, the reference to the container can be specified later. Be aware, though, that if you initialize the link from the element directly, without the index, the container will have to be searched if the index is needed, which could be slow. Also, if the index and StoreGate key are not available (for example, the container wasn't recorded in StoreGate), then the link will not be persistable.

The relationship between the container and the index is encapsulated by an `indexing policy' class. You normally don't need to worry about this, as the appropriate policy is automatically chosen for STL sequence types as well as for STL set and map types. However, it is possible to customize the policy used, if needed. See the macros in DeclareIndexingPolicy.h; the interface required of an indexing policy is summarized in tools/ElementLinkTraits.h.

Regardless of the indexing policy, all container types must support empty().

Forward declarations:

Dealing with forward declarations has been a problem. For example, you have a class MyCont which is a vector of pointers to MyElt, where MyElt contains an ElementLink<MyCont>. Here is a way to get this to work.

In your header for MyElt, make a forward declaration for MyCont. Then include the special macro ELEMENTLINK_FWD:

*

ELEMENTLINK_FWD(MyCont, MyElt);
#define ELEMENTLINK_FWD(TYPE, VALUE_TYPE)
Forward declaration helper for ElementLink.

where the first argument is the container type and the second argument is the base type of the (pointer) value type of the container. You can then write a data member of type ElementLink<MyCont>. You will need to have the complete definition of MyCont available in order to actaully call methods on the link, so you'll likely need to include the header for MyCont within the implementation file for MyElt. A more complete example of what the header for MyElt might look like:

*

#include "AthLinks/ElementLink.h"
class MyElt;
class MyCont;
ELEMENTLINK_FWD(MyCont, MyElt);
class MyElt { ...
};

Restrictions:

  • This only works for containers that are vector-like and which contain pointers (DataVector works.)
  • MyCont can't be a typedef. In most cases, MyCont will have to be a class that derives from the actual container class.
  • The ELEMENTLINK_FWD macro must be used in the global scope (outside of any namespace).
  • The complete definition of the container must be visible before calling any methods on the link. The container header can be included from the implementation file for the element; however, this implies that anything touching the link cannot be written as inline code in the element header.

Implementation notes:

Internally, we store a hashed SG key, a DataProxyHolder instance to encapsulate access to the DataProxy, the index, and a cached copy of the element to which we refer. These last two are in general of arbitrary type. However, the vast majority of EL instantiations refer to vectors of pointers; in that case, we can get away fixed types for these (an unsigned for the index and a void* for the cached element). Since it makes ROOT I/O easier if our state is in a non-templated class, we move all the state of ElementLink into a base class. The particular type of base class is chosen by ElementLinkTraits: the non-templated class ElementLinkBase is used for the vector of pointers case, while the templated GenericElementLinkBase class is used for the general case. */ template <class STORABLE> class ElementLink : public SG::ElementLinkTraits<STORABLE>::Base { private: / Traits class, from which to derive types. typedef SG::ElementLinkTraits<STORABLE> Traits;

/ Base class (factoring out code that doesn't directly depend on STORABLE). typedef typename Traits::Base Base;

/ Function casting from a SG::DataProxy to a pointer. typedef typename Base::castfn_t castfn_t;

public: / The indexing policy. typedef typename Traits::IndexingPolicy IndexingPolicy;

/ The index type presented to and returned from the link. typedef typename IndexingPolicy::index_type index_type;

/ Type of hashed keys. typedef typename Base::sgkey_t sgkey_t;

/ Type of string keys. typedef typename Base::ID_type ID_type;

/ Type of container (storable) and derived types. typedef STORABLE value_type; typedef STORABLE* pointer; typedef const STORABLE* const_pointer; typedef const STORABLE& BaseConstReference; typedef const STORABLE* BaseConstPointer;

/ Container element and derived types. typedef typename IndexingPolicy::ElementType ElementType; typedef typename IndexingPolicy::ElementConstReference ElementConstReference; typedef typename IndexingPolicy::ElementConstPointer ElementConstPointer;

/**

Return the CLID for the class that we reference.

Definition at line 39 of file A/AthLinks/ElementLink.h.

Member Typedef Documentation

◆ BaseConstPointer

template<typename STORABLE>
typedef const STORABLE* ElementLink< STORABLE >::BaseConstPointer

Constant pointer to the container.

Definition at line 53 of file A/AthLinks/ElementLink.h.

◆ BaseConstReference

template<typename STORABLE>
typedef const STORABLE& ElementLink< STORABLE >::BaseConstReference

Constant reference to the container.

Definition at line 51 of file A/AthLinks/ElementLink.h.

◆ castfn_t

typedef void * ElementLinkBase::castfn_t(SG::DataProxy *)
inherited

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

Definition at line 85 of file AthLinks/ElementLinkBase.h.

◆ const_iterator

template<typename STORABLE>
typedef STORABLE::const_iterator ElementLink< STORABLE >::const_iterator

Constant iterator type for the container.

Definition at line 61 of file A/AthLinks/ElementLink.h.

◆ const_pointer_t

Generic pointer to the container (storable).

Definition at line 68 of file AthLinks/ElementLinkBase.h.

◆ DictSel

template<typename STORABLE>
typedef ROOT::Meta::Selection::ElementLink<STORABLE>::self ElementLink< STORABLE >::DictSel
private

Needed to take the Reflex/Cling specifications into account.

Definition at line 207 of file A/AthLinks/ElementLink.h.

◆ ElementConstPointer

template<typename STORABLE>
typedef TypeTools::Copy<value_type>::const_pointer ElementLink< STORABLE >::ElementConstPointer

Constant pointer to an element in the container.

Definition at line 70 of file A/AthLinks/ElementLink.h.

◆ ElementConstReference

template<typename STORABLE>
typedef TypeTools::Copy<value_type>::const_reference ElementLink< STORABLE >::ElementConstReference

Constant reference to an element in the container.

Definition at line 67 of file A/AthLinks/ElementLink.h.

◆ ElementType

template<typename STORABLE>
typedef TypeTools::Copy<value_type>::type ElementLink< STORABLE >::ElementType

Type of the elements in the container.

Definition at line 64 of file A/AthLinks/ElementLink.h.

◆ ID_type

template<typename STORABLE>
typedef std::string ElementLink< STORABLE >::ID_type

Type of the "regular" identifiers in the event.

Definition at line 46 of file A/AthLinks/ElementLink.h.

◆ index_type

template<typename STORABLE>
typedef size_t ElementLink< STORABLE >::index_type

Type of the index used on the container.

Definition at line 56 of file A/AthLinks/ElementLink.h.

◆ sgkey_t

template<typename STORABLE>
typedef uint32_t ElementLink< STORABLE >::sgkey_t

Integer identifier for the object in the event.

Definition at line 48 of file A/AthLinks/ElementLink.h.

◆ stored_index_type

typedef uint32_t ElementLinkBase::stored_index_type
inherited

The type of the index as it is stored internally.

Definition at line 76 of file AthLinks/ElementLinkBase.h.

◆ value_type

template<typename STORABLE>
typedef STORABLE::value_type ElementLink< STORABLE >::value_type

Type of the values inside the container.

Definition at line 59 of file A/AthLinks/ElementLink.h.

Constructor & Destructor Documentation

◆ ElementLink() [1/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( )

Default constructor.

◆ ElementLink() [2/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( xAOD::TVirtualEvent * event)

Constructor setting up the link with a specific event object.

◆ ElementLink() [3/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( const ID_type & key,
index_type index,
xAOD::TVirtualEvent * event = 0 )

Construct object from storable key and element index (fast).

◆ ElementLink() [4/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( sgkey_t id,
index_type index,
xAOD::TVirtualEvent * event = 0 )

Construct object from storable id and element index (fastest).

◆ ElementLink() [5/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( const ID_type & key,
index_type index,
ElementType element,
xAOD::TVirtualEvent * event = 0 )

Construct from a storable key and element index, taking the element object from the user.

Be careful, no checks are done on the received object!

◆ ElementLink() [6/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( sgkey_t id,
index_type index,
ElementType element,
xAOD::TVirtualEvent * event = 0 )

Construct from a storable id and element index, taking the element object from the user.

Be careful, no checks are done on the received object!

◆ ElementLink() [7/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( BaseConstReference container,
index_type index,
xAOD::TVirtualEvent * event = 0 )

Construct from a container reference and element index (slower).

◆ ElementLink() [8/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( ElementType element,
BaseConstReference container,
xAOD::TVirtualEvent * event = 0 )

Construct from a container reference and element pointer (slowest).

◆ ElementLink() [9/9]

template<typename STORABLE>
ElementLink< STORABLE >::ElementLink ( const ElementLink< STORABLE > & parent)

Copy-constructor.

Member Function Documentation

◆ cachedElement()

template<typename STORABLE>
ElementType ElementLink< STORABLE >::cachedElement ( ) const
inline

Access the currently cached element. Doesn't trigger lookup.

Definition at line 176 of file A/AthLinks/ElementLink.h.

176{ return m_element; }

◆ clearCachedElement()

void ElementLinkBase::clearCachedElement ( )
privateinherited

Clear the currently-cached element.

◆ cptr()

template<typename STORABLE>
ElementConstPointer ElementLink< STORABLE >::cptr ( ) const

Get a constant pointer to the referenced object.

◆ dataID()

template<typename STORABLE>
const ID_type & ElementLink< STORABLE >::dataID ( ) const

Get the key that we reference, as a string.

◆ findIdentifier()

template<typename STORABLE>
void ElementLink< STORABLE >::findIdentifier ( )
private

Find the identifier of the object being pointed to.

◆ findIndex()

template<typename STORABLE>
void ElementLink< STORABLE >::findIndex ( )
private

Find the index of an element inside the container.

◆ getCachedElement()

template<class T>
bool ElementLinkBase::getCachedElement ( const T *& elt) const
protectedinherited

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.

◆ getStorableObjectPointer()

template<typename STORABLE>
BaseConstPointer ElementLink< STORABLE >::getStorableObjectPointer ( ) const

Retrieve storable object pointer.

◆ getStorableObjectRef()

template<typename STORABLE>
BaseConstReference ElementLink< STORABLE >::getStorableObjectRef ( ) const

Retrieve storable object reference.

◆ hasCachedElement()

template<typename STORABLE>
bool ElementLink< STORABLE >::hasCachedElement ( ) const
inline

Check if the link has a cached element pointer.

Definition at line 178 of file A/AthLinks/ElementLink.h.

178{ return m_elementCached; }

◆ index()

template<typename STORABLE>
index_type ElementLink< STORABLE >::index ( ) const
inline

Get the index of the element inside of its container.

Definition at line 148 of file A/AthLinks/ElementLink.h.

148{ return persIndex(); }
stored_index_type persIndex() const
Return the index of the link.

◆ isDefault() [1/2]

bool ElementLinkBase::isDefault ( ) const
inherited

Test to see if this link is in the default state.

Definition at line 49 of file ElementLinkBase.cxx.

49 {
51}
stored_index_type m_persIndex
The index of the element within the container for this link.
static const uint32_t INVALID
Value to mark an invalid index.

◆ isDefault() [2/2]

bool ElementLinkBase::isDefault ( ) const
inherited

Is the link in the default state.

A link in the default state was purposefully constructed as a null link

◆ isDefaultIndex()

bool ElementLinkBase::isDefaultIndex ( ) const
inherited

Test the index validity.

Returns
True if the index is not valid (in default state).

◆ isValid()

template<typename STORABLE>
bool ElementLink< STORABLE >::isValid ( ) const

Check if the element can be found.

◆ key()

template<typename STORABLE>
sgkey_t ElementLink< STORABLE >::key ( ) const
inline

Get the key that we reference, as a hash.

Definition at line 153 of file A/AthLinks/ElementLink.h.

153{ return persKey(); }
sgkey_t persKey() const
Return the SG key that we reference, as a hash.

◆ operator ElementConstPointer()

template<typename STORABLE>
ElementLink< STORABLE >::operator ElementConstPointer ( ) const
inline

Auto-convert to the element type.

Definition at line 166 of file A/AthLinks/ElementLink.h.

166{ return cptr(); }

◆ operator!()

template<typename STORABLE>
bool ElementLink< STORABLE >::operator! ( ) const
inline

Operator checking the validity of the link.

Definition at line 173 of file A/AthLinks/ElementLink.h.

173{ return ! isValid(); }

◆ operator!=()

template<typename STORABLE>
bool ElementLink< STORABLE >::operator!= ( const ElementLink< STORABLE > & rhs) const

Comparison operator.

◆ operator*()

template<typename STORABLE>
ElementConstReference ElementLink< STORABLE >::operator* ( ) const

Get a reference to the object in question.

◆ operator->()

template<typename STORABLE>
ElementConstPointer ElementLink< STORABLE >::operator-> ( ) const
inline

Access the object as a smart pointer.

Definition at line 164 of file A/AthLinks/ElementLink.h.

164{ return cptr(); }

◆ operator=()

template<typename STORABLE>
ElementLink & ElementLink< STORABLE >::operator= ( const ElementLink< STORABLE > & rhs)

Assignment operator.

◆ operator==()

template<typename STORABLE>
bool ElementLink< STORABLE >::operator== ( const ElementLink< STORABLE > & rhs) const

Comparison operator.

◆ persIndex() [1/2]

uint32_t ElementLinkBase::persIndex ( ) const
inherited

Return the index of the link.

(Deprecated; use index() instead.)

Definition at line 31 of file ElementLinkBase.cxx.

31 {
32
33 return m_persIndex;
34}

◆ persIndex() [2/2]

uint32_t ElementLinkBase::persIndex ( ) const
inherited

Get the index of the referenced object in the container.

◆ persKey() [1/2]

uint32_t ElementLinkBase::persKey ( ) const
inherited

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

(Deprecated; use key instead.)

Returns 0 on failure.

Definition at line 13 of file ElementLinkBase.cxx.

13 {
14
15 return m_persKey;
16}
SG::sgkey_t m_persKey
The hashed key for this link.

◆ persKey() [2/2]

uint32_t ElementLinkBase::persKey ( ) const
inherited

Get the key/identifier of the referenced container.

◆ proxy()

const SG::DataProxy * ElementLinkBase::proxy ( ) const
inherited

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()

const SG::DataProxyHolder & ElementLinkBase::proxyHolder ( ) const
protectedinherited

Return the internal proxy holder object.

◆ reset()

template<typename STORABLE>
void ElementLink< STORABLE >::reset ( )

Reset to default state.

◆ resetWithKeyAndIndex() [1/4]

template<typename STORABLE>
void ElementLink< STORABLE >::resetWithKeyAndIndex ( const ID_type & key,
index_type index,
xAOD::TVirtualEvent * event = 0 )

Reset with storable key and element index (fast).

◆ resetWithKeyAndIndex() [2/4]

template<typename STORABLE>
void ElementLink< STORABLE >::resetWithKeyAndIndex ( sgkey_t id,
index_type index,
xAOD::TVirtualEvent * event = 0 )

Reset with storable id and element index (fastest).

◆ resetWithKeyAndIndex() [3/4]

void ElementLinkBase::resetWithKeyAndIndex ( const ID_type & dataID,
CLID link_clid,
index_type elemID,
IProxyDict * sg )
protectedinherited

Set the link to an element given by string key and index.

Parameters
dataIDKey of the object.
link_clidCLID of the link being set.
elemIDThe index of the element within the container.
sgAssociated 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() [4/4]

void ElementLinkBase::resetWithKeyAndIndex ( sgkey_t key,
CLID link_clid,
index_type elemID,
IProxyDict * sg )
protectedinherited

Set the link to an element given by string key and index.

Parameters
keyHashed key of the object.
link_clidCLID of the link being set.
elemIDThe index of the element within the container.
sgAssociated 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()

void ElementLinkBase::setCachedElement ( ElementType elt) const
protectedinherited

Set the cached element stored in the link, assuming the cached element is null.

Parameters
eltNew value for the cached element.

This method will set the current cached element if it is currently unset. If it has previously been assigned, then this method will do nothing.

◆ setElement()

template<typename STORABLE>
bool ElementLink< STORABLE >::setElement ( ElementType element)

Set link to point to an Element (slowest).

◆ setIndex()

void ElementLinkBase::setIndex ( index_type index)
protectedinherited

Set the index part of the link.

Parameters
indexNew index value.

◆ setPersIndex()

void ElementLinkBase::setPersIndex ( uint32_t index)
inherited

Set the index of the referenced object in the container.

Definition at line 36 of file ElementLinkBase.cxx.

36 {
37
38 // Check if we're actually changing anything:
39 if( m_persIndex == index ) return;
40 // Store the new index:
42
43 // Reset the internal cache:
45
46 return;
47}
index_type index() const
Return the index of the link.
virtual bool toTransient()=0
Reset the object's internal cache.

◆ setPersKey()

void ElementLinkBase::setPersKey ( uint32_t key)
inherited

Set the key/identifier of the referenced container.

Definition at line 18 of file ElementLinkBase.cxx.

18 {
19
20 // Check if we're actually changing anything:
21 if( m_persKey == key ) return;
22 // Store the new key:
23 m_persKey = key;
24
25 // Reset the internal cache:
27
28 return;
29}
sgkey_t key() const
Return the SG key that we reference, as a hash.

◆ setStorableObject() [1/2]

template<typename STORABLE>
bool ElementLink< STORABLE >::setStorableObject ( BaseConstReference data,
bool replace = false )

Set link storable to data object pointed by data (slower).

◆ setStorableObject() [2/2]

bool ElementLinkBase::setStorableObject ( const_pointer_t data,
CLID link_clid,
bool replace,
IProxyDict * sg )
protectedinherited

Set the container referenced by the link to data.

Parameters
dataPointer to the new container.
link_clidCLID of the link being set.
replaceTrue if we can change an existing link.
sgAssociated 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<typename STORABLE>
xAOD::TVirtualEvent * ElementLink< STORABLE >::source ( ) const
inline

Get the data source for the reference.

Definition at line 183 of file A/AthLinks/ElementLink.h.

183{ return m_event; }

◆ storableBase()

void * ElementLinkBase::storableBase ( castfn_t * castfn,
CLID clid,
bool isConst ) const
protectedinherited

Return a pointer to the currently-referenced container 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).

◆ storeCachedElement()

void ElementLinkBase::storeCachedElement ( ElementType elt)
protectedinherited

Set the cached element stored in the link.

Parameters
eltNew value for the cached element.

◆ storedIndex()

const stored_index_type & ElementLinkBase::storedIndex ( ) const
protectedinherited

Return the stored representation of the link index.

◆ thin() [1/2]

bool ElementLinkBase::thin ( )
inherited

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]

bool ElementLinkBase::thin ( const SG::ThinningCache * thinningCache)
inherited

Adjust for thinning.

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

Parameters
thinningCacheThinning cache for the current stream (may be null).

Returns true if the link was changed; false otherwise.

◆ toContainedElement()

template<typename STORABLE>
bool ElementLink< STORABLE >::toContainedElement ( BaseConstReference container,
ElementType element )

Set link to point to given element (slowest).

◆ toIndexedElement() [1/2]

template<typename STORABLE>
bool ElementLink< STORABLE >::toIndexedElement ( BaseConstReference container,
index_type index )

Set link to point to given index (slower).

◆ toIndexedElement() [2/2]

bool ElementLinkBase::toIndexedElement ( const_pointer_t obj,
CLID link_clid,
index_type elemID,
IProxyDict * sg )
protectedinherited

Set the link to an element given by index and pointer to container.

Parameters
objPointer to the container (storable).
link_clidCLID of the link being set.
elemIDThe index of the element within the container.
sgAssociated 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<typename STORABLE>
bool ElementLink< STORABLE >::toPersistent ( )
inline

Dummy function provinding the offline interface.

Definition at line 186 of file A/AthLinks/ElementLink.h.

186{ return true; }

◆ toTransient() [1/2]

template<typename STORABLE>
virtual bool ElementLink< STORABLE >::toTransient ( )
privatevirtual

Reset the object's internal cache.

Implements ElementLinkBase.

◆ toTransient() [2/2]

bool ElementLinkBase::toTransient ( IProxyDict * sg = 0)
inherited

Finish initialization after link has been read.

Parameters
sgAssociated store.

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.

Member Data Documentation

◆ INVALID [1/2]

const uint32_t ElementLinkBase::INVALID = static_cast<uint32_t> (-1)
staticprivateinherited

Value to mark an invalid index.

Definition at line 62 of file AthLinks/ElementLinkBase.h.

◆ INVALID [2/2]

uint32_t ElementLinkBase::INVALID = static_cast<uint32_t> (-1)
staticconstexprprivateinherited

Value to mark a default index.

Definition at line 27 of file A/AthLinks/ElementLinkBase.h.

◆ m_container

template<typename STORABLE>
BaseConstPointer ElementLink< STORABLE >::m_container
mutableprivate

Cached pointer to the container.

Definition at line 197 of file A/AthLinks/ElementLink.h.

◆ m_element

template<typename STORABLE>
ElementType ElementLink< STORABLE >::m_element
mutableprivate

Cached pointer to the object.

Definition at line 199 of file A/AthLinks/ElementLink.h.

◆ m_elementCached

template<typename STORABLE>
bool ElementLink< STORABLE >::m_elementCached
mutableprivate

Status of the cached pointer.

Definition at line 201 of file A/AthLinks/ElementLink.h.

◆ m_event

template<typename STORABLE>
xAOD::TVirtualEvent* ElementLink< STORABLE >::m_event
private

Pointer to the event object.

Definition at line 203 of file A/AthLinks/ElementLink.h.

◆ m_isDirectIO

bool ElementLinkBase::m_isDirectIO
protectedinherited

A transient variable signalling when direct I/O is happening.

This flag is used exclusively by the ElementLink<>::toTransient() function to know when it should take the persistent data stored in this object into account. That function may be called in normal P->T conversions as well, in which case using the data from this class would just reset the object to its default state.

Definition at line 68 of file A/AthLinks/ElementLinkBase.h.

◆ m_persIndex [1/2]

stored_index_type ElementLinkBase::m_persIndex
privateinherited

The index of the element within the container for this link.

Definition at line 504 of file AthLinks/ElementLinkBase.h.

◆ m_persIndex [2/2]

uint32_t ElementLinkBase::m_persIndex
protectedinherited

Index of the referenced object in the container.

Definition at line 58 of file A/AthLinks/ElementLinkBase.h.

◆ m_persKey [1/2]

SG::sgkey_t ElementLinkBase::m_persKey
privateinherited

The hashed key for this link.

Definition at line 501 of file AthLinks/ElementLinkBase.h.

◆ m_persKey [2/2]

uint32_t ElementLinkBase::m_persKey
protectedinherited

Key/identifier of the referenced container.

Definition at line 56 of file A/AthLinks/ElementLinkBase.h.

◆ m_proxy

SG::DataProxyHolder ElementLinkBase::m_proxy
privateinherited

SG proxy for this link.

Definition at line 507 of file AthLinks/ElementLinkBase.h.


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