The Gaudi Framework  v33r0 (d5ea422b)
Gaudi::StateMachine Namespace Reference

Enumerations

enum  State { OFFLINE, CONFIGURED, INITIALIZED, RUNNING }
 Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool). More...
 
enum  Transition {
  CONFIGURE, INITIALIZE, START, STOP,
  FINALIZE, TERMINATE
}
 Allowed transitions between states. More...
 

Functions

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 allowed. More...
 
std::ostreamoperator<< (std::ostream &s, const Gaudi::StateMachine::State &st)
 Pretty print of states. More...
 
std::ostreamoperator<< (std::ostream &s, const Gaudi::StateMachine::Transition &t)
 Pretty print of transitions. More...
 

Enumeration Type Documentation

◆ State

enum Gaudi::StateMachine::State

Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).

Enumerator
OFFLINE 
CONFIGURED 
INITIALIZED 
RUNNING 

Definition at line 22 of file StateMachine.h.

◆ Transition

enum Gaudi::StateMachine::Transition

Allowed transitions between states.

Enumerator
CONFIGURE 
INITIALIZE 
START 
STOP 
FINALIZE 
TERMINATE 

Definition at line 33 of file StateMachine.h.

33  {
34  CONFIGURE, // OFFLINE -> CONFIGURED
35  INITIALIZE, // CONFIGURED -> INITIALIZED
36  START, // INITIALIZED -> RUNNING
37  STOP, // RUNNING -> INITIALIZED
38  FINALIZE, // INITIALIZED -> CONFIGURED
39  TERMINATE // CONFIGURED -> OFFLINE
40  };

Function Documentation

◆ ChangeState()

State Gaudi::StateMachine::ChangeState ( const Transition  transition,
const State  state 
)

Function to get the new state according to the required transition, checking if the transition is allowed.

Definition at line 19 of file StateMachine.cpp.

19  {
20  switch ( transition ) {
21  case CONFIGURE:
22  if ( OFFLINE == state ) { return CONFIGURED; }
23  break;
24  case INITIALIZE:
25  if ( CONFIGURED == state ) { return INITIALIZED; }
26  break;
27  case START:
28  if ( INITIALIZED == state ) { return RUNNING; }
29  break;
30  case STOP:
31  if ( RUNNING == state ) { return INITIALIZED; }
32  break;
33  case FINALIZE:
34  if ( INITIALIZED == state ) { return CONFIGURED; }
35  break;
36  case TERMINATE:
37  if ( CONFIGURED == state ) { return OFFLINE; }
38  break;
39  default:
40  break;
41  }
43  msg << "Invalid transition '" << transition << "' from state '" << state << "'";
44  throw GaudiException( msg.str(), "Gaudi::StateMachine::ChangeState", StatusCode( StatusCode::FAILURE, true ) );
45  return OFFLINE; // never reached, but maked the compiler happy
46  }
Define general base for Gaudi exception.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ operator<<() [1/2]

std::ostream& Gaudi::StateMachine::operator<< ( std::ostream s,
const Gaudi::StateMachine::State st 
)
inline

Pretty print of states.

Definition at line 49 of file StateMachine.h.

49  {
50  switch ( st ) {
52  return s << "OFFLINE";
54  return s << "CONFIGURED";
56  return s << "INITIALIZED";
58  return s << "RUNNING";
59  default:
60  return s;
61  }
62  }
string s
Definition: gaudirun.py:328

◆ operator<<() [2/2]

std::ostream& Gaudi::StateMachine::operator<< ( std::ostream s,
const Gaudi::StateMachine::Transition t 
)
inline

Pretty print of transitions.

Definition at line 65 of file StateMachine.h.

65  {
66  switch ( t ) {
68  return s << "CONFIGURE";
70  return s << "INITIALIZE";
72  return s << "START";
74  return s << "STOP";
76  return s << "FINALIZE";
78  return s << "TERMINATE";
79  default:
80  return s;
81  }
82  }
string s
Definition: gaudirun.py:328