The Gaudi Framework
v36r1 (3e2fb5a8)
AlgsExecutionStates.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
\***********************************************************************************/
11
#include "
AlgsExecutionStates.h
"
12
13
#include <cstdint>
14
15
namespace
{
16
constexpr
auto
transition(
AlgsExecutionStates::State
first,
AlgsExecutionStates::State
second
) {
17
static_assert(
sizeof
(
AlgsExecutionStates::State
) == 1,
"no more than 255 states please!"
);
18
using
ui16 = uint_fast16_t;
19
return
static_cast<
ui16
>
( first ) * 256 +
static_cast<
ui16
>
(
second
);
20
}
21
}
// namespace
22
23
StatusCode
AlgsExecutionStates::set
(
unsigned
int
iAlgo,
State
newState ) {
24
if
( iAlgo >=
m_states
.
size
() ) {
25
log
() <<
MSG::ERROR
<<
"Index out of bound ("
<< iAlgo <<
" / "
<<
m_states
.
size
() <<
")"
<<
endmsg
;
26
return
StatusCode::FAILURE
;
27
}
28
29
// Allow cycling of a single state
30
if
(
m_states
[iAlgo] == newState )
return
StatusCode::SUCCESS
;
31
32
switch
( transition(
m_states
[iAlgo], newState ) ) {
33
case
transition(
INITIAL
,
CONTROLREADY
):
34
[[fallthrough]];
35
case
transition(
CONTROLREADY
,
DATAREADY
):
36
[[fallthrough]];
37
case
transition(
DATAREADY
,
SCHEDULED
):
38
[[fallthrough]];
39
case
transition(
DATAREADY
,
RESOURCELESS
):
40
[[fallthrough]];
41
case
transition(
RESOURCELESS
,
SCHEDULED
):
42
[[fallthrough]];
43
case
transition(
SCHEDULED
,
ERROR
):
44
[[fallthrough]];
45
case
transition(
SCHEDULED
,
EVTACCEPTED
):
46
[[fallthrough]];
47
case
transition(
SCHEDULED
,
EVTREJECTED
):
48
m_states
[iAlgo] = newState;
49
return
StatusCode::SUCCESS
;
50
default
:
51
log
() <<
MSG::ERROR
<<
"[AlgIndex "
<< iAlgo <<
"] Transition from "
<<
m_states
[iAlgo] <<
" to "
<< newState
52
<<
" is not allowed"
<<
endmsg
;
53
m_states
[iAlgo] =
ERROR
;
54
return
StatusCode::FAILURE
;
55
}
56
}
std::vector::size
T size(T... args)
Gaudi::Units::second
constexpr double second
Definition:
SystemOfUnits.h:139
AlgsExecutionStates::CONTROLREADY
@ CONTROLREADY
Definition:
AlgsExecutionStates.h:42
AlgsExecutionStates.h
AlgsExecutionStates::RESOURCELESS
@ RESOURCELESS
Definition:
AlgsExecutionStates.h:44
AlgsExecutionStates::log
MsgStream log()
Definition:
AlgsExecutionStates.h:85
AlgsExecutionStates::ERROR
@ ERROR
Definition:
AlgsExecutionStates.h:48
StatusCode
Definition:
StatusCode.h:65
AlgsExecutionStates::m_states
std::vector< State > m_states
Definition:
AlgsExecutionStates.h:82
AlgsExecutionStates::SCHEDULED
@ SCHEDULED
Definition:
AlgsExecutionStates.h:45
AlgsExecutionStates::EVTREJECTED
@ EVTREJECTED
Definition:
AlgsExecutionStates.h:47
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition:
MsgStream.h:203
AlgsExecutionStates::set
StatusCode set(unsigned int iAlgo, State newState)
Definition:
AlgsExecutionStates.cpp:23
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition:
StatusCode.h:100
MSG::ERROR
@ ERROR
Definition:
IMessageSvc.h:25
AlgsExecutionStates::DATAREADY
@ DATAREADY
Definition:
AlgsExecutionStates.h:43
AlgsExecutionStates::State
State
Execution states of the algorithms Must have contiguous integer values 0, 1...
Definition:
AlgsExecutionStates.h:40
AlgsExecutionStates::EVTACCEPTED
@ EVTACCEPTED
Definition:
AlgsExecutionStates.h:46
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition:
StatusCode.h:101
AlgsExecutionStates::INITIAL
@ INITIAL
Definition:
AlgsExecutionStates.h:41
GaudiHive
src
AlgsExecutionStates.cpp
Generated on Tue Sep 21 2021 12:27:42 for The Gaudi Framework by
1.8.18