The Gaudi Framework  v33r0 (d5ea422b)
StateMachine.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
12 
13 namespace Gaudi {
14  namespace StateMachine {
19  State ChangeState( const Transition transition, const State state ) {
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( StatusCode::FAILURE, true ) );
45  return OFFLINE; // never reached, but maked the compiler happy
46  }
47  } // namespace StateMachine
48 } // namespace Gaudi
Define general base for Gaudi exception.
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm,...
Definition: StateMachine.h:22
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
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 all...
Transition
Allowed transitions between states.
Definition: StateMachine.h:33
constexpr static const auto FAILURE
Definition: StatusCode.h:97
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1