ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
xAODPrivate::THolderBucket Class Reference

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

Inheritance diagram for xAODPrivate::THolderBucket:
Collaboration diagram for xAODPrivate::THolderBucket:

Public Member Functions

 THolderBucket (const std::string &key, const std::type_info &ti, xAOD::TEvent &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::TEventm_event
 The original TEvent object. More...
 

Detailed Description

Helper object for holding something through a THolder.

Definition at line 46 of file TEventProxyDict.cxx.

Constructor & Destructor Documentation

◆ THolderBucket()

xAODPrivate::THolderBucket::THolderBucket ( const std::string &  key,
const std::type_info &  ti,
xAOD::TEvent event 
)
inline

Constructor with an existing holder.

Definition at line 50 of file TEventProxyDict.cxx.

53  : m_key( key ), m_ti( ti ), m_event( event ) {}

Member Function Documentation

◆ cast() [1/4]

void* xAODPrivate::THolderBucket::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 126 of file TEventProxyDict.cxx.

130  {
131  return THolderBucket::cast (tinfo, irt, isConst);
132  }

◆ cast() [2/4]

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

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

Implements DataBucketBase.

Definition at line 85 of file TEventProxyDict.cxx.

86  {
87 
88  throw std::runtime_error( "THolderBucket::cast not implemented" );
89  return 0;
90  }

◆ cast() [3/4]

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

Return the object, cast to a certain type.

Implements DataBucketBase.

Definition at line 93 of file TEventProxyDict.cxx.

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

◆ 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::THolderBucket::lock ( )
inlineoverridevirtual

Lock the held object. A no-op.

Implements DataBucketBase.

Definition at line 137 of file TEventProxyDict.cxx.

137 {}

◆ object()

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

Return the object held.

Implements DataBucketBase.

Definition at line 56 of file TEventProxyDict.cxx.

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

◆ relinquish()

void xAODPrivate::THolderBucket::relinquish ( )
inlineoverridevirtual

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

Implements DataBucketBase.

Definition at line 135 of file TEventProxyDict.cxx.

135 {}

◆ tinfo()

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

Return the type_info of the stored object.

Implements DataBucketBase.

Definition at line 79 of file TEventProxyDict.cxx.

79  {
80 
81  return m_ti;
82  }

Member Data Documentation

◆ m_event

xAOD::TEvent& xAODPrivate::THolderBucket::m_event
private

The original TEvent object.

Definition at line 145 of file TEventProxyDict.cxx.

◆ m_key

const std::string xAODPrivate::THolderBucket::m_key
private

The key of the object.

Definition at line 141 of file TEventProxyDict.cxx.

◆ m_ti

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

The type info of the object.

Definition at line 143 of file TEventProxyDict.cxx.


The documentation for this class was generated from the following file:
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::TEvent::getInputObject
const void * getInputObject(SG::sgkey_t key, const std::type_info &ti, bool silent=false) override
Function for retrieving an input object in a non-template way.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1938
xAOD::TEvent::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: Control/xAODRootAccess/Root/TEvent.cxx:1914
xAODPrivate::THolderBucket::tinfo
const std::type_info & tinfo() const override
Return the type_info of the stored object.
Definition: TEventProxyDict.cxx:79
xAODPrivate::THolderBucket::cast
void * cast(CLID, SG::IRegisterTransient *, bool) override
Return the object, cast to a CLID's type.
Definition: TEventProxyDict.cxx:85
xAODPrivate::THolderBucket::m_key
const std::string m_key
The key of the object.
Definition: TEventProxyDict.cxx:141
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
xAODPrivate::THolderBucket::m_ti
const std::type_info & m_ti
The type info of the object.
Definition: TEventProxyDict.cxx:143
xAODPrivate::THolderBucket::m_event
xAOD::TEvent & m_event
The original TEvent object.
Definition: TEventProxyDict.cxx:145
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37