Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IAlgExecStateSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_IALGEXECSTATESVC_H
2 #define GAUDIKERNEL_IALGEXECSTATESVC_H 1
3 
8 #include <map>
9 #include <sstream>
10 #include <string>
11 
12 class EventContext;
13 
14 //-----------------------------------------------------------------------------
15 
25 //-----------------------------------------------------------------------------
26 
27 class AlgExecState {
28 public:
29  enum State { None = 0, Executing = 1, Done = 2 };
30 
31  bool filterPassed() const { return m_filterPassed; }
32  State state() const { return m_state; }
33  const StatusCode& execStatus() const { return m_execStatus; }
34 
35  void setFilterPassed( bool f = true ) { m_filterPassed = f; }
36  void setState( State s ) { m_state = s; }
37  void setState( State s, const StatusCode& sc ) {
38  m_state = s;
39  m_execStatus = sc;
40  }
42  void reset() { *this = AlgExecState{}; }
43 
44 private:
45  bool m_filterPassed{true};
46  State m_state{State::None};
48 };
49 
51  ost << "e: ";
52  switch ( s.state() ) {
53  case AlgExecState::State::None:
54  return ost << "n";
55  case AlgExecState::State::Executing:
56  return ost << "e";
57  default:
58  return ost << "d f: " << s.filterPassed() << " sc: " << s.execStatus();
59  }
60 }
61 
62 namespace EventStatus {
63  enum Status { Invalid = 0, Success = 1, AlgFail = 2, AlgStall = 3, Other = 4 };
65  static constexpr std::array<const char*, 5> label{"Invalid", "Success", "AlgFail", "AlgStall", "Other"};
66  return os << label.at( s );
67  }
68 } // namespace EventStatus
69 
70 class GAUDI_API IAlgExecStateSvc : virtual public IInterface {
71 public:
74 
76 
77  // get the Algorithm Execution State for a give Algorithm and EventContext
78  virtual const AlgExecState& algExecState( const Gaudi::StringKey& algName, const EventContext& ctx ) const = 0;
79  const AlgExecState& algExecState( IAlgorithm* iAlg, const EventContext& ctx ) const {
80  return algExecState( iAlg->nameKey(), ctx );
81  }
82  virtual AlgExecState& algExecState( IAlgorithm* iAlg, const EventContext& ctx ) = 0;
83 
84  // get all the Algorithm Execution States for a given EventContext
85  virtual const AlgStateMap_t& algExecStates( const EventContext& ctx ) const = 0;
86 
87  virtual void reset( const EventContext& ctx ) = 0;
88 
89  virtual void addAlg( const Gaudi::StringKey& algName ) = 0;
90  void addAlg( IAlgorithm* iAlg ) { addAlg( iAlg->nameKey() ); }
91 
92  virtual const EventStatus::Status& eventStatus( const EventContext& ctx ) const = 0;
93 
94  virtual void setEventStatus( const EventStatus::Status& sc, const EventContext& ctx ) = 0;
95 
96  virtual void updateEventStatus( const bool& b, const EventContext& ctx ) = 0;
97 
98  virtual unsigned int algErrorCount( const IAlgorithm* iAlg ) const = 0;
99  virtual void resetErrorCount( const IAlgorithm* iAlg ) = 0;
100  virtual unsigned int incrementErrorCount( const IAlgorithm* iAlg ) = 0;
101 
102  virtual void dump( std::ostringstream& ost, const EventContext& ctx ) const = 0;
103 };
104 
105 #endif
const AlgExecState & algExecState(IAlgorithm *iAlg, const EventContext &ctx) const
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
This class represents an entry point to all the event specific data.
Definition: EventContext.h:31
STL class.
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:34
void setState(State s)
Abstract interface for a service that manages the Algorithm execution states.
void setState(State s, const StatusCode &sc)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:13
Definition of the basic interface.
Definition: IInterface.h:244
virtual const Gaudi::StringKey & nameKey() const =0
StringKey rep of name.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
string s
Definition: gaudirun.py:312
STL class.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
StatusCode m_execStatus
bool filterPassed() const
void setFilterPassed(bool f=true)
std::ostream & operator<<(std::ostream &ost, const AlgExecState &s)
void addAlg(IAlgorithm *iAlg)
#define GAUDI_API
Definition: Kernel.h:71
STL class.
State state() const
std::map< Gaudi::StringKey, AlgExecState > AlgStateMap_t
const StatusCode & execStatus() const