The Gaudi Framework  v30r3 (a5ef0a68)
IAlgExecStateSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_IALGEXECSTATESVC_H
2 #define GAUDIKERNEL_IALGEXECSTATESVC_H 1
3 
7 #include <map>
8 #include <sstream>
9 #include <string>
10 
11 class IAlgorithm;
12 class EventContext;
13 
14 //-----------------------------------------------------------------------------
15 
25 //-----------------------------------------------------------------------------
26 
28 {
29 public:
30  enum State { None = 0, Executing = 1, Done = 2 };
31 
32  bool filterPassed() const { return m_filterPassed; }
33  State state() const { return m_state; }
34  const StatusCode& execStatus() const { return m_execStatus; }
35 
36  void setFilterPassed( bool f = true ) { m_filterPassed = f; }
37  void setState( State s ) { m_state = s; }
38  void setState( State s, const StatusCode& sc )
39  {
40  m_state = s;
41  m_execStatus = sc;
42  }
44  void reset() { *this = AlgExecState{}; }
45 
46 private:
47  bool m_filterPassed{true};
48  State m_state{State::None};
50 };
51 
53 {
54  ost << "e: ";
55  if ( s.state() == AlgExecState::State::None ) {
56  ost << "n";
57  } else if ( s.state() == AlgExecState::State::Executing ) {
58  ost << "e";
59  } else {
60  ost << "d f: " << s.filterPassed() << " sc: " << s.execStatus();
61  }
62  return ost;
63 }
64 
65 namespace EventStatus
66 {
67  enum Status { Invalid = 0, Success = 1, AlgFail = 2, AlgStall = 3, Other = 4 };
69  {
70  static const std::array<const char*, 5> label{"Invalid", "Success", "AlgFail", "AlgStall", "Other"};
71  return os << label.at( s );
72  }
73 }
74 
75 class GAUDI_API IAlgExecStateSvc : virtual public IInterface
76 {
77 public:
80 
82 
83  // get the Algorithm Execution State for a give Algorithm and EventContext
84  virtual const AlgExecState& algExecState( const Gaudi::StringKey& algName, const EventContext& ctx ) const = 0;
85  virtual const AlgExecState& algExecState( IAlgorithm* iAlg, const EventContext& ctx ) const = 0;
86  virtual AlgExecState& algExecState( IAlgorithm* iAlg, const EventContext& ctx ) = 0;
87 
88  // get all the Algorithm Execution States for a given EventContext
89  virtual const AlgStateMap_t& algExecStates( const EventContext& ctx ) const = 0;
90 
91  virtual void reset( const EventContext& ctx ) = 0;
92 
93  virtual void addAlg( IAlgorithm* iAlg ) = 0;
94  virtual void addAlg( const Gaudi::StringKey& algName ) = 0;
95 
96  virtual const EventStatus::Status& eventStatus( const EventContext& ctx ) const = 0;
97 
98  virtual void setEventStatus( const EventStatus::Status& sc, const EventContext& ctx ) = 0;
99 
100  virtual void updateEventStatus( const bool& b, const EventContext& ctx ) = 0;
101 
102  virtual unsigned int algErrorCount( const IAlgorithm* iAlg ) const = 0;
103  virtual void resetErrorCount( const IAlgorithm* iAlg ) = 0;
104  virtual unsigned int incrementErrorCount( const IAlgorithm* iAlg ) = 0;
105 
106  virtual void dump( std::ostringstream& ost, const EventContext& ctx ) const = 0;
107 };
108 
109 #endif
constexpr static const auto FAILURE
Definition: StatusCode.h:88
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
STL class.
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:35
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:51
#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:277
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
string s
Definition: gaudirun.py:253
STL class.
StatusCode m_execStatus
bool filterPassed() const
void setFilterPassed(bool f=true)
std::ostream & operator<<(std::ostream &ost, const AlgExecState &s)
#define GAUDI_API
Definition: Kernel.h:104
STL class.
State state() const
std::map< Gaudi::StringKey, AlgExecState > AlgStateMap_t
const StatusCode & execStatus() const