The Gaudi Framework  v31r0 (aeb156f0)
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

enum Gaudi::StateMachine::State

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

Enumerator
OFFLINE 
CONFIGURED 
INITIALIZED 
RUNNING 

Definition at line 12 of file StateMachine.h.

enum Gaudi::StateMachine::Transition

Allowed transitions between states.

Enumerator
CONFIGURE 
INITIALIZE 
START 
STOP 
FINALIZE 
TERMINATE 

Definition at line 23 of file StateMachine.h.

23  {
24  CONFIGURE, // OFFLINE -> CONFIGURED
25  INITIALIZE, // CONFIGURED -> INITIALIZED
26  START, // INITIALIZED -> RUNNING
27  STOP, // RUNNING -> INITIALIZED
28  FINALIZE, // INITIALIZED -> CONFIGURED
29  TERMINATE // CONFIGURED -> OFFLINE
30  };

Function Documentation

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 9 of file StateMachine.cpp.

9  {
10  switch ( transition ) {
11  case CONFIGURE:
12  if ( OFFLINE == state ) { return CONFIGURED; }
13  break;
14  case INITIALIZE:
15  if ( CONFIGURED == state ) { return INITIALIZED; }
16  break;
17  case START:
18  if ( INITIALIZED == state ) { return RUNNING; }
19  break;
20  case STOP:
21  if ( RUNNING == state ) { return INITIALIZED; }
22  break;
23  case FINALIZE:
24  if ( INITIALIZED == state ) { return CONFIGURED; }
25  break;
26  case TERMINATE:
27  if ( CONFIGURED == state ) { return OFFLINE; }
28  break;
29  default:
30  break;
31  }
33  msg << "Invalid transition '" << transition << "' from state '" << state << "'";
34  throw GaudiException( msg.str(), "Gaudi::StateMachine::ChangeState", StatusCode( StatusCode::FAILURE, true ) );
35  return OFFLINE; // never reached, but maked the compiler happy
36  }
Define general base for Gaudi exception.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
T str(T...args)
constexpr static const auto FAILURE
Definition: StatusCode.h:86
std::ostream& Gaudi::StateMachine::operator<< ( std::ostream s,
const Gaudi::StateMachine::State st 
)
inline

Pretty print of states.

Definition at line 39 of file StateMachine.h.

39  {
40  switch ( st ) {
42  return s << "OFFLINE";
44  return s << "CONFIGURED";
46  return s << "INITIALIZED";
48  return s << "RUNNING";
49  default:
50  return s;
51  }
52  }
string s
Definition: gaudirun.py:312
std::ostream& Gaudi::StateMachine::operator<< ( std::ostream s,
const Gaudi::StateMachine::Transition t 
)
inline

Pretty print of transitions.

Definition at line 55 of file StateMachine.h.

55  {
56  switch ( t ) {
58  return s << "CONFIGURE";
60  return s << "INITIALIZE";
62  return s << "START";
64  return s << "STOP";
66  return s << "FINALIZE";
68  return s << "TERMINATE";
69  default:
70  return s;
71  }
72  }
string s
Definition: gaudirun.py:312