The Gaudi Framework  v30r3 (a5ef0a68)
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 14 of file StateMachine.h.

enum Gaudi::StateMachine::Transition

Allowed transitions between states.

Enumerator
CONFIGURE 
INITIALIZE 
START 
STOP 
FINALIZE 
TERMINATE 

Definition at line 25 of file StateMachine.h.

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

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

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  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
T str(T...args)
std::ostream& Gaudi::StateMachine::operator<< ( std::ostream s,
const Gaudi::StateMachine::State st 
)
inline

Pretty print of states.

Definition at line 41 of file StateMachine.h.

42  {
43  switch ( st ) {
45  return s << "OFFLINE";
47  return s << "CONFIGURED";
49  return s << "INITIALIZED";
51  return s << "RUNNING";
52  }
53  return s; // cannot be reached, but make the compiler happy
54  }
string s
Definition: gaudirun.py:253
std::ostream& Gaudi::StateMachine::operator<< ( std::ostream s,
const Gaudi::StateMachine::Transition t 
)
inline

Pretty print of transitions.

Definition at line 57 of file StateMachine.h.

58  {
59  switch ( t ) {
61  return s << "CONFIGURE";
63  return s << "INITIALIZE";
65  return s << "START";
67  return s << "STOP";
69  return s << "FINALIZE";
71  return s << "TERMINATE";
72  }
73  return s; // cannot be reached, but make the compiler happy
74  }
string s
Definition: gaudirun.py:253