Loading [MathJax]/jax/output/HTML-CSS/config.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IAlgExecStateSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_IALGEXECSTATESVC_H
12 #define GAUDIKERNEL_IALGEXECSTATESVC_H 1
13 
14 #include "GaudiKernel/IAlgorithm.h"
15 #include "GaudiKernel/IInterface.h"
16 #include "GaudiKernel/StatusCode.h"
17 #include "GaudiKernel/StringKey.h"
18 #include <map>
19 #include <sstream>
20 #include <string>
21 
22 class EventContext;
23 
24 //-----------------------------------------------------------------------------
25 
35 //-----------------------------------------------------------------------------
36 
37 class AlgExecState {
38 public:
39  enum State { None = 0, Executing = 1, Done = 2 };
40 
41  bool filterPassed() const { return m_filterPassed; }
42  State state() const { return m_state; }
43  const StatusCode& execStatus() const { return m_execStatus; }
44 
45  void setFilterPassed( bool f = true ) { m_filterPassed = f; }
46  void setState( State s ) { m_state = s; }
47  void setState( State s, const StatusCode& sc ) {
48  m_state = s;
49  m_execStatus = sc;
50  }
52  void reset() { *this = AlgExecState{}; }
53 
54 private:
55  bool m_filterPassed{ true };
56  State m_state{ State::None };
58 };
59 
61  ost << "e: ";
62  switch ( s.state() ) {
63  case AlgExecState::State::None:
64  return ost << "n";
65  case AlgExecState::State::Executing:
66  return ost << "e";
67  default:
68  return ost << "d f: " << s.filterPassed() << " sc: " << s.execStatus();
69  }
70 }
71 
72 namespace EventStatus {
73  enum Status { Invalid = 0, Success = 1, AlgFail = 2, AlgStall = 3, Other = 4 };
75  static constexpr std::array<const char*, 5> label{ "Invalid", "Success", "AlgFail", "AlgStall", "Other" };
76  return os << label.at( s );
77  }
78 } // namespace EventStatus
79 
80 class GAUDI_API IAlgExecStateSvc : virtual public IInterface {
81 public:
84 
86 
87  // get the Algorithm Execution State for a give Algorithm and EventContext
88  virtual const AlgExecState& algExecState( const Gaudi::StringKey& algName, const EventContext& ctx ) const = 0;
89  const AlgExecState& algExecState( IAlgorithm* iAlg, const EventContext& ctx ) const {
90  return algExecState( iAlg->nameKey(), ctx );
91  }
92  virtual AlgExecState& algExecState( IAlgorithm* iAlg, const EventContext& ctx ) = 0;
93 
94  // get all the Algorithm Execution States for a given EventContext
95  virtual const AlgStateMap_t& algExecStates( const EventContext& ctx ) const = 0;
96 
97  virtual void reset( const EventContext& ctx ) = 0;
98 
99  virtual void addAlg( const Gaudi::StringKey& algName ) = 0;
100  void addAlg( IAlgorithm* iAlg ) { addAlg( iAlg->nameKey() ); }
101 
102  virtual const EventStatus::Status& eventStatus( const EventContext& ctx ) const = 0;
103 
104  virtual void setEventStatus( const EventStatus::Status& sc, const EventContext& ctx ) = 0;
105 
106  virtual void updateEventStatus( const bool& b, const EventContext& ctx ) = 0;
107 
108  virtual unsigned int algErrorCount( const IAlgorithm* iAlg ) const = 0;
109  virtual void resetErrorCount( const IAlgorithm* iAlg ) = 0;
110  virtual unsigned int incrementErrorCount( const IAlgorithm* iAlg ) = 0;
111 
112  virtual void dump( std::ostringstream& ost, const EventContext& ctx ) const = 0;
113 };
114 
115 #endif
operator<<
std::ostream & operator<<(std::ostream &ost, const AlgExecState &s)
Definition: IAlgExecStateSvc.h:60
EventStatus
Definition: IAlgExecStateSvc.h:72
AlgExecState::reset
void reset()
Definition: IAlgExecStateSvc.h:52
AlgExecState::state
State state() const
Definition: IAlgExecStateSvc.h:42
gaudirun.s
string s
Definition: gaudirun.py:348
AlgExecState::m_state
State m_state
Definition: IAlgExecStateSvc.h:56
EventStatus::Other
@ Other
Definition: IAlgExecStateSvc.h:73
AlgExecState::setState
void setState(State s, const StatusCode &sc)
Definition: IAlgExecStateSvc.h:47
IAlgExecStateSvc::dump
virtual void dump(std::ostringstream &ost, const EventContext &ctx) const =0
StringKey.h
EventStatus::Success
@ Success
Definition: IAlgExecStateSvc.h:73
IAlgExecStateSvc::AlgStateMap_t
std::map< Gaudi::StringKey, AlgExecState > AlgStateMap_t
Definition: IAlgExecStateSvc.h:85
IAlgExecStateSvc::algErrorCount
virtual unsigned int algErrorCount(const IAlgorithm *iAlg) const =0
AlgExecState::Done
@ Done
Definition: IAlgExecStateSvc.h:39
StatusCode.h
IAlgExecStateSvc::algExecState
virtual AlgExecState & algExecState(IAlgorithm *iAlg, const EventContext &ctx)=0
EventStatus::Invalid
@ Invalid
Definition: IAlgExecStateSvc.h:73
AlgExecState::m_filterPassed
bool m_filterPassed
Definition: IAlgExecStateSvc.h:55
AlgExecState::Executing
@ Executing
Definition: IAlgExecStateSvc.h:39
IAlgExecStateSvc::resetErrorCount
virtual void resetErrorCount(const IAlgorithm *iAlg)=0
Gaudi::StringKey
Definition: StringKey.h:44
EventStatus::AlgStall
@ AlgStall
Definition: IAlgExecStateSvc.h:73
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:588
StatusCode
Definition: StatusCode.h:65
IInterface.h
IAlgorithm
Definition: IAlgorithm.h:38
std::ostream
STL class.
AlgExecState::None
@ None
Definition: IAlgExecStateSvc.h:39
IAlgExecStateSvc::addAlg
virtual void addAlg(const Gaudi::StringKey &algName)=0
AlgExecState::setState
void setState(State s)
Definition: IAlgExecStateSvc.h:46
IAlgExecStateSvc
Abstract interface for a service that manages the Algorithm execution states.
Definition: IAlgExecStateSvc.h:80
std::array
STL class.
AlgExecState::execStatus
const StatusCode & execStatus() const
Definition: IAlgExecStateSvc.h:43
IAlgExecStateSvc::algExecStates
virtual const AlgStateMap_t & algExecStates(const EventContext &ctx) const =0
IAlgExecStateSvc::reset
virtual void reset(const EventContext &ctx)=0
IAlgorithm::nameKey
virtual const Gaudi::StringKey & nameKey() const =0
StringKey rep of name.
std::map
STL class.
EventStatus::AlgFail
@ AlgFail
Definition: IAlgExecStateSvc.h:73
std::ostringstream
STL class.
IAlgExecStateSvc::algExecState
const AlgExecState & algExecState(IAlgorithm *iAlg, const EventContext &ctx) const
Definition: IAlgExecStateSvc.h:89
AlgExecState::setExecStatus
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
Definition: IAlgExecStateSvc.h:51
AlgExecState::m_execStatus
StatusCode m_execStatus
Definition: IAlgExecStateSvc.h:57
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
IAlgExecStateSvc::addAlg
void addAlg(IAlgorithm *iAlg)
Definition: IAlgExecStateSvc.h:100
AlgExecState::State
State
Definition: IAlgExecStateSvc.h:39
IInterface
Definition: IInterface.h:237
EventContext
Definition: EventContext.h:34
EventStatus::Status
Status
Definition: IAlgExecStateSvc.h:73
AlgExecState::filterPassed
bool filterPassed() const
Definition: IAlgExecStateSvc.h:41
IAlgExecStateSvc::incrementErrorCount
virtual unsigned int incrementErrorCount(const IAlgorithm *iAlg)=0
IAlgExecStateSvc::setEventStatus
virtual void setEventStatus(const EventStatus::Status &sc, const EventContext &ctx)=0
IAlgExecStateSvc::algExecState
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
IAlgExecStateSvc::eventStatus
virtual const EventStatus::Status & eventStatus(const EventContext &ctx) const =0
IAlgorithm.h
AlgExecState
Definition: IAlgExecStateSvc.h:37
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
AlgExecState::setFilterPassed
void setFilterPassed(bool f=true)
Definition: IAlgExecStateSvc.h:45
IAlgExecStateSvc::DeclareInterfaceID
DeclareInterfaceID(IAlgExecStateSvc, 1, 0)
InterfaceID.
IAlgExecStateSvc::updateEventStatus
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
EventStatus::operator<<
std::ostream & operator<<(std::ostream &os, Status s)
Definition: IAlgExecStateSvc.h:74