ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SG::DVLDataBucket< T > Class Template Reference

A DataBucket specialized for DataVector/DataList. More...

#include <DVLDataBucket.h>

Inheritance diagram for SG::DVLDataBucket< T >:
Collaboration diagram for SG::DVLDataBucket< T >:

Public Member Functions

 DVLDataBucket ()
 Default constructor. More...
 
 DVLDataBucket (T *data)
 Constructor from a payload object. More...
 
template<class U >
 DVLDataBucket (std::unique_ptr< U > data)
 Constructor from a payload object. More...
 
 DVLDataBucket (const DVLDataBucket &other)
 Copy constructor. More...
 
virtual ~DVLDataBucket () override
 Destructor. More...
 
virtual void * cast (CLID clid, IRegisterTransient *irt=0, bool isConst=true) override
 Return the contents of the DataBucket, converted to type given by clid. More...
 
virtual void * cast (const std::type_info &tinfo, IRegisterTransient *irt=0, bool isConst=true) override
 Return the contents of the DataBucket, converted to type given by std::type_info. More...
 
virtual void * cast (CLID clid, const std::type_info &tinfo, SG::IRegisterTransient *irt=0, bool isConst=true) override
 Return the contents of the DataBucket, converted to type given by clid. More...
 
virtual const CLIDclID () const override
 The CLID for the class of object we're holding. More...
 
virtual const std::type_info & tinfo () const override
 The std::type_info for the class of object we're holding. More...
 
virtual void * object () override
 
 operator T* ()
 
 operator const T * () const
 
template<class T >
T * cast (SG::IRegisterTransient *irt=0, bool isConst=true)
 Return the contents of the DataBucket, converted to type T. More...
 
virtual void relinquish () override
 Give up ownership of the DataBucket contents. More...
 
virtual void lock () override
 If the held object derives from ILockable, call lock() on it. More...
 

Static Public Member Functions

static const CLIDclassID ()
 

Protected Member Functions

T * ptr ()
 
const T * cptr () const
 
void * tryStaticConversion (CLID clid)
 Try a conversion using static SG_BASES information. More...
 
void * tryStaticConversion (const std::type_info &tinfo)
 Try a conversion using static SG_BASES information. More...
 

Private Types

typedef std::pair< DataModel_detail::DVLInfoBase *, void * > ent_t
 
typedef std::vector< ent_tvec_t
 

Private Member Functions

DVLDataBucketoperator= (const DVLDataBucket &)
 

Private Attributes

vec_t m_copies
 
const std::type_info * m_ti
 The std::type_info for the class of object we're holding. More...
 
CLID m_clid
 The CLID for the class of object we're holding. More...
 
T * m_ptr
 
vec_t m_cnvcopies
 

Detailed Description

template<class T>
class SG::DVLDataBucket< T >

A DataBucket specialized for DataVector/DataList.

DataVector and DataList have some special conversion requirements.

In particular, we may have a situation where we're asked to convert from DataVector<D> to DataVector<B>, where these two classes are not related by inheritance, but D derived from B. (In practice, this arises when one has multiple inheritance, and can't mirror both arms with DataVector/DataList.)

This DataBucket allows such conversions to happen by making a copy of the container (as a view container) and converting the contained pointers. The new instance remains owned by the DataBucket.

We may also try to create a bucket for a ViewVector<DV> object given a pointer to its DV base class. In such a case, we detect that we actually have a ViewVector and adjust appropriately the CLID and type_info that we return.

Definition at line 47 of file DVLDataBucket.h.

Member Typedef Documentation

◆ ent_t

template<class T >
typedef std::pair<DataModel_detail::DVLInfoBase*, void*> SG::DVLDataBucket< T >::ent_t
private

Definition at line 150 of file DVLDataBucket.h.

◆ vec_t

template<class T >
typedef std::vector<ent_t> SG::DVLDataBucket< T >::vec_t
private

Definition at line 151 of file DVLDataBucket.h.

Constructor & Destructor Documentation

◆ DVLDataBucket() [1/4]

