The Gaudi Framework  v30r3 (a5ef0a68)
StateMachine.cpp
Go to the documentation of this file.
2 
3 namespace Gaudi
4 {
5  namespace StateMachine
6  {
11  State ChangeState( const Transition transition, const State state )
12  {
13  switch ( transition ) {
14  case CONFIGURE:
15  if ( OFFLINE == state ) {
16  return CONFIGURED;
17  }
18  break;
19  case INITIALIZE:
20  if ( CONFIGURED == state ) {
21  return INITIALIZED;
22  }
23  break;
24  case START:
25  if ( INITIALIZED == state ) {
26  return RUNNING;
27  }
28  break;
29  case STOP:
30  if ( RUNNING == state ) {
31  return INITIALIZED;
32  }
33  break;
34  case FINALIZE:
35  if ( INITIALIZED == state ) {
36  return CONFIGURED;
37  }
38  break;
39  case TERMINATE:
40  if ( CONFIGURED == state ) {
41  return OFFLINE;
42  }
43  break;
44  }
46  msg << "Invalid transition '" << transition << "' from state '" << state << "'";
47  throw GaudiException( msg.str(), "Gaudi::StateMachine::ChangeState", StatusCode( StatusCode::FAILURE, true ) );
48  return OFFLINE; // never reached, but maked the compiler happy
49  }
50  }
51 } // namespace Gaudi::StateMachine
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
Definition: StateMachine.h:14
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
T str(T...args)
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
Transition
Allowed transitions between states.
Definition: StateMachine.h:25
Helper functions to set/get the application return code.
Definition: __init__.py:1