ATLAS Offline Software
Loading...
Searching...
No Matches
xAODPrivate::HolderBucket Class Reference

Helper object for holding something through a THolder. More...

Inheritance diagram for xAODPrivate::HolderBucket:
Collaboration diagram for xAODPrivate::HolderBucket:

Public Member Functions

 HolderBucket (const std::string &key, const std::type_info &ti, xAOD::Event &event)
 Constructor with an existing holder.
void * object () override
 Return the object held.
const std::type_info & tinfo () const override
 Return the type_info of the stored object.
void * cast (CLID, SG::IRegisterTransient *, bool) override
 Return the object, cast to a CLID's type.
void * cast (const std::type_info &tinfo, SG::IRegisterTransient *, bool isConst) override
 Return the object, cast to a certain type.
void * cast (CLID, const std::type_info &tinfo, SG::IRegisterTransient *irt, bool isConst) override
 Return the object, cast to type.
void relinquish () override
 Give up ownership of the bucket's contents. A no-op.
void lock () override
 Lock the held object. A no-op.
template<class T>
T * cast (SG::IRegisterTransient *irt=0, bool isConst=true)
 Return the contents of the DataBucket, converted to type T.

Private Attributes

const std::string m_key
 The key of the object.
const std::type_info & m_ti
 The type info of the object.
xAOD::Eventm_event
 The original Event object.

Detailed Description

Helper object for holding something through a THolder.

Definition at line 42 of file EventIProxyDict.cxx.

Constructor & Destructor Documentation

◆ HolderBucket()

xAODPrivate::HolderBucket::HolderBucket ( const std::string & key,
const std::type_info & ti,
xAOD::Event & event )
inline

Constructor with an existing holder.

Definition at line 46 of file EventIProxyDict.cxx.

48 : m_key(key), m_ti(ti), m_event(event) {}
const std::type_info & m_ti
The type info of the object.
const std::string m_key
The key of the object.
xAOD::Event & m_event
The original Event object.

Member Function Documentation

◆ cast() [1/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.

◆ cast() [2/4]

void * xAODPrivate::HolderBucket::cast ( CLID ,
const std::type_info & tinfo,
SG::IRegisterTransient * irt,
bool isConst )
inlineoverridevirtual

Return the object, cast to type.

Reimplemented from DataBucketBase.

Definition at line 122 of file EventIProxyDict.cxx.

123 {
124 return HolderBucket::cast(tinfo, irt, isConst);
125 }
const std::type_info & tinfo() const override
Return the type_info of the stored object.
void * cast(CLID, SG::IRegisterTransient *, bool) override
Return the object, cast to a CLID's type.

◆ cast() [3/4]

void * xAODPrivate::HolderBucket::cast ( CLID ,
SG::IRegisterTransient * ,
bool  )
inlineoverridevirtual

Return the object, cast to a CLID's type.

Implements DataBucketBase.

Definition at line 81 of file EventIProxyDict.cxx.

81 {
82
83 throw std::runtime_error("xAODPrivate::HolderBucket::cast not implemented");
84 return 0;
85 }

◆ cast() [4/4]

void * xAODPrivate::HolderBucket::cast ( const std::type_info & tinfo,
SG::IRegisterTransient * ,
bool isConst )
inlineoverridevirtual

Return the object, cast to a certain type.

Implements DataBucketBase.

Definition at line 88 of file EventIProxyDict.cxx.

89 {
90
91 // Do the cast:
92 static constexpr bool SILENT = true;
93 static constexpr bool METADATA = false;
94 const void* result = nullptr;
95 if (isConst == false) {
96 // Just look among the outputs.
97 result = m_event.getOutputObject(m_key, tinfo, METADATA);
98 } else {
99 // Look among the output objects first:
100 result = m_event.getOutputObject(m_key, tinfo, METADATA);
101 // Check if it succeeded:
102 if (result == nullptr) {
103 // Try the input then:
104 result = m_event.getInputObject(m_key, tinfo, SILENT, METADATA);
105 } else {
106 // Even if there is an output object with this key, it may
107 // be an input object that was copied to the output. So let's
108 // try to silently retrieve an input object as well. This makes
109 // sure that the input/output object is updated for the current
110 // event.
111 m_event.getInputObject(m_key, tinfo, SILENT, METADATA);
112 }
113 }
114
115 // Return the pointer:
116 void* nc_result ATLAS_THREAD_SAFE =
117 const_cast<void*>(result); // DataBucketBase interface
118 return nc_result;
119 }
#define ATLAS_THREAD_SAFE
@ SILENT
don't print anything and return success

◆ lock()

void xAODPrivate::HolderBucket::lock ( )
inlineoverridevirtual

Lock the held object. A no-op.

Implements DataBucketBase.

Definition at line 130 of file EventIProxyDict.cxx.

130{}

◆ object()

void * xAODPrivate::HolderBucket::object ( )
inlineoverridevirtual

Return the object held.

Implements DataBucketBase.

Definition at line 51 of file EventIProxyDict.cxx.

51 {
52
53 // Look among the output objects first:
54 static constexpr bool METADATA = false;
55 const void* result = m_event.getOutputObject(m_key, m_ti, METADATA);
56 // Check if it succeeded:
57 static constexpr bool SILENT = false;
58 if (!result) {
59 // Try the input then:
60 result = m_event.getInputObject(m_key, m_ti, SILENT, METADATA);
61 } else {
62 // Even if there is an output object with this key, it may
63 // be an input object that was copied to the output. So let's
64 // try to silently retrieve an input object as well. This makes
65 // sure that the input/output object is updated for the current
66 // event.
67 static constexpr bool SILENT = false;
68 m_event.getInputObject(m_key, m_ti, SILENT, METADATA);
69 }
70
71 // Return the pointer:
72 void* nc_result ATLAS_THREAD_SAFE =
73 const_cast<void*>(result); // DataBucketBase interface
74 return nc_result;
75 }

◆ relinquish()

void xAODPrivate::HolderBucket::relinquish ( )
inlineoverridevirtual

Give up ownership of the bucket's contents. A no-op.

Implements DataBucketBase.

Definition at line 128 of file EventIProxyDict.cxx.

128{}

◆ tinfo()

const std::type_info & xAODPrivate::HolderBucket::tinfo ( ) const
inlineoverridevirtual

Return the type_info of the stored object.

Implements DataBucketBase.

Definition at line 78 of file EventIProxyDict.cxx.

78{ return m_ti; }

Member Data Documentation

◆ m_event

xAOD::Event& xAODPrivate::HolderBucket::m_event
private

The original Event object.

Definition at line 138 of file EventIProxyDict.cxx.

◆ m_key

const std::string xAODPrivate::HolderBucket::m_key
private

The key of the object.

Definition at line 134 of file EventIProxyDict.cxx.

◆ m_ti

const std::type_info& xAODPrivate::HolderBucket::m_ti
private

The type info of the object.

Definition at line 136 of file EventIProxyDict.cxx.


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