ATLAS Offline Software
Loading...
Searching...
No Matches
HLT::TypedHolder< FEATURE, CONTAINER > Class Template Reference

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

#include <TypedHolder.h>

Inheritance diagram for HLT::TypedHolder< FEATURE, CONTAINER >:
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

Public Member Functions

 TypedHolder (const BaseHolder &baseholder, const asg::EventStoreType *store, const std::string &container_name=ClassID_traits< CONTAINER >::typeName())
 constructor from BaseHolder.
 TypedHolder (const TypelessHolder &typeless, const asg::EventStoreType *store, const std::string &container_name=ClassID_traits< CONTAINER >::typeName())
 constructor from BaseHolder.
const std::string & key () const
 key used to access EventStore
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.
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.
virtual class_id_type typeClid () const
virtual const std::string & label () const
virtual sub_index_type subTypeIndex () const
virtual bool serialize (std::vector< uint32_t > &data) const
void setLevel (MSG::Level lvl)
 Change the current logging level.
Functions providing the same interface as AthMessaging
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.

Static Public Member Functions

static bool enquireSerialized (std::vector< uint32_t >::const_iterator &fromHere, const std::vector< uint32_t >::const_iterator &end, class_id_type &c, std::string &label, sub_index_type &subtypeIndex)

Protected Attributes

class_id_type m_clid
std::string m_label
sub_index_type m_sub

Private Member Functions

StatusCode syncWithStore ()
 cache container retrieved from StoreGate
 TypedHolder ()
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

const asg::EventStoreTypem_store = nullptr
const CONTAINER * m_cont = nullptr
std::string m_key
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

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

68 asg::AsgMessaging("TypedHolder"),
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");
74 }
doubly templated class interfacing access to feature containers in StoreGate.
Definition TypedHolder.h:55
const asg::EventStoreType * m_store
std::string m_key
const CONTAINER * m_cont
TypelessHolder(class_id_type clid, const std::string &label, sub_index_type sub)
virtual sub_index_type subTypeIndex() const
virtual class_id_type typeClid() const
virtual const std::string & label() const
std::string formatSGkey(const std::string &prefix, const std::string &containername, const std::string &label)
declaration of formatting function.
Definition Holder.cxx:121

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

81 asg::AsgMessaging("TypedHolder"),
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");
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

◆ enquireSerialized()

bool BaseHolder::enquireSerialized ( std::vector< uint32_t >::const_iterator & fromHere,
const std::vector< uint32_t >::const_iterator & end,
class_id_type & c,
std::string & label,
sub_index_type & subtypeIndex )
staticinherited

Definition at line 12 of file BaseHolder.cxx.

15 {
16 using namespace std;
17 if ( fromHere == end ) return false;
18
19 c = *fromHere++;
20 if ( fromHere == end ) return false;
21
22 subtypeIndex = *fromHere++;
23 if ( fromHere == end ) return false;
24
25 unsigned labelSize = *fromHere++;
26 if ( fromHere == end ) return false;
27 if ( fromHere+labelSize > end ) return false;
28
29 std::vector<uint32_t>::const_iterator stringEnd = fromHere+labelSize;
30 HLT::StringSerializer::deserialize(fromHere, stringEnd, label);
31
32 //advance iterator to end of label
33 std::advance(fromHere,labelSize);
34
35 return true;
36}
virtual const std::string & label() const =0
std::size_t deserialize(std::vector< uint32_t >::const_iterator first, std::vector< uint32_t >::const_iterator last, std::vector< std::string > &strings)

◆ 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
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());
125
126 // from now own we don't want anybody modifying the container
128 return StatusCode::SUCCESS;
129 }
#define ATH_MSG_ERROR(x)
const std::string & key() const
key used to access EventStore
Definition TypedHolder.h:92
StatusCode syncWithStore()
cache container retrieved from StoreGate

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

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ key()

template<typename FEATURE, typename CONTAINER>
const 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;}

◆ label()

virtual const std::string & HLT::TypelessHolder::label ( ) const
inlinevirtualinherited

Implements HLT::BaseHolder.

Definition at line 15 of file TypelessHolder.h.

15{ return m_label; }

◆ msg() [1/2]

MsgStream & asg::AsgMessaging::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 49 of file AsgMessaging.cxx.

49 {
50#ifndef XAOD_STANDALONE
51 return ::AthMessaging::msg();
52#else // not XAOD_STANDALONE
53 return m_msg;
54#endif // not XAOD_STANDALONE
55 }

◆ msg() [2/2]

MsgStream & asg::AsgMessaging::msg ( const MSG::Level lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 57 of file AsgMessaging.cxx.

57 {
58#ifndef XAOD_STANDALONE
59 return ::AthMessaging::msg( lvl );
60#else // not XAOD_STANDALONE
61 m_msg << lvl;
62 return m_msg;
63#endif // not XAOD_STANDALONE
64 }

◆ msgLvl()

bool asg::AsgMessaging::msgLvl ( const MSG::Level lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 41 of file AsgMessaging.cxx.

41 {
42#ifndef XAOD_STANDALONE
43 return ::AthMessaging::msgLvl( lvl );
44#else // not XAOD_STANDALONE
45 return m_msg.msgLevel( lvl );
46#endif // not XAOD_STANDALONE
47 }

◆ serialize()

bool BaseHolder::serialize ( std::vector< uint32_t > & data) const
virtualinherited

Reimplemented in HLTNavDetails::HolderImp< STORED, CONTAINER >, HLTNavDetails::IHolder, and HolderImp< STORED, CONTAINER >.

Definition at line 38 of file BaseHolder.cxx.

38 {
39 output.push_back( typeClid() );
40 output.push_back( subTypeIndex() );
41
42 const size_t labelSizeIndex = output.size();
43 output.push_back( 0 );
44 const size_t beforeSS = output.size();
46 output[labelSizeIndex] = output.size() - beforeSS;
47 return true;
48}
virtual class_id_type typeClid() const =0
virtual sub_index_type subTypeIndex() const =0
void serialize(const std::vector< std::string > &strings, std::vector< uint32_t > &storage)
output
Definition merge.py:16

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ subTypeIndex()

virtual sub_index_type HLT::TypelessHolder::subTypeIndex ( ) const
inlinevirtualinherited

Implements HLT::BaseHolder.

Definition at line 16 of file TypelessHolder.h.

16{ return m_sub; }
sub_index_type m_sub

◆ 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
162 StatusCode sc = m_store->retrieve(m_cont,key());
163
164 //sanity checks
165 if(sc.isFailure()) return StatusCode::FAILURE;
166 if(!m_cont) return StatusCode::FAILURE;
167
168 return StatusCode::SUCCESS;
169 }

◆ typeClid()

virtual class_id_type HLT::TypelessHolder::typeClid ( ) const
inlinevirtualinherited

Implements HLT::BaseHolder.

Definition at line 14 of file TypelessHolder.h.

14{ return m_clid; }
class_id_type m_clid

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_clid

class_id_type HLT::TypelessHolder::m_clid
protectedinherited

Definition at line 19 of file TypelessHolder.h.

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

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

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

std::string HLT::TypelessHolder::m_label
protectedinherited

Definition at line 20 of file TypelessHolder.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.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.

◆ m_sub

sub_index_type HLT::TypelessHolder::m_sub
protectedinherited

Definition at line 21 of file TypelessHolder.h.


The documentation for this class was generated from the following file: