| The Gaudi Framework v32r1 (f65d50dc)

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 }
AlgsExecutionStates::ERROR
Definition: AlgsExecutionStates.h:36
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
AlgsExecutionStates::DATAREADY
Definition: AlgsExecutionStates.h:32
Gaudi::Units::second
constexpr double second
Definition: SystemOfUnits.h:121
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
AlgsExecutionStates::EVTREJECTED
Definition: AlgsExecutionStates.h:35
AlgsExecutionStates::set
StatusCode set(unsigned int iAlgo, State newState)
Definition: AlgsExecutionStates.cpp:13
AlgsExecutionStates::EVTACCEPTED
Definition: AlgsExecutionStates.h:34
AlgsExecutionStates::SCHEDULED
Definition: AlgsExecutionStates.h:33
AlgsExecutionStates::CONTROLREADY
Definition: AlgsExecutionStates.h:31
AlgsExecutionStates::State
State
Execution states of the algorithms.
Definition: AlgsExecutionStates.h:29
AlgsExecutionStates::INITIAL
Definition: AlgsExecutionStates.h:30
std::vector::size
T size(T... args)
AlgsExecutionStates::m_states
std::vector< State > m_states
Definition: AlgsExecutionStates.h:69
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
AlgsExecutionStates.h
AlgsExecutionStates::log
MsgStream log()
Definition: AlgsExecutionStates.h:72
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192