| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# 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.

## 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.

    00012            {
    00013   OFFLINE,
    00014   CONFIGURED,
    00015   INITIALIZED,
    00016   RUNNING//,
    00017   //FINALIZED = CONFIGURED
    00018 };

enum Gaudi::StateMachine::Transition

Allowed transitions between states.

Enumerator:

  CONFIGURE |
  INITIALIZE |
  START |
  STOP |
  FINALIZE |
  TERMINATE |

Definition at line 23 of file StateMachine.h.

    00023                 {
    00024   CONFIGURE,  // OFFLINE     -> CONFIGURED
    00025   INITIALIZE, // CONFIGURED  -> INITIALIZED
    00026   START,      // INITIALIZED -> RUNNING
    00027   STOP,       // RUNNING     -> INITIALIZED
    00028   FINALIZE,   // INITIALIZED -> CONFIGURED
    00029   TERMINATE   // CONFIGURED  -> OFFLINE
    00030 };

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

    00008                                                                   {
    00009   switch (transition) {
    00010   case CONFIGURE:
    00011     if ( OFFLINE == state ) {
    00012       return CONFIGURED;
    00013     }
    00014     break;
    00015   case INITIALIZE:
    00016     if ( CONFIGURED == state ) {
    00017       return INITIALIZED;
    00018     }
    00019     break;
    00020   case START:
    00021     if ( INITIALIZED == state ) {
    00022       return RUNNING;
    00023     }
    00024     break;
    00025   case STOP:
    00026     if ( RUNNING == state ) {
    00027       return INITIALIZED;
    00028     }
    00029     break;
    00030   case FINALIZE:
    00031     if ( INITIALIZED == state ) {
    00032       return CONFIGURED;
    00033     }
    00034     break;
    00035   case TERMINATE:
    00036     if ( CONFIGURED == state ) {
    00037       return OFFLINE;
    00038     }
    00039     break;
    00040   }
    00041   std::stringstream msg;
    00042   msg << "Invalid transition '" << transition << "' from state '" << state << "'";
    00043   throw GaudiException(msg.str(), "Gaudi::StateMachine::ChangeState",
    00044       StatusCode(StatusCode::FAILURE,true));
    00045   return OFFLINE; // never reached, but maked the compiler happy
    00046 }