template<class T >
SG::DVLDataBucket< T >::DVLDataBucket ( )
inline

Default constructor.

Definition at line 54 of file DVLDataBucket.h.

54  :
55  m_ti (nullptr),
56  m_clid (CLID_NULL)
57  {}

◆ DVLDataBucket() [2/4]

template<class T >
SG::DVLDataBucket< T >::DVLDataBucket ( T *  data)

Constructor from a payload object.

Parameters
dataObject to hold in the bucket.

◆ DVLDataBucket() [3/4]

template<class T >
template<class U >
SG::DVLDataBucket< T >::DVLDataBucket ( std::unique_ptr< U >  data)

Constructor from a payload object.

Parameters
dataObject to hold in the bucket.

◆ DVLDataBucket() [4/4]

template<class T >
SG::DVLDataBucket< T >::DVLDataBucket ( const DVLDataBucket< T > &  other)

Copy constructor.

Parameters
otherBucket to copy.

◆ ~DVLDataBucket()

template<class T >
virtual SG::DVLDataBucket< T >::~DVLDataBucket ( )
overridevirtual

Destructor.

Member Function Documentation

◆ cast() [1/4]

template<class T >
virtual void* SG::DVLDataBucket< T >::cast ( CLID  clid,
const std::type_info &  tinfo,
SG::IRegisterTransient irt = 0,
bool  isConst = true 
)
overridevirtual

Return the contents of the DataBucket, converted to type given by clid.

Note that only derived->base conversions are allowed here.

Parameters
clidThe class ID to which to convert.
tinfoThe std::type_info of the type to which to convert.
irtTo be called if we make a new instance.
isConstTrue if the object being converted is regarded as const.

This allows the callee to choose whether to use clid or tinfo. Here we use clid.

Reimplemented from SG::DataBucket< T >.

◆ cast() [2/4]

template<class T >
virtual void* SG::DVLDataBucket< T >::cast ( CLID  clid,
IRegisterTransient irt = 0,
bool  isConst = true 
)
overridevirtual

Return the contents of the DataBucket, converted to type given by clid.

Note that only derived->base conversions are allowed here.

Parameters
clidThe class ID to which to convert.
irtTo be called if we make a new instance.
isConstTrue if the object being converted is regarded as const.

Reimplemented from SG::DataBucket< T >.

◆ cast() [3/4]

template<class T >
virtual void* SG::DVLDataBucket< T >::cast ( const std::type_info &  tinfo,
IRegisterTransient irt = 0,
bool  isConst = true 
)
overridevirtual

Return the contents of the DataBucket, converted to type given by std::type_info.

Note that only derived->base conversions are allowed here.

Parameters
clidThe std::type_info of the type to which to convert.
irtTo be called if we make a new instance.
isConstTrue if the object being converted is regarded as const.

Reimplemented from SG::DataBucket< T >.

◆ cast() [4/4]

template<class T >
T* DataBucketBase::cast ( SG::IRegisterTransient irt = 0,
bool  isConst = true 
)
inherited

Return the contents of the DataBucket, converted to type T.

Note that only derived->base conversions are allowed here. T must have a valid Class ID for this to work.

Parameters
irtTo be called if we make a new instance.
isConstTrue if the object being converted is regarded as const.

◆ classID()

template<class T >
static const CLID& SG::DataBucket< T >::classID ( )
staticinherited

◆ clID()

template<class T >
virtual const CLID& SG::DVLDataBucket< T >::clID ( ) const
overridevirtual

The CLID for the class of object we're holding.

May be different from that of the base DataVector in the case of a ViewVector.

Reimplemented from SG::DataBucket< T >.

◆ cptr()

template<class T >
const T* SG::DataBucket< T >::cptr ( ) const
inlineprotectedinherited

Definition at line 133 of file DataBucket.h.

133 { return m_ptr; }

◆ lock()

template<class T >
virtual void SG::DataBucket< T >::lock ( )
overridevirtualinherited

If the held object derives from ILockable, call lock() on it.

Implements DataBucketBase.

◆ object()

