The Gaudi Framework  v30r2 (9eca68f7)
AlgsExecutionStates Class Referencefinal

The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single event. More...

#include <GaudiKernel/AlgsExecutionStates.h>

Collaboration diagram for AlgsExecutionStates:

Classes

class  Iterator
 

Public Types

enum  State : uint8_t {
  INITIAL = 0, CONTROLREADY = 1, DATAREADY = 2, SCHEDULED = 3,
  EVTACCEPTED = 4, EVTREJECTED = 5, ERROR = 6
}
 Execution states of the algorithms. More...
 

Public Member Functions

 AlgsExecutionStates (unsigned int algsNumber, SmartIF< IMessageSvc > MS)
 
StatusCode updateState (unsigned int iAlgo, State newState)
 
void reset ()
 
bool algsPresent (State state) const
 
bool allAlgsExecuted ()
 
const Stateoperator[] (unsigned int i) const
 
size_t size () const
 
size_t sizeOfSubset (State state) const
 
Iterator begin (State kind)
 
Iterator end (State kind)
 

Static Public Attributes

static std::map< State, std::stringstateNames
 

Private Member Functions

MsgStream log ()
 

Private Attributes

std::vector< Statem_states
 
SmartIF< IMessageSvcm_MS
 

Detailed Description

The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single event.

It is used by the concurrent schedulers

Author
Benedikt Hegner
Danilo Piparo
Version
1.0

Definition at line 27 of file AlgsExecutionStates.h.

Member Enumeration Documentation

Execution states of the algorithms.

Enumerator
INITIAL 
CONTROLREADY 
DATAREADY 
SCHEDULED 
EVTACCEPTED 
EVTREJECTED 
ERROR 

Definition at line 31 of file AlgsExecutionStates.h.

Constructor & Destructor Documentation

AlgsExecutionStates::AlgsExecutionStates ( unsigned int  algsNumber,
SmartIF< IMessageSvc MS 
)
inline

Definition at line 43 of file AlgsExecutionStates.h.

44  : m_states( algsNumber, INITIAL ), m_MS( std::move( MS ) ){};
SmartIF< IMessageSvc > m_MS
T move(T...args)
std::vector< State > m_states

Member Function Documentation

bool AlgsExecutionStates::algsPresent ( State  state) const
inline

Definition at line 50 of file AlgsExecutionStates.h.

51  {
52  return std::find( m_states.begin(), m_states.end(), state ) != m_states.end();
53  }
T end(T...args)
T find(T...args)
std::vector< State > m_states
T begin(T...args)
bool AlgsExecutionStates::allAlgsExecuted ( )
inline

Definition at line 55 of file AlgsExecutionStates.h.

56  {
57  return std::all_of( m_states.begin(), m_states.end(),
58  []( State s ) { return s == EVTACCEPTED || s == EVTREJECTED; } );
59  };
T end(T...args)
State
Execution states of the algorithms.
std::vector< State > m_states
T begin(T...args)
T all_of(T...args)
string s
Definition: gaudirun.py:253
Iterator AlgsExecutionStates::begin ( State  kind)
inline

Definition at line 110 of file AlgsExecutionStates.h.

110 { return {kind, m_states, m_states.begin()}; }
std::vector< State > m_states
T begin(T...args)
Iterator AlgsExecutionStates::end ( State  kind)
inline

Definition at line 111 of file AlgsExecutionStates.h.

111 { return {kind, m_states, m_states.end()}; }
T end(T...args)
std::vector< State > m_states
MsgStream AlgsExecutionStates::log ( )
inlineprivate

Definition at line 74 of file AlgsExecutionStates.h.

74 { return {m_MS, "AlgsExecutionStates"}; }
SmartIF< IMessageSvc > m_MS
const State& AlgsExecutionStates::operator[] ( unsigned int  i) const
inline

Definition at line 61 of file AlgsExecutionStates.h.

61 { return m_states.at( i ); };
T at(T...args)
std::vector< State > m_states
void AlgsExecutionStates::reset ( )
inline

Definition at line 48 of file AlgsExecutionStates.h.

T end(T...args)
std::vector< State > m_states
T begin(T...args)
T fill(T...args)
size_t AlgsExecutionStates::size ( ) const
inline

Definition at line 63 of file AlgsExecutionStates.h.

63 { return m_states.size(); }
T size(T...args)
std::vector< State > m_states
size_t AlgsExecutionStates::sizeOfSubset ( State  state) const
inline

Definition at line 65 of file AlgsExecutionStates.h.

66  {
67  return std::count_if( m_states.begin(), m_states.end(), [&]( State s ) { return s == state; } );
68  }
T end(T...args)
State
Execution states of the algorithms.
T count_if(T...args)
std::vector< State > m_states
T begin(T...args)
string s
Definition: gaudirun.py:253
StatusCode AlgsExecutionStates::updateState ( unsigned int  iAlgo,
State  newState 
)

Definition at line 18 of file AlgsExecutionStates.cpp.

19 {
20  if ( iAlgo >= m_states.size() ) {
21  log() << MSG::ERROR << "Index out of bound (" << iAlgo << " / " << m_states.size() << ")" << endmsg;
22  return StatusCode::FAILURE;
23  }
24 
25  switch ( transition( m_states[iAlgo], newState ) ) {
26  case transition( INITIAL, CONTROLREADY ): // Fallthrough
27  case transition( CONTROLREADY, DATAREADY ): // Fallthrough
28  case transition( DATAREADY, SCHEDULED ): // Fallthrough
29  case transition( SCHEDULED, EVTACCEPTED ): // Fallthrough
30  case transition( SCHEDULED, EVTREJECTED ):
31  m_states[iAlgo] = newState;
32  return StatusCode::SUCCESS;
33  default:
34  log() << MSG::ERROR << "[AlgIndex " << iAlgo << "] Transition from " << stateNames.at( m_states[iAlgo] ) << " to "
35  << stateNames.at( newState ) << " is not allowed" << endmsg;
36  m_states[iAlgo] = ERROR;
37  return StatusCode::FAILURE;
38  }
39 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
T at(T...args)
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
static std::map< State, std::string > stateNames

Member Data Documentation

SmartIF<IMessageSvc> AlgsExecutionStates::m_MS
private

Definition at line 72 of file AlgsExecutionStates.h.

std::vector<State> AlgsExecutionStates::m_states
private

Definition at line 71 of file AlgsExecutionStates.h.

std::map< AlgsExecutionStates::State, std::string > AlgsExecutionStates::stateNames
static
Initial value:
= {
{INITIAL, "INITIAL"}, {CONTROLREADY, "CONTROLREADY"}, {DATAREADY, "DATAREADY"}, {SCHEDULED, "SCHEDULED"},
{EVTACCEPTED, "EVTACCEPTED"}, {EVTREJECTED, "EVTREJECTED"}, {ERROR, "ERROR"}}

Definition at line 41 of file AlgsExecutionStates.h.


The documentation for this class was generated from the following files: