ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SG::ReadCondHandle< T > Class Template Reference

#include <ReadCondHandle.h>

Collaboration diagram for SG::ReadCondHandle< T >:

Public Types

typedef T * pointer_type
 
typedef const T * const_pointer_type
 
typedef T & reference_type
 
typedef const T & const_reference_type
 

Public Member Functions

 ReadCondHandle (const SG::ReadCondHandleKey< T > &key)
 
 ReadCondHandle (const SG::ReadCondHandleKey< T > &key, const EventContext &ctx)
 
 ~ReadCondHandle ()
 
const std::string & key () const
 
const DataObjID & fullKey () const
 
const_pointer_type retrieve ()
 
const_pointer_type retrieve (const EventIDBase &t)
 
const_pointer_type operator-> ()
 
const_pointer_type operator* ()
 
const_pointer_type cptr ()
 
bool isValid ()
 
bool isValid (const EventIDBase &t) const
 
bool range (EventIDRange &r)
 
bool range (const EventIDBase &t, EventIDRange &r) const
 
const EventIDRange & getRange ()
 
CondCont< T > * getCC ()
 

Private Member Functions

bool initCondHandle ()
 

Private Attributes

EventIDBase m_eid
 
CondCont< T > * m_cc {nullptr}
 
const T * m_obj { nullptr }
 
const EventIDRange * m_range { nullptr }
 
const SG::ReadCondHandleKey< T > & m_hkey
 

Detailed Description

template<typename T>
class SG::ReadCondHandle< T >

Definition at line 44 of file ReadCondHandle.h.

Member Typedef Documentation

◆ const_pointer_type

template<typename T >
typedef const T* SG::ReadCondHandle< T >::const_pointer_type

Definition at line 48 of file ReadCondHandle.h.

◆ const_reference_type

template<typename T >
typedef const T& SG::ReadCondHandle< T >::const_reference_type

Definition at line 50 of file ReadCondHandle.h.

◆ pointer_type

template<typename T >
typedef T* SG::ReadCondHandle< T >::pointer_type

Definition at line 47 of file ReadCondHandle.h.

◆ reference_type

template<typename T >
typedef T& SG::ReadCondHandle< T >::reference_type

Definition at line 49 of file ReadCondHandle.h.

Constructor & Destructor Documentation

◆ ReadCondHandle() [1/2]

template<typename T >
SG::ReadCondHandle< T >::ReadCondHandle ( const SG::ReadCondHandleKey< T > &  key)

Definition at line 95 of file ReadCondHandle.h.

95  :
96  ReadCondHandle(key, Gaudi::Hive::currentContext())
97  {
98  // cppcheck-suppress missingReturn; false positive
99  }

◆ ReadCondHandle() [2/2]

template<typename T >
SG::ReadCondHandle< T >::ReadCondHandle ( const SG::ReadCondHandleKey< T > &  key,
const EventContext &  ctx 
)

Definition at line 104 of file ReadCondHandle.h.

105  :
106  m_eid( ctx.eventID() ),
107  m_cc( key.getCC() ),
108  m_hkey(key)
109  {
110  try {
111  EventIDBase::number_type conditionsRun =
113  if (conditionsRun != EventIDBase::UNDEFNUM) {
114  m_eid.set_run_number (conditionsRun);
115  }
116  }
117  catch (const std::bad_any_cast& e) {
118  throw SG::ExcBadContext (ctx, key.objKey());
119  }
120 
121  if (ATH_UNLIKELY(!key.isInit())) {
122  throw SG::ExcUninitKey (key.clid(), key.key(), key.storeHandle().name(),
123  "", "ReadCond");
124  }
125 
126  if (ATH_UNLIKELY(m_cc == 0)) {
127  // try to retrieve it
128  StoreGateSvc* cs = m_hkey.getCS();
129  CondContBase *cb(nullptr);
130  if (cs->retrieve(cb, m_hkey.key()).isFailure()) {
131  throw SG::ExcNoCondCont (m_hkey.fullKey().key(), "Can't retrieve.");
132  } else {
133  m_cc = dynamic_cast< CondCont<T>* > (cb);
134  if (m_cc == 0) {
135  throw SG::ExcNoCondCont (m_hkey.fullKey().key(), "Can't dcast CondContBase.");
136  }
137  }
138  }
139  }

◆ ~ReadCondHandle()

