The Gaudi Framework  master (37c0b60a)
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

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.

22  {
23  OFFLINE,
24  CONFIGURED,
26  RUNNING //,
27  // FINALIZED = CONFIGURED
28  };

◆ 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::FAILURE );
45  return OFFLINE; // never reached, but maked the compiler happy
46  }

◆ 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  }

◆ 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  }
Gaudi::StateMachine::TERMINATE
@ TERMINATE
Definition: StateMachine.h:39
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::StateMachine::FINALIZE
@ FINALIZE
Definition: StateMachine.h:38
GaudiException
Definition: GaudiException.h:31
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
std::stringstream
STL class.
Gaudi::StateMachine::INITIALIZE
@ INITIALIZE
Definition: StateMachine.h:35
bug_34121.t
t
Definition: bug_34121.py:31
Gaudi::StateMachine::CONFIGURED
@ CONFIGURED
Definition: StateMachine.h:24
Gaudi::StateMachine::OFFLINE
@ OFFLINE
Definition: StateMachine.h:23
Gaudi::StateMachine::RUNNING
@ RUNNING
Definition: StateMachine.h:26
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
Gaudi::StateMachine::START
@ START
Definition: StateMachine.h:36
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
compareRootHistos.state
state
Definition: compareRootHistos.py:496
Gaudi::StateMachine::CONFIGURE
@ CONFIGURE
Definition: StateMachine.h:34
Gaudi::StateMachine::STOP
@ STOP
Definition: StateMachine.h:37