DataLink< STORABLE > Class Template Reference

DataLink implementation for ROOT usage. More...

#include <DataLink.h>

Inheritance diagram for DataLink< STORABLE >:
SelectNoInstance DataLinkBase

List of all members.

Public Types

typedef DataLink< STORABLE > self
 Convenience declaration of this structure's type.
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 STORABLE value_type
 Type of the object being handled.
typedef STORABLE * __attribute__ ((deprecated)) pointer
 Pointer type for the object being handled.
typedef const STORABLE * const_pointer
 Constant pointer type for the object being handled.
typedef STORABLE & __attribute__ ((deprecated)) reference
 Reference type for the object being handled.
typedef const STORABLE & const_reference
 Constant reference type for the object being handled.

Public Member Functions

xAOD::TVirtualEventsource () const
 Get the data source for the reference.
bool toPersistent ()
 Prepare the object to be written out.
Constructors



 DataLink ()
 Default constructor, creating a null pointer basically.
 DataLink (xAOD::TVirtualEvent *event)
 Constructor taking an alternative TVirtualEvent object to use.
 DataLink (const_reference data, xAOD::TVirtualEvent *event=0)
 Constructor receiving a reference to the target object.
 DataLink (const_pointer data, xAOD::TVirtualEvent *event=0)
 Constructor receiving a pointer to the target object.
 DataLink (const ID_type &id, xAOD::TVirtualEvent *event=0)
 Constructor receiving a user-readable ID for the target object.
 DataLink (sgkey_t key, xAOD::TVirtualEvent *event=0)
 Constructor receiving a hashed ID for the target object.
template<typename T >
 DataLink (const DataLink< T > &parent)
 Copy constructor.
Setter functions



void toStorableObject (const_reference data)
 Set the link to a data object that's already in the event.
void toDefaultObject ()
 Set the link to the default object of this type in the event.
void toIdentifiedObject (const ID_type &id)
 Set the link using a user readable ID for the target object.
void toIdentifiedObject (sgkey_t key)
 Set the link using a hashed ID for the target object.
Accessor functions



const_reference operator* () const
 Get a reference to the target object. May throw an exception.
const_pointer operator-> () const
 Get a pointer to the target object.
 operator const_pointer () const
 Automatic conversion operator.
const_pointer cptr () const
 Get a constant pointer to the referenced object.
bool isValid () const
 Check if the object can be found.
 operator bool () const
 Convenience validity check operator.
bool operator! () const
 Another convenience validity checker.
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.

Public Attributes

ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_object
 Declare m_object as transient.
ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_event
 Declare m_event as transient.

Detailed Description

template<typename STORABLE>
class DataLink< STORABLE >

DataLink implementation for ROOT usage.

This is an implementation of DataLink<T> for vanilla ROOT. The code is quite simple, leaving most of the work for the xAOD::TEvent 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 >
DataLink< STORABLE >::DataLink (  )  [inline]

Default constructor, creating a null pointer basically.

This constructor creates an object that will either return a null pointer when asked for one, or throw an exception when trying to de-reference it.

template<typename STORABLE >
DataLink< STORABLE >::DataLink ( xAOD::TVirtualEvent event  )  [inline]

Constructor taking an alternative TVirtualEvent object to use.

This constructor allows the user to create a null-pointer that uses an alternative TVirtualEvent object as its store.

Parameters:
event Pointer to an alternative TVirtualEvent object
template<typename STORABLE >
DataLink< STORABLE >::DataLink ( const_reference  data,
xAOD::TVirtualEvent event = 0 
) [inline]

Constructor receiving a reference to the target object.

This constructor can be used to create a valid object based on a reference to an existing object, that's already part of the current event. In case the object can not be found in the current event, the constructor throws an exception.

Parameters:
data A constant reference to the object that the smart pointer should point to
event Pointer to an alternative TVirtualEvent object
template<typename STORABLE >
DataLink< STORABLE >::DataLink ( const_pointer  data,
xAOD::TVirtualEvent event = 0 
) [inline]

Constructor receiving a pointer to the target object.

This constructor can be used to create a valid object based on a pointer to an existing object, that's already part of the current event. In case the object can not be found in the current event, the constructor throws an exception.

Parameters:
data A constant pointer to the object that the smart pointer should point to
event Pointer to an alternative TVirtualEvent object
template<typename STORABLE >
DataLink< STORABLE >::DataLink ( const ID_type id,
xAOD::TVirtualEvent event = 0 
) [inline]

Constructor receiving a user-readable ID for the target object.

This is probably the most convenient version of the constructors. It receives a string identifier (branch name) for the object that the smart pointer should reference.

Parameters:
id A string identifier for the object to be referenced
event Pointer to an alternative TVirtualEvent object
template<typename STORABLE >
DataLink< STORABLE >::DataLink ( sgkey_t  key,
xAOD::TVirtualEvent event = 0 
) [inline]

Constructor receiving a hashed ID for the target object.

This is the most cost-effective of the constructors after the default one. It relies on the user knowing exactly what hashed key to ask for for the target object.

Parameters:
key A hashed key identifying the object to be referenced
event Pointer to an alternative TVirtualEvent object
template<typename STORABLE >
template<typename T >
DataLink< STORABLE >::DataLink ( const DataLink< T > &  parent  )  [inline]

Copy constructor.

Simple copy-constructor. It just copies the persistent information from the base class together with the TVirtualEvent pointer that the parent class had.

Parameters:
parent The parent object to be copied

Member Function Documentation

template<class STORABLE >
DataLink< STORABLE >::const_pointer DataLink< STORABLE >::cptr (  )  const [inline]

Get a constant pointer to the referenced object.

This function is doing most of the heavy lifting. It interacts with the TVirtualEvent object to deliver a pointer to the target object to the user.

Returns:
A constant pointer to the target object if available, a null pointer if not

Default key, calculated just once:

template<class STORABLE >
bool DataLink< STORABLE >::isValid (  )  const [inline]

Check if the object can be found.

Default key, calculated just once:

template<class STORABLE >
DataLink< STORABLE >::const_reference DataLink< STORABLE >::operator* (  )  const [inline]

Get a reference to the target object. May throw an exception.

This operator can be used to get a constant reference to the object. In most cases though one should probably use the -> operator instead. The code throws an exception if the target object is not available.

Returns:
A constant reference to the target object if available
template<typename STORABLE >
void DataLink< STORABLE >::toDefaultObject (  )  [inline]

Set the link to the default object of this type in the event.

This function sets up the object to point at the default object of the template type in the event. It can be useful when only one object of a given type is available.

template<typename STORABLE >
void DataLink< STORABLE >::toIdentifiedObject ( sgkey_t  key  )  [inline]

Set the link using a hashed ID for the target object.

This function hardly has to do anything. It just sets the received key as the persistent information for the object, and resets its internals.

Parameters:
key The hashed key for the target object
template<typename STORABLE >
void DataLink< STORABLE >::toIdentifiedObject ( const ID_type id  )  [inline]

Set the link using a user readable ID for the target object.

This is one of the more convenient functions. It sets up the smart pointer using a user-readable string idetifier for the target object.

Parameters:
id A string identifier (branch name) for the target object
template<class STORABLE >
bool DataLink< STORABLE >::toPersistent (  )  [inline]

Prepare the object to be written out.

This function is just here to enable us compiling the same EDM code as we do offline. We don't actually need to prepare this object for being written out, it's always in a consistent state.

Returns:
A dummy value. Just to have the same signature as the offline function.
template<typename STORABLE >
void DataLink< STORABLE >::toStorableObject ( const_reference  data  )  [inline]

Set the link to a data object that's already in the event.

This function should be used to set up the object when your code has a reference to the target object.

The function will throw an exception if the supplied object can't be found in the current event.

Parameters:
data A reference to the target object

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