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

#include <MetaCont.h>

Collaboration diagram for SG::ReadMetaHandle< 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

 ReadMetaHandle (const SG::ReadMetaHandleKey< T > &key)
 
 ReadMetaHandle (const SG::ReadMetaHandleKey< T > &key, const EventContext &ctx)
 
 ~ReadMetaHandle ()
 
const_pointer_type retrieve ()
 
const_pointer_type retrieve (const SG::SourceID &t)
 
const_pointer_type operator-> ()
 
const_pointer_type operator* ()
 
bool isValid ()
 

Private Member Functions

bool initMetaHandle ()
 

Private Attributes

SG::SourceID m_sid
 
const MetaCont< T > * m_cont {nullptr}
 
T * m_ent {nullptr}
 
const SG::ReadMetaHandleKey< T > & m_hkey
 

Detailed Description

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

Definition at line 21 of file MetaCont.h.

Member Typedef Documentation

◆ const_pointer_type

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

Definition at line 31 of file ReadMetaHandle.h.

◆ const_reference_type

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

Definition at line 33 of file ReadMetaHandle.h.

◆ pointer_type

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

Definition at line 30 of file ReadMetaHandle.h.

◆ reference_type

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

Definition at line 32 of file ReadMetaHandle.h.

Constructor & Destructor Documentation

◆ ReadMetaHandle() [1/2]

template<typename T >
SG::ReadMetaHandle< T >::ReadMetaHandle ( const SG::ReadMetaHandleKey< T > &  key)

Definition at line 65 of file ReadMetaHandle.h.

66  : ReadMetaHandle(key, Gaudi::Hive::currentContext())
67  {
68  }

◆ ReadMetaHandle() [2/2]

template<typename T >
SG::ReadMetaHandle< T >::ReadMetaHandle ( const SG::ReadMetaHandleKey< T > &  key,
const EventContext &  ctx 
)

Definition at line 73 of file ReadMetaHandle.h.

75  : m_sid( Atlas::getExtendedEventContext(ctx).proxy()->sourceID() )
76  , m_cont( key.getContainer() )
77  , m_hkey(key)
78  {
79  MsgStream msg(Athena::getMessageSvc(), "ReadMetaHandle");
80  if (ATH_UNLIKELY(!m_hkey.isInit())) {
81  msg << MSG::ERROR
82  << "ReadMetaHandleKey " << key.objKey() << " was not initialized"
83  << endmsg;
84  throw std::runtime_error("ReadMetaHandle: ReadMetaHandleKey was not initialized");
85  }
86 
87  if (ATH_UNLIKELY(m_cont == 0)) {
88  // Try to retrieve it
89  StoreGateSvc* ms = m_hkey.getStore();
90  MetaContBase* cb{nullptr};
91  if(ms->retrieve(cb, m_hkey.key()).isFailure()) {
92  msg << MSG::ERROR
93  << "can't retrieve " << m_hkey.fullKey()
94  << " via base class" << endmsg;
95  throw std::runtime_error("ReadCondHandle: ptr to CondCont<T> is zero");
96  }
97  else {
98  m_cont = dynamic_cast< MetaCont<T>* > (cb);
99  if(!m_cont) {
100  msg << MSG::ERROR
101  << "can't dcast MetaContBase to " << m_hkey.fullKey()
102  << endmsg;
103  throw std::runtime_error("ReadMetaHandle: ptr to MetaCont<T> is zero");
104  }
105  }
106  }
107  }

◆ ~ReadMetaHandle()

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

Definition at line 40 of file ReadMetaHandle.h.

40 {};

Member Function Documentation

◆ initMetaHandle()

template<typename T >
bool SG::ReadMetaHandle< T >::initMetaHandle
private

Definition at line 113 of file ReadMetaHandle.h.

