ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
HLT::TypedHolder< FEATURE, CONTAINER > Class Template Reference

doubly templated class interfacing access to feature containers in StoreGate. More...

#include <TypedHolder.h>

Collaboration diagram for HLT::TypedHolder< FEATURE, CONTAINER >:

Public Types

template<typename T , bool value>
using StatusCode_if = typename std::enable_if< std::is_same< T, CONTAINER >::value==value, StatusCode >::type
 shorthand for enable_if with returning StatusCode base on comparison with CONTAINER type More...
 

Public Member Functions

 TypedHolder (const BaseHolder &baseholder, const asg::EventStoreType *store, const std::string &container_name=ClassID_traits< CONTAINER >::typeName())
 constructor from BaseHolder. More...
 
 TypedHolder (const TypelessHolder &typeless, const asg::EventStoreType *store, const std::string &container_name=ClassID_traits< CONTAINER >::typeName())
 constructor from BaseHolder. More...
 
std::string key () const
 key used to access EventStore More...
 
template<typename T >
StatusCode_if< T, true > get (const T *&destination, HLT::TriggerElement::ObjectIndex idx)
 method creates a new VIEW container containing pointers to the elements pointed to by the ObjectIndex. More...
 
template<typename T >
StatusCode_if< T, false > get (const T *&destination, HLT::TriggerElement::ObjectIndex idx)
 method retrieves container from storegated and returns pointer at passed ObjectIndex Only enabled for ELEMENT holders (i.e. More...
 

Private Member Functions

StatusCode syncWithStore ()
 cache container retrieved from StoreGate More...
 
 TypedHolder ()
 

Private Attributes

const asg::EventStoreTypem_store = nullptr
 
const CONTAINER * m_cont = nullptr
 
std::string m_key
 

Detailed Description

template<typename FEATURE, typename CONTAINER>
class HLT::TypedHolder< FEATURE, CONTAINER >

doubly templated class interfacing access to feature containers in StoreGate.

Definition at line 42 of file TypedHolder.h.

Member Typedef Documentation

◆ StatusCode_if

template<typename FEATURE , typename CONTAINER >
template<typename T , bool value>
using HLT::TypedHolder< FEATURE, CONTAINER >::StatusCode_if = typename std::enable_if<std::is_same<T,CONTAINER>::value == value,StatusCode>::type

shorthand for enable_if with returning StatusCode base on comparison with CONTAINER type

Definition at line 60 of file TypedHolder.h.

Constructor & Destructor Documentation

◆ TypedHolder() [1/3]

template<typename FEATURE , typename CONTAINER >
HLT::TypedHolder< FEATURE, CONTAINER >::TypedHolder ( const BaseHolder baseholder,
const asg::EventStoreType store,
const std::string &  container_name = ClassID_traits<CONTAINER>::typeName() 
)
inline

constructor from BaseHolder.

Throws runtime exception if clids of BaseHolder and FEATURE type don't match

Definition at line 66 of file TypedHolder.h.

67  : TypelessHolder(baseholder.typeClid(),baseholder.label(),baseholder.subTypeIndex()),
68  asg::AsgMessaging("TypedHolder"),
69  m_store(store),
70  m_cont(0) {
71  // if(!clidCheck<FEATURE>())
72  //throw std::runtime_error("attempted construction with CLID mismatch! Check template parameter and passed typeless holder");
73  m_key = HLTNavDetails::formatSGkey("HLT",container_name,this->label());
74  }

◆ TypedHolder() [2/3]

template<typename FEATURE , typename CONTAINER >
HLT::TypedHolder< FEATURE, CONTAINER >::TypedHolder ( const TypelessHolder typeless,
const asg::EventStoreType store,
const std::string &  container_name = ClassID_traits<CONTAINER>::typeName() 
)
inline

constructor from BaseHolder.

Throws runtime exception if clids of BaseHolder and FEATURE type don't match

Definition at line 79 of file TypedHolder.h.

80  : TypelessHolder(typeless),
81  asg::AsgMessaging("TypedHolder"),
82  m_store(store),
83  m_cont(0) {
84  //if(!clidCheck<FEATURE>())
85  // throw std::runtime_error("attempted construction with CLID mismatch! Check template parameter and passed typeless holder");
86  m_key = HLTNavDetails::formatSGkey("HLT",container_name,this->label());
87  }

◆ TypedHolder() [3/3]

template<typename FEATURE , typename CONTAINER >
HLT::TypedHolder< FEATURE, CONTAINER >::TypedHolder ( )
inlineprivate

Definition at line 171 of file TypedHolder.h.

171 {;}

Member Function Documentation

◆ get() [1/2]

template<typename FEATURE , typename CONTAINER >
template<typename T >
StatusCode_if<T,true> HLT::TypedHolder< FEATURE, CONTAINER >::get ( const T *&  destination,
HLT::TriggerElement::ObjectIndex  idx 
)
inline

method creates a new VIEW container containing pointers to the elements pointed to by the ObjectIndex.

Caller owns the VIEW container. Only enabled for CONTAINER holders

Definition at line 99 of file TypedHolder.h.

99  {
100  if(syncWithStore().isFailure()){
101  ATH_MSG_ERROR("accessing holder with key: " << key() << " sync with store failed ");
102  return StatusCode::FAILURE;
103  }
104  if(m_cont->size() < idx.objectsEnd()){
105  ATH_MSG_ERROR("accessing holder with key: " << key() << " index past range " << "idx range is: " << idx.objectsBegin() << ":" << idx.objectsEnd() << " container size: " << m_cont->size());
106  return StatusCode::FAILURE;
107  };
108 
109  // make sure we get a fresh pointer as were about to set it to a newly created one
110  if(destination){
111  //ATH_MSG_ERROR("reference pointe provided is already set");
112  return StatusCode::FAILURE;
113  }
114 
115  CONTAINER* nonConstDestination = new CONTAINER(SG::VIEW_ELEMENTS);
116 
117  // need to cast to be able to use non const iterators
118  CONTAINER* src = const_cast<CONTAINER*>(m_cont);
119  typename CONTAINER::iterator beg = src->begin();
120  typename CONTAINER::iterator end = src->begin();
121 
122  std::advance(beg, idx.objectsBegin());
123  std::advance(end, idx.objectsEnd());
124  nonConstDestination->insert(nonConstDestination->end(), beg, end);
125 
126  // from now own we don't want anybody modifying the container
127  destination = nonConstDestination;
128  return StatusCode::SUCCESS;
129  }

◆ get() [2/2]

template<typename FEATURE , typename CONTAINER >
template<typename T >
StatusCode_if<T,false> HLT::TypedHolder< FEATURE, CONTAINER >::get ( const T *&  destination,
HLT::TriggerElement::ObjectIndex  idx 
)
inline

method retrieves container from storegated and returns pointer at passed ObjectIndex Only enabled for ELEMENT holders (i.e.

non CONTAINER)

Definition at line 135 of file TypedHolder.h.

135  {
136  if((idx.objectsEnd() - idx.objectsBegin())!=1){
137  //ATH_MSG_ERROR("accessing holder with key: " << key() << "index is not single element: " << idx.objectsBegin() << ":" << idx.objectsEnd());
138  return StatusCode::FAILURE;
139  }
140  if(syncWithStore().isFailure()){
141  //ATH_MSG_ERROR("accessing holder with key: " << key() << " sync with store failed ");
142  return StatusCode::FAILURE;
143  }
144  if(m_cont->size() < idx.objectsBegin()){
145  //ATH_MSG_ERROR("accessing holder with key: " << key() << " index past range " << "indexBegin is: " << idx.objectsBegin() << " container size: " << m_cont->size() << std::endl;
146  return StatusCode::FAILURE;
147  };
148 
149  //everything went fine
150  destination = m_cont->at(idx.objectsBegin());
151  return StatusCode::SUCCESS;
152  }

◆ key()

template<typename FEATURE , typename CONTAINER >
std::string HLT::TypedHolder< FEATURE, CONTAINER >::key ( ) const
inline

key used to access EventStore

Definition at line 92 of file TypedHolder.h.

92 {return m_key;}

◆ syncWithStore()

template<typename FEATURE , typename CONTAINER >
StatusCode HLT::TypedHolder< FEATURE, CONTAINER >::syncWithStore ( )
inlineprivate

cache container retrieved from StoreGate

Definition at line 159 of file TypedHolder.h.

159  {
160  if(m_cont) return StatusCode::SUCCESS;
161 
163 
164  //sanity checks
165  if(sc.isFailure()) return StatusCode::FAILURE;
166  if(!m_cont) return StatusCode::FAILURE;
167 
168  return StatusCode::SUCCESS;
169  }

Member Data Documentation

◆ m_cont

template<typename FEATURE , typename CONTAINER >
const CONTAINER* HLT::TypedHolder< FEATURE, CONTAINER >::m_cont = nullptr
private

Definition at line 173 of file TypedHolder.h.

◆ m_key

template<typename FEATURE , typename CONTAINER >
std::string HLT::TypedHolder< FEATURE, CONTAINER >::m_key
private

Definition at line 174 of file TypedHolder.h.

◆ m_store

template<typename FEATURE , typename CONTAINER >
const asg::EventStoreType* HLT::TypedHolder< FEATURE, CONTAINER >::m_store = nullptr
private

Definition at line 172 of file TypedHolder.h.


The documentation for this class was generated from the following file:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
HLT::TypedHolder::m_key
std::string m_key
Definition: TypedHolder.h:174
HLTNavDetails::formatSGkey
std::string formatSGkey(const std::string &prefix, const std::string &containername, const std::string &label)
declaration of formatting function.
Definition: Holder.cxx:122
HLT::TypedHolder::m_store
const asg::EventStoreType * m_store
Definition: TypedHolder.h:172
HLT::TypedHolder::m_cont
const CONTAINER * m_cont
Definition: TypedHolder.h:173
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
HLT::TypedHolder::syncWithStore
StatusCode syncWithStore()
cache container retrieved from StoreGate
Definition: TypedHolder.h:159
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HLT::TypedHolder::key
std::string key() const
key used to access EventStore
Definition: TypedHolder.h:92
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69