ATLAS Offline Software
Loading...
Searching...
No Matches
TypelessDataBucket Class Reference

DataBucket holding the object as an untyped (void*) pointer. More...

#include <TypelessDataBucket.h>

Inheritance diagram for TypelessDataBucket:
Collaboration diagram for TypelessDataBucket:

Public Member Functions

 TypelessDataBucket (void *object, const SG::BaseInfoBase &bib)
 Constructor.
 ~TypelessDataBucket ()
 Destructor.
virtual const CLID & clID () const override
 Return the CLID.
virtual void * object () override
 Return the pointer as a void*.
virtual const std::type_info & tinfo () const override
 Return the type_info for the stored object.
virtual void * cast (CLID clid, SG::IRegisterTransient *irt=0, bool isConst=true) override
 Return the contents of the DataBucket, converted to type given by clid.
virtual void * cast (const std::type_info &tinfo, SG::IRegisterTransient *irt=0, bool isConst=true) override
 Return the contents of the DataBucket, converted to type given by std::type_info.
virtual void relinquish () override
 Give up ownership of the DataBucket contents.
virtual void lock () override
 If the held object derives from ILockable, call lock() on it.
template<class T>
T * cast (SG::IRegisterTransient *irt=0, bool isConst=true)
 Make visible the template version from the base class.
virtual void * cast (CLID clid, const std::type_info &tinfo, SG::IRegisterTransient *irt=0, bool isConst=true)
 Make visible the template version from the base class.

Private Attributes

void * m_object
 The held object.
const SG::BaseInfoBase & m_bib
 Type information for the held object.
CLID m_clid
 CLID of the held object.

Detailed Description

DataBucket holding the object as an untyped (void*) pointer.

Type information is provided via a BaseInfoBase object.

Definition at line 25 of file TypelessDataBucket.h.

Constructor & Destructor Documentation

◆ TypelessDataBucket()

TypelessDataBucket::TypelessDataBucket ( void * object,
const SG::BaseInfoBase & bib )

Constructor.

Parameters
objectThe object to be held. The DataBucket takes ownership.

Definition at line 19 of file TypelessDataBucket.cxx.

21 : m_object (object), m_bib (bib), m_clid (bib.clid())
22{
23}
CLID clid() const
Return the CLID for this class.
Definition BaseInfo.cxx:143
const SG::BaseInfoBase & m_bib
Type information for the held object.
void * m_object
The held object.
CLID m_clid
CLID of the held object.

◆ ~TypelessDataBucket()

TypelessDataBucket::~TypelessDataBucket ( )

Destructor.

Will destroy the held object.

Definition at line 29 of file TypelessDataBucket.cxx.

30{
31 if (m_object) {
32 m_bib.destroy (m_object);
33 }
34}

Member Function Documentation

◆ cast() [1/4]

virtual void * DataBucketBase::cast ( CLID clid,
const std::type_info & tinfo,
SG::IRegisterTransient * irt = 0,
bool isConst = true )
virtual

Make visible the template version from the base class.

Reimplemented from DataBucketBase.

◆ cast() [2/4]

void * TypelessDataBucket::cast ( CLID clid,
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.
irtTo be called if we make a new instance.
isConstTrue if the object being converted is regarded as const.

Implements DataBucketBase.

Definition at line 72 of file TypelessDataBucket.cxx.

75{
76 if (!isConst) return nullptr;
77 if (clid == m_clid) {
78 return m_object;
79 }
80
81 return m_bib.cast (m_object, clid);
82}

◆ cast() [3/4]

void * TypelessDataBucket::cast ( const std::type_info & tinfo,
SG::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
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.

Implements DataBucketBase.

Definition at line 93 of file TypelessDataBucket.cxx.

96{
97 if (!isConst) return nullptr;
98 return m_bib.cast (m_object, tinfo);
99}
virtual const std::type_info & tinfo() const override
Return the type_info for the stored object.

◆ cast() [4/4]

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

Make visible the template version from the base class.

◆ clID()

const CLID & TypelessDataBucket::clID ( ) const
overridevirtual

Return the CLID.

Definition at line 40 of file TypelessDataBucket.cxx.

41{
42 return m_clid;
43}

◆ lock()

void TypelessDataBucket::lock ( )
overridevirtual

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

Not implemented for this type.

Implements DataBucketBase.

Definition at line 117 of file TypelessDataBucket.cxx.

118{
119 // Not implemented.
120}

◆ object()

void * TypelessDataBucket::object ( )
overridevirtual

Return the pointer as a void*.

Implements DataBucketBase.

Definition at line 49 of file TypelessDataBucket.cxx.

50{
51 return m_object;
52}

◆ relinquish()

void TypelessDataBucket::relinquish ( )
overridevirtual

Give up ownership of the DataBucket contents.

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

Implements DataBucketBase.

Definition at line 106 of file TypelessDataBucket.cxx.

107{
108 m_object = nullptr;
109}

◆ tinfo()

const std::type_info & TypelessDataBucket::tinfo ( ) const
overridevirtual

Return the type_info for the stored object.

Implements DataBucketBase.

Definition at line 58 of file TypelessDataBucket.cxx.

59{
60 return m_bib.typeinfo();
61}

Member Data Documentation

◆ m_bib

const SG::BaseInfoBase& TypelessDataBucket::m_bib
private

Type information for the held object.

Definition at line 110 of file TypelessDataBucket.h.

◆ m_clid

CLID TypelessDataBucket::m_clid
private

CLID of the held object.

Definition at line 113 of file TypelessDataBucket.h.

◆ m_object

void* TypelessDataBucket::m_object
private

The held object.

Definition at line 107 of file TypelessDataBucket.h.


The documentation for this class was generated from the following files: