The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
EventContext Class Reference

This class represents an entry point to all the event specific data. More...

#include <GaudiKernel/EventContext.h>

Collaboration diagram for EventContext:

Public Types

using ContextID_t = size_t
 
using ContextEvt_t = size_t
 

Public Member Functions

 EventContext ()=default
 
 EventContext (const ContextEvt_t e, const ContextID_t s=INVALID_CONTEXT_ID, const ContextID_t subSlot=INVALID_CONTEXT_ID)
 
ContextEvt_t evt () const
 
ContextID_t slot () const
 
ContextID_t subSlot () const
 
bool usesSubSlot () const
 
bool valid () const
 
const EventIDBaseeventID () const
 
void set (const ContextEvt_t e=0, const ContextID_t s=INVALID_CONTEXT_ID, const ContextID_t subSlot=INVALID_CONTEXT_ID)
 
void setEvt (const ContextEvt_t e)
 
void setSlot (const ContextID_t s)
 
void setSubSlot (const ContextID_t subslot)
 
void setValid (const bool b=true)
 
void setEventID (const EventIDBase &e)
 
template<typename ValueType, typename... Args>
auto & emplaceExtension (Args &&... args)
 
template<typename T>
auto & setExtension (T &&t)
 
void resetExtension ()
 
std::any detachExtension ()
 
template<typename T>
auto & getExtension ()
 
template<typename T>
const auto & getExtension () const
 
template<typename T>
T * tryGetExtension () noexcept
 
template<typename T>
const T * tryGetExtension () const noexcept
 
bool hasExtension () const
 
template<typename T>
bool hasExtension () const
 
const std::type_info & getExtensionType () const
 

Static Public Attributes

static constexpr ContextID_t INVALID_CONTEXT_ID = std::numeric_limits<ContextID_t>::max()
 
static constexpr ContextEvt_t INVALID_CONTEXT_EVT = std::numeric_limits<ContextEvt_t>::max()
 

Private Attributes

EventIDBase m_eid {}
 
ContextEvt_t m_evt_num { INVALID_CONTEXT_EVT }
 
ContextID_t m_evt_slot { INVALID_CONTEXT_ID }
 
ContextID_t m_sub_slot { INVALID_CONTEXT_ID }
 
bool m_valid { false }
 
std::any m_extension
 

Friends

std::ostream & operator<< (std::ostream &os, const EventContext &ctx)
 
std::ostream & operator<< (std::ostream &os, const EventContext *ctx)
 

Detailed Description

This class represents an entry point to all the event specific data.

It is needed to make the algorithm "aware" of the event it is operating on. This was not needed in the serial version of Gaudi where the assumption of 1-event-at-the-time processing was implicit.

This class has nothing to do with the AlgContextSvc or the Context of the EvtSelector!

Author
Danilo Piparo, Charles Leggett
Date
2012

Definition at line 34 of file EventContext.h.

Member Typedef Documentation

◆ ContextEvt_t

Definition at line 37 of file EventContext.h.

◆ ContextID_t

using EventContext::ContextID_t = size_t

Definition at line 36 of file EventContext.h.

Constructor & Destructor Documentation

◆ EventContext() [1/2]

EventContext::EventContext ( )
default

◆ EventContext() [2/2]

EventContext::EventContext ( const ContextEvt_t e,
const ContextID_t s = INVALID_CONTEXT_ID,
const ContextID_t subSlot = INVALID_CONTEXT_ID )
inlineexplicit

Definition at line 44 of file EventContext.h.

46 : m_evt_num( e ), m_evt_slot( s ), m_sub_slot( subSlot ) {
48 }
ContextID_t subSlot() const
ContextID_t m_sub_slot
ContextID_t m_evt_slot
static constexpr ContextEvt_t INVALID_CONTEXT_EVT
ContextEvt_t m_evt_num
static constexpr ContextID_t INVALID_CONTEXT_ID

Member Function Documentation

◆ detachExtension()

std::any EventContext::detachExtension ( )
inline

Definition at line 100 of file EventContext.h.

100{ return std::move( m_extension ); }
std::any m_extension

◆ emplaceExtension()

template<typename ValueType, typename... Args>
auto & EventContext::emplaceExtension ( Args &&... args)
inline

Definition at line 88 of file EventContext.h.

88 {
89 return m_extension.emplace<ValueType>( std::forward<Args>( args )... );
90 }

◆ eventID()

const EventIDBase & EventContext::eventID ( ) const
inline

Definition at line 55 of file EventContext.h.

55{ return m_eid; }
EventIDBase m_eid

◆ evt()

ContextEvt_t EventContext::evt ( ) const
inline

Definition at line 50 of file EventContext.h.

50{ return m_evt_num; }

◆ getExtension() [1/2]

template<typename T>
auto & EventContext::getExtension ( )
inline

Definition at line 103 of file EventContext.h.

103 {
104 return std::any_cast<std::decay_t<T>&>( m_extension );
105 }

◆ getExtension() [2/2]

template<typename T>
const auto & EventContext::getExtension ( ) const
inline

Definition at line 108 of file EventContext.h.

108 {
109 return std::any_cast<std::decay_t<T> const&>( m_extension );
110 }

◆ getExtensionType()

const std::type_info & EventContext::getExtensionType ( ) const
inline

