The Gaudi Framework  v30r3 (a5ef0a68)
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 set (unsigned int iAlgo, State newState)
 
void reset ()
 
bool contains (State state) const
 check if the collection contains at least one state of requested type More...
 
bool containsAny (std::initializer_list< State > l) const
 check if the collection contains at least one state of any listed types More...
 
bool containsOnly (std::initializer_list< State > l) const
 check if the collection contains only states of listed types More...
 
const Stateoperator[] (unsigned int i) const
 
size_t size () const
 
size_t sizeOfSubset (State state) const
 
Iterator begin (State kind)
 
Iterator end (State kind)
 

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 26 of file AlgsExecutionStates.h.

Member Enumeration Documentation

Execution states of the algorithms.

Enumerator
INITIAL 
CONTROLREADY 
DATAREADY 
SCHEDULED 
EVTACCEPTED 
EVTREJECTED 
ERROR 

Definition at line 30 of file AlgsExecutionStates.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file AlgsExecutionStates.h.

41  : 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

Iterator AlgsExecutionStates::begin ( State  kind)
inline

Definition at line 112 of file AlgsExecutionStates.h.

112 { return {kind, m_states, m_states.begin()}; }
std::vector< State > m_states
T begin(T...args)
bool AlgsExecutionStates::contains ( State  state) const
inline

check if the collection contains at least one state of requested type

Definition at line 48 of file AlgsExecutionStates.h.

48 { return std::find( m_states.begin(), m_states.end(), state ) != m_states.end(); }
T end(T...args)
T find(T...args)
std::vector< State > m_states
T begin(T...args)
bool AlgsExecutionStates::containsAny ( std::initializer_list< State l) const
inline

check if the collection contains at least one state of any listed types

Definition at line 51 of file AlgsExecutionStates.h.

52  {
53  return std::find_first_of( m_states.begin(), m_states.end(), l.begin(), l.end() ) != m_states.end();
54  }
T end(T...args)
T find_first_of(T...args)
std::vector< State > m_states
T begin(T...args)
bool AlgsExecutionStates::containsOnly ( std::initializer_list< State l) const
inline

check if the collection contains only states of listed types

Definition at line 57 of file AlgsExecutionStates.h.

58  {
59  return std::all_of( m_states.begin(), m_states.end(),
60  [l]( State s ) { return std::find( l.begin(), l.end(), s ) != l.end(); } );
61  };
T end(T...args)
State
Execution states of the algorithms.
dictionary l
Definition: gaudirun.py:440
T find(T...args)
std::vector< State > m_states
T begin(T...args)
T all_of(T...args)
string s
Definition: gaudirun.py:253
Iterator AlgsExecutionStates::end ( State  kind)
inline

Definition at line 113 of file AlgsExecutionStates.h.

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

Definition at line 76 of file AlgsExecutionStates.h.

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

Definition at line 63 of file AlgsExecutionStates.h.

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

Definition at line 45 of file AlgsExecutionStates.h.

T end(T...args)
std::vector< State > m_states
T begin(T...args)
T fill(T...args)
StatusCode AlgsExecutionStates::set ( unsigned int  iAlgo,
State  newState 
)

Definition at line 15 of file AlgsExecutionStates.cpp.

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 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
size_t AlgsExecutionStates::size ( ) const
inline

Definition at line 65 of file AlgsExecutionStates.h.

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

Definition at line 67 of file AlgsExecutionStates.h.

68  {
69  return std::count_if( m_states.begin(), m_states.end(), [&]( State s ) { return s == state; } );
70  }
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

Member Data Documentation

SmartIF<IMessageSvc> AlgsExecutionStates::m_MS
private

Definition at line 74 of file AlgsExecutionStates.h.

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

Definition at line 73 of file AlgsExecutionStates.h.


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