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