Gaudi::StateMachine Namespace Reference

Enumerations

enum  State {
  OFFLINE, CONFIGURED, INITIALIZED, RUNNING,
  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, CONFIGURE, INITIALIZE,
  START, STOP, FINALIZE, TERMINATE
}
 Allowed transitions between states. More...
 
enum  State {
  OFFLINE, CONFIGURED, INITIALIZED, RUNNING,
  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, 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::ostream & operator<< (std::ostream &s, const Gaudi::StateMachine::State &st)
 Pretty print of states. More...
 
std::ostream & operator<< (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 
OFFLINE 
CONFIGURED 
INITIALIZED 
RUNNING 

Definition at line 12 of file StateMachine.h.

enum Gaudi::StateMachine::State

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

Enumerator
OFFLINE 
CONFIGURED 
INITIALIZED 
RUNNING 
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 
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 };
enum Gaudi::StateMachine::Transition

Allowed transitions between states.

Enumerator
CONFIGURE 
INITIALIZE 
START 
STOP 
FINALIZE 
TERMINATE 
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_API 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 8 of file StateMachine.cpp.

8  {
9  switch (transition) {
10  case CONFIGURE:
11  if ( OFFLINE == state ) {
12  return CONFIGURED;
13  }
14  break;
15  case INITIALIZE:
16  if ( CONFIGURED == state ) {
17  return INITIALIZED;
18  }
19  break;
20  case START:
21  if ( INITIALIZED == state ) {
22  return RUNNING;
23  }
24  break;
25  case STOP:
26  if ( RUNNING == state ) {
27  return INITIALIZED;
28  }
29  break;
30  case FINALIZE:
31  if ( INITIALIZED == state ) {
32  return CONFIGURED;
33  }
34  break;
35  case TERMINATE:
36  if ( CONFIGURED == state ) {
37  return OFFLINE;
38  }
39  break;
40  }
41  std::stringstream msg;
42  msg << "Invalid transition '" << transition << "' from state '" << state << "'";
43  throw GaudiException(msg.str(), "Gaudi::StateMachine::ChangeState",
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:26
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) {
41  case Gaudi::StateMachine::OFFLINE : return s << "OFFLINE";
42  case Gaudi::StateMachine::CONFIGURED : return s << "CONFIGURED";
43  case Gaudi::StateMachine::INITIALIZED : return s << "INITIALIZED";
44  case Gaudi::StateMachine::RUNNING : return s << "RUNNING";
45  }
46  return s; // cannot be reached, but make the compiler happy
47 }
string s
Definition: gaudirun.py:245
std::ostream & Gaudi::StateMachine::operator<< ( std::ostream &  s,
const Gaudi::StateMachine::Transition t 
)
inline

Pretty print of transitions.

Definition at line 50 of file StateMachine.h.

50  {
51  switch (t) {
52  case Gaudi::StateMachine::CONFIGURE : return s << "CONFIGURE";
53  case Gaudi::StateMachine::INITIALIZE : return s << "INITIALIZE";
54  case Gaudi::StateMachine::START : return s << "START";
55  case Gaudi::StateMachine::STOP : return s << "STOP";
56  case Gaudi::StateMachine::FINALIZE : return s << "FINALIZE";
57  case Gaudi::StateMachine::TERMINATE : return s << "TERMINATE";
58  }
59  return s; // cannot be reached, but make the compiler happy
60 }
string s
Definition: gaudirun.py:245