114  {
115 
116  if (m_ent) return true;
117 
118  // Initialize sid from dbKey found at ReadMetaHandleKey initialize
119 // m_sid = m_hkey.dbKey(); ???? Do I need this ????
120 
121  if ( ATH_UNLIKELY(! m_cont->find(m_sid, m_ent)) ) {
122  std::ostringstream ost;
123  m_cont->list(ost);
124  MsgStream msg(Athena::getMessageSvc(), "ReadMetaHandle");
125  msg << MSG::ERROR
126  << "ReadMetaHandle:: could not find current SourceID "
127  << m_sid << " for key " << m_hkey.objKey() << "\n"
128  << ost.str() << endmsg;
129  m_ent = nullptr;
130  return false;
131  }
132 
133  return true;
134  }

◆ isValid()

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

Definition at line 182 of file ReadMetaHandle.h.

182  {
183 
184  return initMetaHandle();
185  }

◆ operator*()

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

Definition at line 46 of file ReadMetaHandle.h.

46 { return retrieve(); }

◆ operator->()

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

Definition at line 45 of file ReadMetaHandle.h.

45 { return retrieve(); }

◆ retrieve() [1/2]

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

Definition at line 140 of file ReadMetaHandle.h.

141  {
142 
143  if (m_ent == 0) {
144  if (!initMetaHandle()) {
145  return nullptr;
146  }
147  }
148 
149  return m_ent;
150  }

◆ retrieve() [2/2]

template<typename T >
const T * SG::ReadMetaHandle< T >::retrieve ( const SG::SourceID t)

Definition at line 156 of file ReadMetaHandle.h.

157  {
158  if (sid == m_sid) {
159  return retrieve();
160  }
161 
162  pointer_type obj(0);
163  if (! (m_cont->find(sid, obj) ) ) {
164  std::ostringstream ost;
165  m_cont->list(ost);
166  MsgStream msg(Athena::getMessageSvc(), "ReadMetaHandle");
167  msg << MSG::ERROR
168  << "ReadMetaHandle::retrieve() could not find SourceID "
169  << sid << " for key " << m_hkey.objKey() << "\n"
170  << ost.str()
171  << endmsg;
172  return nullptr;
173  }
174 
175  return obj;
176  }

Member Data Documentation

◆ m_cont

template<typename T >
const MetaCont<T>* SG::ReadMetaHandle< T >::m_cont {nullptr}
private

Definition at line 55 of file ReadMetaHandle.h.

◆ m_ent

template<typename T >
T* SG::ReadMetaHandle< T >::m_ent {nullptr}
private

Definition at line 56 of file ReadMetaHandle.h.

◆ m_hkey

template<typename T >
const SG::ReadMetaHandleKey<T>& SG::ReadMetaHandle< T >::m_hkey
private

Definition at line 58 of file ReadMetaHandle.h.

◆ m_sid

template<typename T >
SG::SourceID SG::ReadMetaHandle< T >::m_sid
private

Definition at line 54 of file ReadMetaHandle.h.


The documentation for this class was generated from the following files:
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
SG::ReadMetaHandle::m_sid
SG::SourceID m_sid
Definition: ReadMetaHandle.h:54
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
SG::ReadMetaHandle::initMetaHandle
bool initMetaHandle()
Definition: ReadMetaHandle.h:113
MetaContBase
Definition: MetaCont.h:24
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
MetaCont
Definition: MetaCont.h:48
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
SG::ReadMetaHandle::pointer_type
T * pointer_type
Definition: ReadMetaHandle.h:30
SG::ReadMetaHandle::m_cont
const MetaCont< T > * m_cont
Definition: ReadMetaHandle.h:55
SG::ReadMetaHandle::retrieve
const_pointer_type retrieve()
Definition: ReadMetaHandle.h:140
SG::ReadMetaHandle::ReadMetaHandle
ReadMetaHandle(const SG::ReadMetaHandleKey< T > &key)
Definition: ReadMetaHandle.h:65
SG::ReadMetaHandle::m_hkey
const SG::ReadMetaHandleKey< T > & m_hkey
Definition: ReadMetaHandle.h:58
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::ReadMetaHandle::m_ent
T * m_ent
Definition: ReadMetaHandle.h:56
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37