ATLAS Offline Software
Loading...
Searching...
No Matches
ElementLink.h File Reference
#include "AthLinks/tools/ElementLinkTraits.h"
#include "AthLinks/DataLink.h"
#include <utility>
#include "AthLinks/ElementLink.icc"
Include dependency graph for AthLinks/ElementLink.h:

Go to the source code of this file.

Classes

 Specialization for a pair containing an ElementLink, allowing for faster initialization. More...

Namespaces

namespace  SG_detail
namespace  std
 STL namespace.

Functions

static CLID classID ()
bool SG_detail::checkForRemap (IProxyDict *sg, SG::sgkey_t sgkey_in, size_t index_in, SG::sgkey_t &sgkey_out, size_t &index_out)
 See if an EL is being remapped.
template<class T>
bool SG_detail::checkForRemap (IProxyDict *sg, SG::sgkey_t sgkey_in, const T &, SG::sgkey_t &sgkey_out, T &)
 See if an EL is being remapped.
Constructors.
 ElementLink ()
 Default constructor.
 ElementLink (const ID_type &dataID, index_type elemID, IProxyDict *sg=0)
 Construct a link from a string storable key and an index.
 ElementLink (const ID_type &dataID, index_type elemID, const EventContext &ctx)
 Construct a link from a string storable key and an index.
 ElementLink (sgkey_t key, index_type elemID, IProxyDict *sg=0)
 Construct a link from a hashed storable key and an index.
 ElementLink (sgkey_t key, index_type elemID, const EventContext &ctx)
 Construct a link from a hashed storable key and an index.
 ElementLink (const ID_type &dataID, index_type elemID, ElementType pEl, IProxyDict *sg=0)
 Construct from a string storable key, index, AND pointer to element.
 ElementLink (const ID_type &dataID, index_type elemID, ElementType pEl, const EventContext &ctx)
 Construct from a string storable key, index, AND pointer to element.
 ElementLink (sgkey_t key, index_type elemID, ElementType pEl, IProxyDict *sg=0)
 Construct from a hashed storable key, index, AND pointer to element.
 ElementLink (sgkey_t key, index_type elemID, ElementType pEl, const EventContext &ctx)
 Construct from a hashed storable key, index, AND pointer to element.
 ElementLink (BaseConstReference data, index_type elemID, IProxyDict *sg=0)
 Construct a link from an index and reference to the container.
 ElementLink (BaseConstReference data, index_type elemID, const EventContext &ctx)
 Construct a link from an index and reference to the container.
 ElementLink (const ElementType &element, BaseConstReference data, IProxyDict *sg=0)
 Construct from an element and reference to the container.
 ElementLink (const ElementType &element, BaseConstReference data, const EventContext &ctx)
 Construct from an element and reference to the container.
 ElementLink (const ElementLink &other, index_type elemID)
 Construct a link from another link, changing the index.
 ElementLink (const DataLink< STORABLE > &dlink, index_type index)
 Construct a link from a DataLink and an index.
template<class U>
 ElementLink (const ElementLink< U > &other)
 Constructor allowing a derived -> base conversion.
 ElementLink (const ElementLink &)=default
ElementLinkoperator= (const ElementLink &)=default
Dereferencing the link.
const_pointer getDataPtr () const
 Return a pointer to the currently-referenced container object.
pointer getDataNonConstPtr ()
 Return a pointer to the currently-referenced container object.
DataLink< STORABLE > getDataLink ()
 Return a link to the currently-referenced container object.
BaseConstPointer getStorableObjectPointer () const
 Return a pointer to the currently-referenced container object.
BaseConstReference getStorableObjectRef () const
 Return a reference to the currently-referenced container object.
ElementConstPointer cptr () const
 Return a pointer to the referenced element.
ElementConstReference operator* () const
 Return a reference to the referenced element.
ElementConstPointer operator-> () const
 Return a pointer to the referenced element.
 operator ElementConstPointer () const
 Convert to a pointer to the referenced element.
bool isValid () const
 Test to see if the link can be dereferenced.
bool operator! () const
 Test to see if the link can not be dereferenced.
ElementType cachedElement () const
 Return the cached element, if any.
Modifying the link.
bool toIndexedElement (BaseConstReference data, index_type elemID, IProxyDict *sg=0)
 Set the link to an element given by index and pointer to container.
bool toIndexedElement (BaseConstReference data, index_type elemID, const EventContext &ctx)
 Set the link to an element given by index and pointer to container.
bool toContainedElement (BaseConstReference data, ElementType element, IProxyDict *sg=0)
 Set from element pointer and a reference to the container (storable).
