The Gaudi Framework
master (bb4415cc)
Toggle main menu visibility
Loading...
Searching...
No Matches
AlgsExecutionStates.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 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
#pragma once
12
13
// Framework include files
14
#include <
GaudiKernel/MsgStream.h
>
15
#include <
GaudiKernel/Service.h
>
16
17
// C++ include files
18
#include <algorithm>
19
#include <initializer_list>
20
#include <string>
21
#include <vector>
22
23
// Boost include files
24
#include <boost/container/flat_set.hpp>
25
26
//---------------------------------------------------------------------------
27
37
class
AlgsExecutionStates
final {
38
public
:
41
enum
State
: uint8_t {
42
INITIAL
= 0,
43
CONTROLREADY
= 1,
44
DATAREADY
= 2,
45
RESOURCELESS
= 3,
46
SCHEDULED
= 4,
47
EVTACCEPTED
= 5,
48
EVTREJECTED
= 6,
49
ERROR
= 7,
50
MAXVALUE
= 8
// Allows loop over all states
51
};
52
53
AlgsExecutionStates
(
unsigned
int
algsNumber,
SmartIF<IMessageSvc>
MS )
54
:
m_states
( algsNumber,
INITIAL
),
m_algsInState
(
MAXVALUE
),
m_MS
(
std
::move( MS ) ) {
55
56
m_algsInState
[
INITIAL
].reserve( algsNumber );
57
for
(
unsigned
int
i = 0; i < algsNumber; ++i )
m_algsInState
[
INITIAL
].insert( i );
58
}
59
60
StatusCode
set
(
unsigned
int
iAlgo,
State
newState );
61
62
void
reset
() {
63
std::fill(
m_states
.begin(),
m_states
.end(),
INITIAL
);
64
65
for
(
auto
& algs :
m_algsInState
) algs.clear();
66
m_algsInState
[
INITIAL
].reserve(
m_states
.size() );
67
for
(
unsigned
int
i = 0; i <
m_states
.size(); ++i )
m_algsInState
[
INITIAL
].insert( i );
68
}
69
71
bool
contains
(
State
state )
const
{
return
m_algsInState
[state].size() > 0; }
72
74
bool
containsAny
( std::initializer_list<State> l )
const
{
75
for
(
auto
state : l )
76
if
(
m_algsInState
[state].
size
() > 0 )
return
true
;
77
return
false
;
78
}
79
80
// copy the current set of algs in a particular state
81
// states change during scheduler loop over set, so cannot return reference
82
const
boost::container::flat_set<int>
algsInState
(
State
state )
const
{
return
m_algsInState
[state]; }
83
84
const
State
&
operator[]
(
unsigned
int
i )
const
{
return
m_states
.at( i ); }
85
86
size_t
size
()
const
{
return
m_states
.size(); }
87
88
size_t
sizeOfSubset
(
State
state )
const
{
return
m_algsInState
[state].size(); }
89
90
private
:
91
std::vector<State>
m_states
;
92
std::vector<boost::container::flat_set<int>>
m_algsInState
;
93
SmartIF<IMessageSvc>
m_MS
;
94
95
MsgStream
log
() {
return
{
m_MS
,
"AlgsExecutionStates"
}; }
96
};
97
99
inline
std::ostream&
operator<<
( std::ostream& s,
AlgsExecutionStates::State
x ) {
100
using
State =
AlgsExecutionStates::State
;
101
switch
( x ) {
102
case
State::INITIAL:
103
s <<
"INITIAL"
;
104
break
;
105
case
State::CONTROLREADY:
106
s <<
"CONTROLREADY"
;
107
break
;
108
case
State::DATAREADY:
109
s <<
"DATAREADY"
;
110
break
;
111
case
State::RESOURCELESS:
112
s <<
"RESOURCELESS"
;
113
break
;
114
case
State::SCHEDULED:
115
s <<
"SCHEDULED"
;
116
break
;
117
case
State::EVTACCEPTED:
118
s <<
"EVTACCEPTED"
;
119
break
;
120
case
State::EVTREJECTED:
121
s <<
"EVTREJECTED"
;
122
break
;
123
case
State::ERROR:
124
s <<
"ERROR"
;
125
break
;
126
default
:
127
s <<
"UNKNOWN"
;
128
}
129
return
s;
130
}
operator<<
std::ostream & operator<<(std::ostream &s, AlgsExecutionStates::State x)
Streaming of State values.
Definition
AlgsExecutionStates.h:99
MsgStream.h
Service.h
AlgsExecutionStates::AlgsExecutionStates
AlgsExecutionStates(unsigned int algsNumber, SmartIF< IMessageSvc > MS)
Definition
AlgsExecutionStates.h:53
AlgsExecutionStates::operator[]
const State & operator[](unsigned int i) const
Definition
AlgsExecutionStates.h:84
AlgsExecutionStates::reset
void reset()
Definition
AlgsExecutionStates.h:62
AlgsExecutionStates::algsInState
const boost::container::flat_set< int > algsInState(State state) const
Definition
AlgsExecutionStates.h:82
AlgsExecutionStates::size
size_t size() const
Definition
AlgsExecutionStates.h:86
AlgsExecutionStates::m_states
std::vector< State > m_states
Definition
AlgsExecutionStates.h:91
AlgsExecutionStates::m_algsInState
std::vector< boost::container::flat_set< int > > m_algsInState
Definition
AlgsExecutionStates.h:92
AlgsExecutionStates::sizeOfSubset
size_t sizeOfSubset(State state) const
Definition
AlgsExecutionStates.h:88
AlgsExecutionStates::contains
bool contains(State state) const
check if the collection contains at least one state of requested type
Definition
AlgsExecutionStates.h:71
AlgsExecutionStates::log
MsgStream log()
Definition
AlgsExecutionStates.h:95
AlgsExecutionStates::State
State
Execution states of the algorithms Must have contiguous integer values 0, 1... N.
Definition
AlgsExecutionStates.h:41
AlgsExecutionStates::DATAREADY
@ DATAREADY
Definition
AlgsExecutionStates.h:44
AlgsExecutionStates::RESOURCELESS
@ RESOURCELESS
Definition
AlgsExecutionStates.h:45
AlgsExecutionStates::CONTROLREADY
@ CONTROLREADY
Definition
AlgsExecutionStates.h:43
AlgsExecutionStates::ERROR
@ ERROR
Definition
AlgsExecutionStates.h:49
AlgsExecutionStates::INITIAL
@ INITIAL
Definition
AlgsExecutionStates.h:42
AlgsExecutionStates::EVTREJECTED
@ EVTREJECTED
Definition
AlgsExecutionStates.h:48
AlgsExecutionStates::EVTACCEPTED
@ EVTACCEPTED
Definition
AlgsExecutionStates.h:47
AlgsExecutionStates::MAXVALUE
@ MAXVALUE
Definition
AlgsExecutionStates.h:50
AlgsExecutionStates::SCHEDULED
@ SCHEDULED
Definition
AlgsExecutionStates.h:46
AlgsExecutionStates::containsAny
bool containsAny(std::initializer_list< State > l) const
check if the collection contains at least one state of any listed types
Definition
AlgsExecutionStates.h:74
AlgsExecutionStates::set
StatusCode set(unsigned int iAlgo, State newState)
Definition
AlgsExecutionStates.cpp:23
AlgsExecutionStates::m_MS
SmartIF< IMessageSvc > m_MS
Definition
AlgsExecutionStates.h:93
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition
MsgStream.h:29
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition
SmartIF.h:28
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
std
STL namespace.
GaudiHive
src
AlgsExecutionStates.h
Generated on
for The Gaudi Framework by
1.17.0