template<typename T >
SG::ReadCondHandle< T >::~ReadCondHandle ( )
inline

Definition at line 57 of file ReadCondHandle.h.

57 {};

Member Function Documentation

◆ cptr()

template<typename T >
const_pointer_type SG::ReadCondHandle< T >::cptr ( )
inline

Definition at line 67 of file ReadCondHandle.h.

67 { return retrieve(); }

◆ fullKey()

template<typename T >
const DataObjID& SG::ReadCondHandle< T >::fullKey ( ) const
inline

Definition at line 60 of file ReadCondHandle.h.

60 { return m_hkey.fullKey(); }

◆ getCC()

template<typename T >
CondCont<T>* SG::ReadCondHandle< T >::getCC ( )
inline

Definition at line 77 of file ReadCondHandle.h.

77 { return m_cc; }

◆ getRange()

template<typename T >
const EventIDRange & SG::ReadCondHandle< T >::getRange

Definition at line 242 of file ReadCondHandle.h.

242  {
243 
244  if (m_obj == 0) {
245  if (!initCondHandle()) {
247  }
248  }
249 
250  if (!m_range) {
251  throw SG::ExcNoRange();
252  }
253  return *m_range;
254 
255  }

◆ initCondHandle()

template<typename T >
bool SG::ReadCondHandle< T >::initCondHandle
private

Definition at line 145 of file ReadCondHandle.h.

145  {
146 
147  if (m_obj != 0) return true;
148 
149  if ( ATH_UNLIKELY(!m_cc->find(m_eid, m_obj, &m_range)) ) {
150  ReadCondHandleNotFound (*m_cc, m_eid, m_hkey.objKey());
151  m_obj = nullptr;
152  return false;
153  }
154 
155  return true;
156  }

◆ isValid() [1/2]

template<typename T >
bool SG::ReadCondHandle< T >::isValid

Definition at line 206 of file ReadCondHandle.h.

206  {
207 
208  return initCondHandle();
209  }

◆ isValid() [2/2]

template<typename T >
bool SG::ReadCondHandle< T >::isValid ( const EventIDBase &  t) const

Definition at line 215 of file ReadCondHandle.h.

215  {
216 
217  return (m_cc->valid(t));
218  }

◆ key()

template<typename T >
const std::string& SG::ReadCondHandle< T >::key ( ) const
inline

Definition at line 59 of file ReadCondHandle.h.

59 { return m_hkey.key(); }

◆ operator*()

template<typename T >
const_pointer_type SG::ReadCondHandle< T >::operator* ( )
inline

Definition at line 66 of file ReadCondHandle.h.

66 { return retrieve(); }

◆ operator->()

template<typename T >
const_pointer_type SG::ReadCondHandle< T >::operator-> ( )
inline

Definition at line 65 of file ReadCondHandle.h.

65 { return retrieve(); }

◆ range() [1/2]

template<typename T >
bool SG::ReadCondHandle< T >::range ( const EventIDBase &  t,
EventIDRange &  r 
) const

Definition at line 262 of file ReadCondHandle.h.

262  {
263 
264  return ( m_cc->range(eid, r) );
265  }

◆ range() [2/2]

template<typename T >
bool SG::ReadCondHandle< T >::range ( EventIDRange &  r)

Definition at line 224 of file ReadCondHandle.h.

224  {
225 
226  if (m_obj == 0) {
227  if (!initCondHandle()) {
228  return false;
229  }
230  }
231 
232  if (m_range) {
233  r = *m_range;
234  return true;
235  }
236 
237  return false;
238  }

◆ retrieve() [1/2]

template<typename T >
const T * SG::ReadCondHandle< T >::retrieve

Definition at line 162 of file ReadCondHandle.h.

162  {
163 
164  if (m_obj == 0) {
165  if (!initCondHandle()) {
166  // std::ostringstream ost;
167  // m_cc->list(ost);
168  // MsgStream msg(Athena::getMessageSvc(), "ReadCondHandle");
169  // msg << MSG::ERROR
170  // << "ReadCondHandle::retrieve() could not find EventTime "
171  // << m_eid << " for key " << objKey() << "\n"
172  // << ost.str()
173  // << endmsg;
174  return nullptr;
175  }
176  }
177 
178  return m_obj;
179  }

◆ retrieve() [2/2]

