ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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. More...
 
void * object () override
 Return the object held. More...
 
const std::type_info & tinfo () const override
 Return the type_info of the stored object. More...
 
void * cast (CLID, SG::IRegisterTransient *, bool) override
 Return the object, cast to a CLID's type. More...
 
void * cast (const std::type_info &tinfo, SG::IRegisterTransient *, bool isConst) override
 Return the object, cast to a certain type. More...
 
void * cast (CLID, const std::type_info &tinfo, SG::IRegisterTransient *irt, bool isConst) override
 Return the object, cast to type. More...
 
void relinquish () override
 Give up ownership of the bucket's contents. A no-op. More...
 
void lock () override
 Lock the held object. A no-op. More...
 
template<class T >
T * cast (SG::IRegisterTransient *irt=0, bool isConst=true)
 Return the contents of the DataBucket, converted to type T. More...
 

Private Attributes

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

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) {}

Member Function Documentation

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

◆ cast() [2/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() [3/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 = true;
94  const void* result = 0;
95  if (isConst == false) {
96  // Just look among the outputs.
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) {
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  }

◆ 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.

◆ 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:
xAODPrivate::HolderBucket::cast
void * cast(CLID, SG::IRegisterTransient *, bool) override
Return the object, cast to a CLID's type.
Definition: EventIProxyDict.cxx:81
get_generator_info.result
result
Definition: get_generator_info.py:21
xAODPrivate::HolderBucket::tinfo
const std::type_info & tinfo() const override
Return the type_info of the stored object.
Definition: EventIProxyDict.cxx:78
CP::OutOfValidityAction::SILENT
@ SILENT
don't print anything and return success
xAODPrivate::HolderBucket::m_event
xAOD::Event & m_event
The original Event object.
Definition: EventIProxyDict.cxx:138
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
xAODPrivate::HolderBucket::m_ti
const std::type_info & m_ti
The type info of the object.
Definition: EventIProxyDict.cxx:136
xAOD::Event::getOutputObject
void * getOutputObject(SG::sgkey_t key, const std::type_info &ti) override
Function for retrieving an output object in a non-template way.
Definition: EventTVirtualEvent.cxx:138
xAOD::Event::getInputObject
const void * getInputObject(SG::sgkey_t key, const std::type_info &ti, bool silent) override
Function for retrieving an input object in a non-template way.
Definition: EventTVirtualEvent.cxx:162
xAODPrivate::HolderBucket::m_key
const std::string m_key
The key of the object.
Definition: EventIProxyDict.cxx:134
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37