template<class T >
virtual void* SG::DataBucket< T >::object ( )
inlineoverridevirtualinherited

Implements DataBucketBase.

Definition at line 51 of file DataBucket.h.

52  {
53  typedef typename std::remove_const<T>::type T_nc;
54  return const_cast<T_nc*>(m_ptr);
55  }

◆ operator const T *()

template<class T >
SG::DataBucket< T >::operator const T * ( ) const
inlineinherited

Definition at line 74 of file DataBucket.h.

74 { return cptr(); }

◆ operator T*()

template<class T >
SG::DataBucket< T >::operator T* ( )
inlineinherited

Definition at line 73 of file DataBucket.h.

73 { return ptr(); } //FIXME can we do without?

◆ operator=()

template<class T >
DVLDataBucket& SG::DVLDataBucket< T >::operator= ( const DVLDataBucket< T > &  )
private

◆ ptr()

template<class T >
T* SG::DataBucket< T >::ptr ( )
inlineprotectedinherited

Definition at line 132 of file DataBucket.h.

132 { return m_ptr; }

◆ relinquish()

template<class T >
virtual void SG::DataBucket< T >::relinquish ( )
inlineoverridevirtualinherited

Give up ownership of the DataBucket contents.

This leaks the contents and it is useful mainly for error handling.

Implements DataBucketBase.

Definition at line 123 of file DataBucket.h.

123 { m_ptr=0;} //LEAKS m_ptr

◆ tinfo()

template<class T >
virtual const std::type_info& SG::DVLDataBucket< T >::tinfo ( ) const
overridevirtual

The std::type_info for the class of object we're holding.

May be different from that of the base DataVector in the case of a ViewVector.

Reimplemented from SG::DataBucket< T >.

◆ tryStaticConversion() [1/2]

template<class T >
void* SG::DataBucket< T >::tryStaticConversion ( CLID  clid)
protectedinherited

Try a conversion using static SG_BASES information.

Parameters
clidThe class ID to which to convert.

This can all be unfolded at compile time, so is fast, but doesn't take into account SG_ADD_BASES.

◆ tryStaticConversion() [2/2]

template<class T >
void* SG::DataBucket< T >::tryStaticConversion ( const std::type_info &  tinfo)
protectedinherited

Try a conversion using static SG_BASES information.

Parameters
tinfoThe std::type_info of the type to which to convert.

This can all be unfolded at compile time, so is fast, but doesn't take into account SG_ADD_BASES.

Member Data Documentation

◆ m_clid

template<class T >
CLID SG::DVLDataBucket< T >::m_clid
private

The CLID for the class of object we're holding.

May be different from that of the base DataVector in the case of a ViewVector.

Definition at line 162 of file DVLDataBucket.h.

◆ m_cnvcopies

template<class T >
vec_t SG::DataBucket< T >::m_cnvcopies
privateinherited

Definition at line 162 of file DataBucket.h.

◆ m_copies

template<class T >
vec_t SG::DVLDataBucket< T >::m_copies
private

Definition at line 152 of file DVLDataBucket.h.

◆ m_ptr

template<class T >
T* SG::DataBucket< T >::m_ptr
privateinherited

Definition at line 157 of file DataBucket.h.

◆ m_ti

template<class T >
const std::type_info* SG::DVLDataBucket< T >::m_ti
private

The std::type_info for the class of object we're holding.

May be different from that of the base DataVector in the case of a ViewVector.

Definition at line 157 of file DVLDataBucket.h.


The documentation for this class was generated from the following file:
SG::DVLDataBucket::m_ti
const std::type_info * m_ti
The std::type_info for the class of object we're holding.
Definition: DVLDataBucket.h:157
SG::DataBucket::cptr
const T * cptr() const
Definition: DataBucket.h:133
SG::DVLDataBucket::m_clid
CLID m_clid
The CLID for the class of object we're holding.
Definition: DVLDataBucket.h:162
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SG::DataBucket::ptr
T * ptr()
Definition: DataBucket.h:132
SG::DataBucket::m_ptr
T * m_ptr
Definition: DataBucket.h:157