The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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.
 
std::ostream & operator<< (std::ostream &s, const Gaudi::StateMachine::State &st)
 Pretty print of states.
 
std::ostream & operator<< (std::ostream &s, const Gaudi::StateMachine::Transition &t)
 Pretty print of transitions.
 

Enumeration Type Documentation

◆ State

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

Enumerator
OFFLINE 
CONFIGURED 
INITIALIZED 
RUNNING 

Definition at line 21 of file StateMachine.h.

21 {
22 OFFLINE,
25 RUNNING //,
26 // FINALIZED = CONFIGURED
27 };

◆ Transition

Allowed transitions between states.

Enumerator
CONFIGURE 
INITIALIZE 
START 
STOP 
FINALIZE 
TERMINATE 

Definition at line 32 of file StateMachine.h.

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

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 }
42 std::stringstream msg;
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 }
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ operator<<() [1/2]

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

Pretty print of states.

Definition at line 48 of file StateMachine.h.

48 {
49 switch ( st ) {
51 return s << "OFFLINE";
53 return s << "CONFIGURED";
55 return s << "INITIALIZED";
57 return s << "RUNNING";
58 default:
59 return s;
60 }
61 }

◆ operator<<() [2/2]

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

Pretty print of transitions.

Definition at line 64 of file StateMachine.h.

64 {
65 switch ( t ) {
67 return s << "CONFIGURE";
69 return s << "INITIALIZE";
71 return s << "START";
73 return s << "STOP";
75 return s << "FINALIZE";
77 return s << "TERMINATE";
78 default:
79 return s;
80 }
81 }