bool toContainedElement (BaseConstReference data, ElementType element, const EventContext &ctx)
 Set from element pointer and a reference to the container (storable).
bool setElement (ElementType element)
 Set to point to an element.
bool setStorableObject (BaseConstReference data, bool replace=false, IProxyDict *sg=0)
 Set link to point to a new container (storable).
bool setStorableObject (BaseConstReference data, bool replace, const EventContext &ctx)
 Set link to point to a new container (storable).
void resetWithKeyAndIndex (const ID_type &dataID, index_type elemID, IProxyDict *sg=0)
 Set the link to an element given by string key and index.
void resetWithKeyAndIndex (const ID_type &dataID, index_type elemID, const EventContext &ctx)
 Set the link to an element given by string key and index.
void resetWithKeyAndIndex (sgkey_t key, index_type elemID, IProxyDict *sg=0)
 Set the link to an element given by string key and index.
void resetWithKeyAndIndex (sgkey_t key, index_type elemID, const EventContext &ctx)
 Set the link to an element given by string key and index.
const void * storable () const
 Return a (void) pointer to the currently-referenced container object.
void * storableNonConst ()
 Return a (void) pointer to the currently-referenced container object.
template<typename STORABLE>
bool operator< (const ElementLink< STORABLE > &lhs, const ElementLink< STORABLE > &rhs)
 Ordering relation for ElementLink (less-than).
template<typename STORABLE>
bool operator> (const ElementLink< STORABLE > &lhs, const ElementLink< STORABLE > &rhs)
 Ordering relation for ElementLink (greater-than).
template<typename STORABLE>
bool operator== (const ElementLink< STORABLE > &lhs, const ElementLink< STORABLE > &rhs)
 Equality relation for ElementLink.
template<typename STORABLE>
bool operator!= (const ElementLink< STORABLE > &lhs, const ElementLink< STORABLE > &rhs)
 Inequality relation for ElementLink.

Function Documentation

◆ cachedElement()

ElementType cachedElement ( ) const

Return the cached element, if any.

◆ classID()

CLID classID ( )
static

◆ cptr()

ElementConstPointer cptr ( ) const

Return a pointer to the referenced element.

Be aware: if the element is a pointer, then this will yield a pointer to a pointer.

◆ ElementLink() [1/17]

ElementLink ( )

Default constructor.

Makes a null link.

◆ ElementLink() [2/17]

ElementLink ( BaseConstReference data,
index_type elemID,
const EventContext & ctx )

Construct a link from an index and reference to the container.

O(1)

Parameters
dataReference to the container (storable).
elemIDThe index of the element within the container.
ctxEvent context for this link.

◆ ElementLink() [3/17]

ElementLink ( BaseConstReference data,
index_type elemID,
IProxyDict * sg = 0 )

Construct a link from an index and reference to the container.

O(1)

Parameters
dataReference to the container (storable).
elemIDThe index of the element within the container.
sgAssociated store.

If sg is 0, we take the global default.

◆ ElementLink() [4/17]

ElementLink ( const DataLink< STORABLE > & dlink,
index_type index )

Construct a link from a DataLink and an index.

Parameters
dlinkLink to the container.
indexThe index of the element within the container.

◆ ElementLink() [5/17]

ElementLink ( const ElementLink & )
default

◆ ElementLink() [6/17]

ElementLink ( const ElementLink & other,
index_type elemID )

Construct a link from another link, changing the index.

Parameters
otherThe source link.
elemIDThe index for the new link.

The index being constructed will reference the same container as other, but it will refer to element elemID.

◆ ElementLink() [7/17]

template<class U>
ElementLink ( const ElementLink< U > & other)

Constructor allowing a derived -> base conversion.

◆ ElementLink() [8/17]

ElementLink ( const ElementType & element,
BaseConstReference data,
const EventContext & ctx )

Construct from an element and reference to the container.

O(N)

Parameters
elementThe element to reference.
dataReference to the container (storable).
ctxEvent context for this link.

Does the same thing as the default ctor followed by toContainedElement. Note the reversed parameter order compared to the previous constructor. This is to prevent ambiguities in the case that the contained type is convertable to an int.

Will throw SG::ExcElementNotFound if the element is not in the container.

◆ ElementLink() [9/17]

ElementLink ( const ElementType & element,
BaseConstReference data,
IProxyDict * sg = 0 )

Construct from an element and reference to the container.

O(N)

Parameters
elementThe element to reference.
dataReference to the container (storable).
sgAssociated store.

Does the same thing as the default ctor followed by toContainedElement. Note the reversed parameter order compared to the previous constructor. This is to prevent ambiguities in the case that the contained type is convertable to an int.

Will throw SG::ExcElementNotFound if the element is not in the container.

If sg is 0, we take the global default.

◆ ElementLink() [10/17]

ElementLink ( const ID_type & dataID,
index_type elemID,
const EventContext & ctx )

Construct a link from a string storable key and an index.

O(1)

Parameters
dataIDKey of the object.
elemIDThe index of the element within the container.
ctxEvent context for this link.

◆ ElementLink() [11/17]

ElementLink ( const ID_type & dataID,
index_type elemID,
ElementType pEl,
const EventContext & ctx )

Construct from a string storable key, index, AND pointer to element.

O(1)

Parameters
dataIDKey of the object.
elemIDThe index of the element within the container.
pElPointer to the element.
ctxEvent context for this link.

USE CAREFULLY: no coherency checks, we just trust you!

◆ ElementLink() [12/17]

ElementLink ( const ID_type & dataID,
index_type elemID,
ElementType pEl,
IProxyDict * sg = 0 )

Construct from a string storable key, index, AND pointer to element.

O(1)

Parameters
dataIDKey of the object.
elemIDThe index of the element within the container.
pElPointer to the element.
sgAssociated store.

USE CAREFULLY: no coherency checks, we just trust you!

If sg is 0, we take the global default.

◆ ElementLink() [13/17]

ElementLink ( const ID_type & dataID,
index_type elemID,
IProxyDict * sg = 0 )

Construct a link from a string storable key and an index.

O(1)

Parameters
dataIDKey of the object.
elemIDThe index of the element within the container.
sgAssociated store.

If sg is 0, we take the global default.

◆ ElementLink() [14/17]

ElementLink ( sgkey_t key,
index_type elemID,
const EventContext & ctx )

Construct a link from a hashed storable key and an index.

O(1)

Parameters
keyHashed key of the object.
elemIDThe index of the element within the container.
ctxEvent context for this link.

◆ ElementLink() [15/17]

ElementLink ( sgkey_t key,
index_type elemID,
ElementType pEl,
const EventContext & ctx )

Construct from a hashed storable key, index, AND pointer to element.

O(1)

Parameters
keyHashed key of the object.
elemIDThe index of the element within the container.
pElPointer to the element.
ctxEvent context for this link.

USE CAREFULLY: no coherency checks, we just trust you!

◆ ElementLink() [16/17]

ElementLink ( sgkey_t key,
index_type elemID,
ElementType pEl,
IProxyDict * sg = 0 )

Construct from a hashed storable key, index, AND pointer to element.

O(1)

Parameters
keyHashed key of the object.
elemIDThe index of the element within the container.
pElPointer to the element.
sgAssociated store.

USE CAREFULLY: no coherency checks, we just trust you!

If sg is 0, we take the global default.

◆ ElementLink() [17/17]

ElementLink ( sgkey_t key,
index_type elemID,
IProxyDict * sg = 0 )

Construct a link from a hashed storable key and an index.

O(1)

Parameters
keyHashed key of the object.
elemIDThe index of the element within the container.
sgAssociated store.

If sg is 0, we take the global default.

◆ getDataLink()

const DataLink< STORABLE > getDataLink ( )

Return a link to the currently-referenced container object.

◆ getDataNonConstPtr()

pointer getDataNonConstPtr ( )

Return a pointer to the currently-referenced container object.

Returns
A pointer to an object of the type given by clid, or null on a failure (or if the reference is null).

◆ getDataPtr()

const_pointer getDataPtr ( ) const

Return a pointer to the currently-referenced container object.

Returns
A pointer to an object of the type given by clid, or null on a failure (or if the reference is null).

◆ getStorableObjectPointer()

BaseConstPointer getStorableObjectPointer ( ) const

Return a pointer to the currently-referenced container object.

◆ getStorableObjectRef()

BaseConstReference getStorableObjectRef ( ) const

Return a reference to the currently-referenced container object.

◆ isValid()

bool isValid ( ) const

Test to see if the link can be dereferenced.

Will throw an exception if the container is not empty and the referenced element cannot be retrieved.

◆ operator ElementConstPointer()

operator ElementConstPointer ( ) const

Convert to a pointer to the referenced element.

◆ operator!()

bool operator! ( ) const

Test to see if the link can not be dereferenced.

◆ operator!=()

template<typename STORABLE>
bool operator!= ( const ElementLink< STORABLE > & lhs,
const ElementLink< STORABLE > & rhs )
private

Inequality relation for ElementLink.

Parameters
lhsLeft-hand-side EL.
rhsRight-hand-side EL.