Definition at line 129 of file EventContext.h.

129{ return m_extension.type(); }

◆ hasExtension() [1/2]

bool EventContext::hasExtension ( ) const
inline

Definition at line 122 of file EventContext.h.

122{ return m_extension.has_value(); }

◆ hasExtension() [2/2]

template<typename T>
bool EventContext::hasExtension ( ) const
inline

Definition at line 125 of file EventContext.h.

125 {
126 return hasExtension() && m_extension.type() == typeid( std::decay_t<T> );
127 }
bool hasExtension() const

◆ resetExtension()

void EventContext::resetExtension ( )
inline

Definition at line 98 of file EventContext.h.

98{ m_extension.reset(); }

◆ set()

void EventContext::set ( const ContextEvt_t e = 0,
const ContextID_t s = INVALID_CONTEXT_ID,
const ContextID_t subSlot = INVALID_CONTEXT_ID )
inline

Definition at line 57 of file EventContext.h.

58 {
60 m_evt_num = e;
61 m_evt_slot = s;
63 }

◆ setEventID()

void EventContext::setEventID ( const EventIDBase & e)
inline

Definition at line 85 of file EventContext.h.

85{ m_eid = e; }

◆ setEvt()

void EventContext::setEvt ( const ContextEvt_t e)
inline

Definition at line 65 of file EventContext.h.

65 {
66 if ( e == INVALID_CONTEXT_EVT ) setValid( false );
67 m_evt_num = e;
68 }
void setValid(const bool b=true)

◆ setExtension()

template<typename T>
auto & EventContext::setExtension ( T && t)
inline

Definition at line 93 of file EventContext.h.

93 {
94 m_extension = std::forward<T>( t );
95 return getExtension<T>();
96 }
auto & getExtension()

◆ setSlot()

void EventContext::setSlot ( const ContextID_t s)
inline

Definition at line 70 of file EventContext.h.

70 {
71 if ( s == INVALID_CONTEXT_ID ) setValid( false );
72 m_evt_slot = s;
73 }

◆ setSubSlot()

void EventContext::setSubSlot ( const ContextID_t subslot)
inline

Definition at line 75 of file EventContext.h.

75{ m_sub_slot = subslot; }

◆ setValid()

void EventContext::setValid ( const bool b = true)
inline

Definition at line 77 of file EventContext.h.

77 {
78 m_valid = b;
79 if ( !m_valid ) {
82 }
83 }

◆ slot()

ContextID_t EventContext::slot ( ) const
inline

Definition at line 51 of file EventContext.h.

51{ return m_evt_slot; }

◆ subSlot()

ContextID_t EventContext::subSlot ( ) const
inline

Definition at line 52 of file EventContext.h.

52{ return m_sub_slot; }

◆ tryGetExtension() [1/2]

template<typename T>
const T * EventContext::tryGetExtension ( ) const
inlinenoexcept

Definition at line 118 of file EventContext.h.

118 {
119 return std::any_cast<T>( &m_extension );
120 }

◆ tryGetExtension() [2/2]

template<typename T>
T * EventContext::tryGetExtension ( )
inlinenoexcept

Definition at line 113 of file EventContext.h.

113 {
114 return std::any_cast<T>( &m_extension );
115 }

◆ usesSubSlot()

bool EventContext::usesSubSlot ( ) const
inline

Definition at line 53 of file EventContext.h.

53{ return m_sub_slot != INVALID_CONTEXT_ID; }

◆ valid()

bool EventContext::valid ( ) const
inline

Definition at line 54 of file EventContext.h.

54{ return m_valid; }

Friends And Related Symbol Documentation

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & os,
const EventContext & ctx )
friend

Definition at line 13 of file EventContext.cpp.

13{ return os << fmt::format( "{}", ctx ); }

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & os,
const EventContext * ctx )
friend

Definition at line 15 of file EventContext.cpp.

15 {
16 if ( c ) { return os << fmt::format( "{}", *c ); }
17 return os << "INVALID";
18}

Member Data Documentation

◆ INVALID_CONTEXT_EVT

ContextEvt_t EventContext::INVALID_CONTEXT_EVT = std::numeric_limits<ContextEvt_t>::max()
staticconstexpr

Definition at line 40 of file EventContext.h.

◆ INVALID_CONTEXT_ID

ContextID_t EventContext::INVALID_CONTEXT_ID = std::numeric_limits<ContextID_t>::max()
staticconstexpr

Definition at line 39 of file EventContext.h.

◆ m_eid

EventIDBase EventContext::m_eid {}
private

Definition at line 135 of file EventContext.h.

135{};

◆ m_evt_num

ContextEvt_t EventContext::m_evt_num { INVALID_CONTEXT_EVT }
private

Definition at line 136 of file EventContext.h.

◆ m_evt_slot

ContextID_t EventContext::m_evt_slot { INVALID_CONTEXT_ID }
private

Definition at line 137 of file EventContext.h.

◆ m_extension

std::any EventContext::m_extension
private

Definition at line 141 of file EventContext.h.

◆ m_sub_slot

ContextID_t EventContext::m_sub_slot { INVALID_CONTEXT_ID }
private

Definition at line 138 of file EventContext.h.

◆ m_valid

bool EventContext::m_valid { false }
private

Definition at line 139 of file EventContext.h.

139{ false };

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