xAOD::THolder Class Reference

This class takes care of holding EDM objects in memory. More...

#include <THolder.h>

Inheritance diagram for xAOD::THolder:
xAOD::TCDVHolderT< T >

List of all members.

Public Member Functions

 THolder ()
 Default constructor.
 THolder (void *object,::TClass *type,::Bool_t owner=kTRUE)
 Constructor pointing to an object in memory.
 THolder (void *object, const std::type_info &type,::Bool_t owner=kTRUE)
 Constructor pointing to an object in memory.
 THolder (const THolder &parent)
 Copy constructor.
 THolder (THolder &&parent)
 Move constructor.
virtual ~THolder ()
 The destructor cleans out the memory used by the managed object.
THolderoperator= (const THolder &rhs)
 Assignment operator.
THolderoperator= (THolder &&rhs)
 Move operator.
void * get () const
 Return a typeless pointer to the held object.
void ** getPtr ()
 Return a typeless pointer to the held object's pointer.
virtual void set (void *obj)
 Replace the managed object.
::Bool_t isOwner () const
 Check whether the holder owns its object.
void setOwner (::Bool_t state=kTRUE)
 Set whether the holder should own its object.
virtual void * getAs (const std::type_info &tid,::Bool_t silent=kFALSE) const
 Return the object as a specific pointer.
virtual const void * getAsConst (const std::type_info &tid,::Bool_t silent=kFALSE) const
 Return the object as a specific, constant pointer.
::TClass * getClass () const
 Return the concrete type of the object.
const std::type_info * getTypeInfo () const
 Return the concrete type of the object.
void renew ()
 Renew the object in memory.

Protected Types

typedef std::map< const
std::type_info *, TClass * > 
TypeCache_t
 Type for the internal cache.
typedef std::map< void *, int > SharedCount_t
 Type implementing the instance counting.

Protected Member Functions

void deleteObject ()
 Internal function used to delete the managed object from memory.

Protected Attributes

void * m_object
 Typeless pointer to the object in memory.
::TClass * m_type
 Concrete type of the object being held on to.
const std::type_info * m_typeInfo
 Concrete type of the object, if it doesn't have a dictionary.
::Bool_t m_owner
 A flag for whether the object owns what it points to.

Static Protected Attributes

static TypeCache_t s_typeMap = THolder::TypeCache_t()
 Cache for the requested class types.
static SharedCount_t s_sharedCount = THolder::SharedCount_t()
 Variable counting the different object instances.

Detailed Description

This class takes care of holding EDM objects in memory.

In order to be able to access EDM objects easily as their concrete type, or as one of their base classes, a little trickery is needed.

We always access the branches of the input TTree as their concrete, transient types. It is then up to our own code to decide if the user is requesting the object as a type that it can be cast to, or not.

Author:
Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
Revision
725531
Date
2016-02-22 17:14:25 +0100 (Mon, 22 Feb 2016)

Constructor & Destructor Documentation

xAOD::THolder::THolder ( const THolder parent  ) 

Copy constructor.

The copy constructor takes the pointer from the parent object, and based on whether the parent owned the object or not, increments the shared count.

Parameters:
parent The parent object that should be copied
xAOD::THolder::THolder ( THolder &&  parent  ) 

Move constructor.

This is a tricky one. Since the object is being moved, meaning that the parent will be deleted right after this operation, instead of incrementing and then decrementing the shared count, we just tell the parent that it doesn't own its object anymore. In this case if it did own it, the shared count will remain valid. Since it's this object owning it now. If it didn't own the object in the first place, then no hard no foul.

Parameters:
parent The parent object that should be moved

Member Function Documentation

void * xAOD::THolder::getAs ( const std::type_info &  tid,
::Bool_t  silent = kFALSE 
) const [virtual]

Return the object as a specific pointer.

This function is used for retrieving an object as one of its bases. It is used when the caller requires a non-const pointer to the managed object.

Parameters:
tid The type as which the object is to be retrieved
silent When kTRUE, the call will fail silently when unsuccessful
Returns:
A non-const pointer that can be cast to the requested type
const void * xAOD::THolder::getAsConst ( const std::type_info &  tid,
::Bool_t  silent = kFALSE 
) const [virtual]

Return the object as a specific, constant pointer.

This function is used for retrieving an object as one of its bases. It is used when the caller need a const pointer to the managed object.

Parameters:
tid The type as which the object is to be retrieved
silent When kTRUE, the call will fail silently when unsuccessful
Returns:
A const pointer that can be cast to the requested type

Reimplemented in xAOD::TCDVHolderT< T >.

THolder & xAOD::THolder::operator= ( THolder &&  rhs  ) 

Move operator.

This move operator is necessary to be able to use this type as a value type of STL containers.

See the comments given for the move constructor for an explanation of the behaviour of this operator.

Parameters:
rhs The object that has to be moved
Returns:
A reference to this same object
THolder & xAOD::THolder::operator= ( const THolder rhs  ) 

Assignment operator.

The copy operator, just like the copy constructor makes the object aware that it doesn't own the object that it has the pointer to.

Parameters:
rhs The object that has to be copied
Returns:
A reference to this same object
void xAOD::THolder::renew (  ) 

Renew the object in memory.

This function is mostly used in "Athena access mode", to delete the managed objects from memory between events, and recreate them from scratch.


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