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 clid, SG::IRegisterTransient *irt, bool isConst) 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::Event & m_event
 The original Event object.

Detailed Description

Helper object for holding something through a THolder.

Definition at line 44 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 48 of file EventIProxyDict.cxx.

50 : 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 clid,
SG::IRegisterTransient * irt,
bool isConst )
inlineoverridevirtual

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

Implements DataBucketBase.

Definition at line 83 of file EventIProxyDict.cxx.

83 {
84
85 const SG::BaseInfoBase* bib = SG::BaseInfoBase::find (clid);
86 if (bib) {
87 return this->cast (bib->typeinfo(), irt, isConst);
88 }
89 throw std::runtime_error(std::format ("xAODPrivate::HolderBucket::cast cannot look up CLID {}", clid));
90 return 0;
91 }
static const BaseInfoBase * find(CLID clid)
Find the BaseInfoBase instance for clid.
Definition BaseInfo.cxx:587
const std::type_info & typeinfo() const
Return the std::type_info for this class.
Definition BaseInfo.cxx:154
void * cast(CLID clid, SG::IRegisterTransient *irt, bool isConst) override
Return the object, cast to a CLID's type.

◆ cast() [3/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 128 of file EventIProxyDict.cxx.

129 {
130 return HolderBucket::cast(tinfo, irt, isConst);
131 }
const std::type_info & tinfo() const override
Return the type_info of the stored object.

◆ 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 94 of file EventIProxyDict.cxx.

95 {
96
97 // Do the cast:
98 static constexpr bool SILENT = true;
99 static constexpr bool METADATA = false;
100 const void* result = nullptr;
101 if (isConst == false) {
102 // Just look among the outputs.
103 result = m_event.getOutputObject(m_key, tinfo, METADATA);
104 } else {
105 // Look among the output objects first:
106 result = m_event.getOutputObject(m_key, tinfo, METADATA);
107 // Check if it succeeded:
108 if (result == nullptr) {
109 // Try the input then:
110 result = m_event.getInputObject(m_key, tinfo, SILENT, METADATA);
111 } else {
112 // Even if there is an output object with this key, it may
113 // be an input object that was copied to the output. So let's
114 // try to silently retrieve an input object as well. This makes
115 // sure that the input/output object is updated for the current
116 // event.
117 m_event.getInputObject(m_key, tinfo, SILENT, METADATA);
118 }
119 }
120
121 // Return the pointer:
122 void* nc_result ATLAS_THREAD_SAFE =
123 const_cast<void*>(result); // DataBucketBase interface
124 return nc_result;
125 }
#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 136 of file EventIProxyDict.cxx.

136{}

◆ object()

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

Return the object held.

Implements DataBucketBase.

Definition at line 53 of file EventIProxyDict.cxx.

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

◆ relinquish()

void xAODPrivate::HolderBucket::relinquish ( )
inlineoverridevirtual

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

Implements DataBucketBase.

Definition at line 134 of file EventIProxyDict.cxx.

134{}

◆ tinfo()

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

Return the type_info of the stored object.

Implements DataBucketBase.

Definition at line 80 of file EventIProxyDict.cxx.

80{ return m_ti; }

Member Data Documentation

◆ m_event

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

The original Event object.

Definition at line 144 of file EventIProxyDict.cxx.

◆ m_key

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

The key of the object.

Definition at line 140 of file EventIProxyDict.cxx.

◆ m_ti

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

The type info of the object.

Definition at line 142 of file EventIProxyDict.cxx.


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