ElementLink< STORABLE > Class Template Reference

ElementLink implementation for ROOT usage. More...

#include <ElementLink.h>

Inheritance diagram for ElementLink< STORABLE >:
SelectNoInstance ElementLinkBase

List of all members.

Public Types

typedef ElementLink< STORABLE > self
 Helper definition.
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.
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)
 ElementLink (sgkey_t id, index_type index, ElementType element, xAOD::TVirtualEvent *event=0)
 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.
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.

Public Attributes

ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_container
 Mark all transient members:.
ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_element
ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_elementCached
ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_event

Detailed Description

template<typename STORABLE>
class ElementLink< STORABLE >

ElementLink implementation for ROOT usage.

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 <Attila.Krasznahorkay@cern.ch>
Revision
649074
Date
2015-02-23 17:51:40 +0100 (Mon, 23 Feb 2015)

Constructor & Destructor Documentation

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

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!

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

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!


Member Function Documentation

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

Get a constant pointer to the referenced object.

This is the only function in the ElementLink code that tries to retrieve information from the event.

Returns:
A constant pointer to the element, or a null pointer if unsuccessful

Default key, calculated just once:

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

Check if the element can be found.

Default key, calculated just once:

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

Reset with storable id and element index (fastest).

This is the fastest way of setting an existing ElementLink to point to a new element. It's just a bit more inconvenient than the function receiving a string identifier for the container.

Parameters:
id A hashed identifier for the container
index The index of the element inside its container
event An alternative event object to use
template<typename STORABLE >
void ElementLink< STORABLE >::resetWithKeyAndIndex ( const ID_type key,
index_type  index,
xAOD::TVirtualEvent event = 0 
) [inline]

Reset with storable key and element index (fast).

This is probably the most preferred way of setting an existing ElementLink to point to a new element. It doesn't need to do any costly lookups.

Parameters:
key The user-readable key of the container
index The index of the element inside its container
event An alternative event object to use
template<typename STORABLE >
bool ElementLink< STORABLE >::setElement ( ElementType  element  )  [inline]

Set link to point to an Element (slowest).

This function can be used to set the link to point to a new element inside the container that it already points to. The function is slow, as it needs to find the index of the element inside the container.

Avoid using if at all possible!

Parameters:
element The element within the container that the link should point to
Returns:
A dymmy value. Failure is signalled by an exception.
template<typename STORABLE >
bool ElementLink< STORABLE >::setStorableObject ( BaseConstReference  data,
bool  replace = false 
) [inline]

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

This function tells the object to start using a new container. It should be used together with the setElement function most of the time. It is however a slow function, so please avoid it if possible.

Parameters:
data The container that the link should point to
replace true if the element pointer will be replaced
Returns:
A dymmy value. Failure is signalled by an exception.
template<typename STORABLE >
bool ElementLink< STORABLE >::toContainedElement ( BaseConstReference  container,
ElementType  element 
) [inline]

Set link to point to given element (slowest).

This is probably the slowest function of the class. It first needs to look up the ID of the received container inside the event, and then needs to find the index of the object within this container.

Avoid using if at all possible!

Parameters:
container The container that the link should point to
element The element within the container that the link should point to
Returns:
A dymmy value. Failure is signalled by an exception.
template<typename STORABLE >
bool ElementLink< STORABLE >::toIndexedElement ( BaseConstReference  container,
index_type  index 
) [inline]

Set link to point to given index (slower).

This function can be used to set up an existing element link to point at an indexed element of a specific object in memory. The link needs to ask the event for the ID of the received object, so the function can take a bit of time.

Parameters:
container The container that the link should point to
index The index of the element inside the container that the link needs to point to
Returns:
A dummy value. Failure is signalled by an exception.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1