template<typename T >
const T * SG::ReadCondHandle< T >::retrieve ( const EventIDBase &  t)

Definition at line 185 of file ReadCondHandle.h.

185  {
186  if (eid == m_eid) {
187  return retrieve();
188  }
189 
190  // pointer_type obj(0);
191  const_pointer_type cobj(0);
192  if (! (m_cc->find(eid, cobj) ) ) {
193  ReadCondHandleNotFound (*m_cc, eid, m_hkey.objKey());
194  return nullptr;
195  }
196 
197  // const_pointer_type cobj = const_cast<const_pointer_type>( obj );
198 
199  return cobj;
200  }

Member Data Documentation

◆ m_cc

template<typename T >
CondCont<T>* SG::ReadCondHandle< T >::m_cc {nullptr}
private

Definition at line 84 of file ReadCondHandle.h.

◆ m_eid

template<typename T >
EventIDBase SG::ReadCondHandle< T >::m_eid
private

Definition at line 83 of file ReadCondHandle.h.

◆ m_hkey

template<typename T >
const SG::ReadCondHandleKey<T>& SG::ReadCondHandle< T >::m_hkey
private

Definition at line 88 of file ReadCondHandle.h.

◆ m_obj

template<typename T >
const T* SG::ReadCondHandle< T >::m_obj { nullptr }
private

Definition at line 85 of file ReadCondHandle.h.

◆ m_range

template<typename T >
const EventIDRange* SG::ReadCondHandle< T >::m_range { nullptr }
private

Definition at line 86 of file ReadCondHandle.h.


The documentation for this class was generated from the following file:
SG::ReadCondHandle::m_range
const EventIDRange * m_range
Definition: ReadCondHandle.h:86
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
beamspotman.r
def r
Definition: beamspotman.py:676
SG::ExcBadContext
Exception — Bad EventContext extension while building ReadCondHandle.
Definition: Control/StoreGate/StoreGate/exceptions.h:312
Atlas::ExtendedEventContext::conditionsRun
EventIDBase::number_type conditionsRun() const
Definition: ExtendedEventContext.h:38
AtlasMcWeight::number_type
unsigned int number_type
Definition: AtlasMcWeight.h:20
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::ExcBadReadCondHandleInit
Exception — ReadCondHandle didn't initialize in getRange().
Definition: Control/StoreGate/StoreGate/exceptions.h:346
SG::ReadCondHandleNotFound
void ReadCondHandleNotFound(const CondContBase &cc, const EventIDBase &eid, const std::string &key)
Report a conditions container lookup failure.
Definition: ReadCondHandle.cxx:23
SG::ExcNoRange
Exception — Range not set in ReadCondHandle::getRange().
Definition: Control/StoreGate/StoreGate/exceptions.h:360
SG::ExcNoCondCont
Exception — Can't retrieve CondCont from ReadCondHandle.
Definition: Control/StoreGate/StoreGate/exceptions.h:330
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
SG::ReadCondHandle::m_hkey
const SG::ReadCondHandleKey< T > & m_hkey
Definition: ReadCondHandle.h:88
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
SG::ReadCondHandle::retrieve
const_pointer_type retrieve()
Definition: ReadCondHandle.h:162
SG::ReadCondHandle::m_obj
const T * m_obj
Definition: ReadCondHandle.h:85
SG::ReadCondHandle::ReadCondHandle
ReadCondHandle(const SG::ReadCondHandleKey< T > &key)
Definition: ReadCondHandle.h:95
CondContBase
Base class for all conditions containers.
Definition: CondCont.h:140
SG::ReadCondHandle::initCondHandle
bool initCondHandle()
Definition: ReadCondHandle.h:145
CondCont
Hold mapping of ranges to condition objects.
Definition: CondCont.h:811
SG::ExcUninitKey
Exception — Tried to create a handle from an uninitialized key.
Definition: Control/StoreGate/StoreGate/exceptions.h:111
SG::ReadCondHandle::const_pointer_type
const T * const_pointer_type
Definition: ReadCondHandle.h:48
SG::ReadCondHandle::m_eid
EventIDBase m_eid
Definition: ReadCondHandle.h:83
SG::ReadCondHandle::m_cc
CondCont< T > * m_cc
Definition: ReadCondHandle.h:84
SG::ReadCondHandle::key
const std::string & key() const
Definition: ReadCondHandle.h:59