Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgsExecutionStates.cpp
Go to the documentation of this file.
1 #include "AlgsExecutionStates.h"
2 
3 #include <cstdint>
4 
5 namespace {
6  constexpr auto transition( AlgsExecutionStates::State first, AlgsExecutionStates::State second ) {
7  static_assert( sizeof( AlgsExecutionStates::State ) == 1, "no more than 255 states please!" );
8  using ui16 = uint_fast16_t;
9  return static_cast<ui16>( first ) * 256 + static_cast<ui16>( second );
10  }
11 } // namespace
12 
13 StatusCode AlgsExecutionStates::set( unsigned int iAlgo, State newState ) {
14  if ( iAlgo >= m_states.size() ) {
15  log() << MSG::ERROR << "Index out of bound (" << iAlgo << " / " << m_states.size() << ")" << endmsg;
16  return StatusCode::FAILURE;
17  }
18 
19  switch ( transition( m_states[iAlgo], newState ) ) {
20  case transition( INITIAL, CONTROLREADY ): // Fallthrough
21  case transition( CONTROLREADY, DATAREADY ): // Fallthrough
22  case transition( DATAREADY, SCHEDULED ): // Fallthrough
23  case transition( SCHEDULED, ERROR ): // Fallthrough
24  case transition( SCHEDULED, EVTACCEPTED ): // Fallthrough
25  case transition( SCHEDULED, EVTREJECTED ):
26  m_states[iAlgo] = newState;
27  return StatusCode::SUCCESS;
28  default:
29  log() << MSG::ERROR << "[AlgIndex " << iAlgo << "] Transition from " << m_states[iAlgo] << " to " << newState
30  << " is not allowed" << endmsg;
31  m_states[iAlgo] = ERROR;
32  return StatusCode::FAILURE;
33  }
34 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
constexpr double second
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode set(unsigned int iAlgo, State newState)
State
Execution states of the algorithms.
T size(T...args)
std::vector< State > m_states
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192