◆ operator*()

ElementConstReference operator* ( ) const

Return a reference to the referenced element.

Will throw an exception if the link is not valid.

◆ operator->()

ElementConstPointer operator-> ( ) const

Return a pointer to the referenced element.

◆ operator<()

template<typename STORABLE>
bool operator< ( const ElementLink< STORABLE > & lhs,
const ElementLink< STORABLE > & rhs )
private

Ordering relation for ElementLink (less-than).

Parameters
lhsLeft-hand-side EL.
rhsRight-hand-side EL.

◆ operator=()

ElementLink & operator= ( const ElementLink & )
default

◆ operator==()

template<typename STORABLE>
bool operator== ( const ElementLink< STORABLE > & lhs,
const ElementLink< STORABLE > & rhs )
private

Equality relation for ElementLink.

Parameters
lhsLeft-hand-side EL.
rhsRight-hand-side EL.

◆ operator>()

template<typename STORABLE>
bool operator> ( const ElementLink< STORABLE > & lhs,
const ElementLink< STORABLE > & rhs )
private

Ordering relation for ElementLink (greater-than).

Parameters
lhsLeft-hand-side EL.
rhsRight-hand-side EL.

◆ resetWithKeyAndIndex() [1/4]

void resetWithKeyAndIndex ( const ID_type & dataID,
index_type elemID,
const EventContext & ctx )

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

Parameters
dataIDKey of the object.
elemIDThe index of the element within the container.
ctxThe event context.

◆ resetWithKeyAndIndex() [2/4]

void resetWithKeyAndIndex ( const ID_type & dataID,
index_type elemID,
IProxyDict * sg = 0 )

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

Parameters
dataIDKey of the object.
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() [3/4]

void resetWithKeyAndIndex ( sgkey_t key,
index_type elemID,
const EventContext & ctx )

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

Parameters
keyHashed key of the object.
elemIDThe index of the element within the container.
ctxThe event context.

◆ resetWithKeyAndIndex() [4/4]

void resetWithKeyAndIndex ( sgkey_t key,
index_type elemID,
IProxyDict * sg = 0 )

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

Parameters
keyHashed key of the object.
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.

◆ setElement()

bool setElement ( ElementType element)

Set to point to an element.

Parameters
elementThe element.
Returns
True if the link was changed.

The collection and the element can be specified independently using setElement and setStorableObject.

If the link is already set, this will return false and leave the link unchanged.

◆ setStorableObject() [1/2]

bool setStorableObject ( BaseConstReference data,
bool replace,
const EventContext & ctx )

Set link to point to a new container (storable).

Parameters
dataReference to the container (storable).
replaceTrue if we can change an existing link.
ctxThe event context.
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.

◆ setStorableObject() [2/2]

bool setStorableObject ( BaseConstReference data,
bool replace = false,
IProxyDict * sg = 0 )

Set link to point to a new container (storable).

Parameters
dataReference to the container (storable).
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.

◆ storable()

const void * storable ( ) const
private

Return a (void) pointer to the currently-referenced container object.

Returns
A pointer to an object of the type given by clid, or null on a failure (or if the reference is null).

◆ storableNonConst()

void * storableNonConst ( )
private

Return a (void) pointer to the currently-referenced container object.

Returns
A pointer to an object of the type given by clid, or null on a failure (or if the reference is null).

◆ toContainedElement() [1/2]

bool toContainedElement ( BaseConstReference data,
ElementType element,
const EventContext & ctx )

Set from element pointer and a reference to the container (storable).

Parameters
dataReference to the container (storable).
elementThe element.
ctxThe event context.
Returns
True if the link was changed.

O(N) for sequences!

If the link is already set, this will return false and leave the link unchanged.

◆ toContainedElement() [2/2]

bool toContainedElement ( BaseConstReference data,
ElementType element,
IProxyDict * sg = 0 )

Set from element pointer and a reference to the container (storable).

Parameters
dataReference to the container (storable).
elementThe element.
sgAssociated store.
Returns
True if the link was changed.

O(N) for sequences!

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.

◆ toIndexedElement() [1/2]

bool toIndexedElement ( BaseConstReference data,
index_type elemID,
const EventContext & ctx )

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

Parameters
dataReference to the container (storable).
elemIDThe index of the element within the container.
ctxThe event context.
Returns
True if the link was changed.

If the link is already set, this will return false and leave the link unchanged.

◆ toIndexedElement() [2/2]

bool toIndexedElement ( BaseConstReference data,
index_type elemID,
IProxyDict * sg = 0 )

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

Parameters
dataReference to the container (storable).
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.