The Gaudi Framework  v29r0 (ff2e7097)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgsExecutionStates Class Reference

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 : unsigned short {
  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)
 
 ~AlgsExecutionStates ()
 
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 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 28 of file AlgsExecutionStates.h.

Member Enumeration Documentation

enum AlgsExecutionStates::State : unsigned short

Execution states of the algorithms.

Enumerator
INITIAL 
CONTROLREADY 
DATAREADY 
SCHEDULED 
EVTACCEPTED 
EVTREJECTED 
ERROR 

Definition at line 32 of file AlgsExecutionStates.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file AlgsExecutionStates.h.

45  : m_states( algsNumber, INITIAL ), m_MS( MS ){};
SmartIF< IMessageSvc > m_MS
std::vector< State > m_states
AlgsExecutionStates::~AlgsExecutionStates ( )
inline

Definition at line 47 of file AlgsExecutionStates.h.

47 {};

Member Function Documentation

bool AlgsExecutionStates::algsPresent ( State  state) const
inline

Definition at line 53 of file AlgsExecutionStates.h.

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

Definition at line 58 of file AlgsExecutionStates.h.

59  {
60  int execAlgos = std::count_if( m_states.begin(), m_states.end(),
61  []( State s ) { return ( s == EVTACCEPTED || s == EVTREJECTED ); } );
62  return m_states.size() == (unsigned int)execAlgos;
63  };
T end(T...args)
T count_if(T...args)
T size(T...args)
std::vector< State > m_states
T begin(T...args)
string s
Definition: gaudirun.py:253
State
Execution states of the algorithms.
Iterator AlgsExecutionStates::begin ( State  kind)
inline

Definition at line 125 of file AlgsExecutionStates.h.

125 { return ( Iterator( Iterator::POS::BEGIN, kind, m_states ) ); }
std::vector< State > m_states
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
Iterator AlgsExecutionStates::end ( State  kind)
inline

Definition at line 127 of file AlgsExecutionStates.h.

127 { return ( Iterator( Iterator::POS::END, kind, m_states ) ); }
std::vector< State > m_states
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
const State& AlgsExecutionStates::operator[] ( unsigned int  i) const
inline

Definition at line 65 of file AlgsExecutionStates.h.

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

Definition at line 51 of file AlgsExecutionStates.h.

size_t AlgsExecutionStates::size ( ) const
inline

Definition at line 67 of file AlgsExecutionStates.h.

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

Definition at line 69 of file AlgsExecutionStates.h.

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

Definition at line 8 of file AlgsExecutionStates.cpp.

9 {
10 
11  MsgStream log( m_MS, "AlgExecutionStates" );
12  const unsigned int states_size = m_states.size();
13 
14  if ( iAlgo >= states_size ) {
15  log << MSG::ERROR << "Index out of bound (" << iAlgo << " and the size of the states vector is " << states_size
16  << ")" << endmsg;
17 
18  return StatusCode::FAILURE;
19  }
20 
21  switch ( newState ) {
22  case INITIAL:
23  log << MSG::ERROR << "[AlgIndex " << iAlgo << "] Transition to INITIAL is not defined.";
24  return StatusCode::FAILURE;
25  //
26  case CONTROLREADY:
27  if ( m_states[iAlgo] != INITIAL ) {
28  log << MSG::ERROR << "[AlgIndex " << iAlgo
29  << "] Transition to CONTROLREADY possible only from INITIAL state! The state is " << m_states[iAlgo]
30  << endmsg;
31  return StatusCode::FAILURE;
32  } else {
33  m_states[iAlgo] = CONTROLREADY;
34  return StatusCode::SUCCESS;
35  }
36  //
37  case DATAREADY:
38  if ( m_states[iAlgo] != CONTROLREADY ) {
39  log << MSG::ERROR << "[AlgIndex " << iAlgo
40  << "] Transition to DATAREADY possible only from CONTROLREADY state!The state is " << m_states[iAlgo]
41  << endmsg;
42  return StatusCode::FAILURE;
43  } else {
44  m_states[iAlgo] = DATAREADY;
45  return StatusCode::SUCCESS;
46  }
47  case SCHEDULED:
48  if ( m_states[iAlgo] != DATAREADY ) {
49  log << MSG::ERROR << "[AlgIndex " << iAlgo
50  << "] Transition to SCHEDULED possible only from DATAREADY state! The state is " << m_states[iAlgo] << endmsg;
51  return StatusCode::FAILURE;
52  } else {
53  m_states[iAlgo] = SCHEDULED;
54  return StatusCode::SUCCESS;
55  }
56  //
57  case EVTACCEPTED:
58  if ( m_states[iAlgo] != SCHEDULED ) {
59  log << MSG::ERROR << "[AlgIndex " << iAlgo
60  << "] Transition to EVTACCEPTED possible only from SCHEDULED state! The state is " << m_states[iAlgo]
61  << endmsg;
62  return StatusCode::FAILURE;
63  } else {
64  m_states[iAlgo] = EVTACCEPTED;
65  return StatusCode::SUCCESS;
66  }
67  //
68  case EVTREJECTED:
69  if ( m_states[iAlgo] != SCHEDULED ) {
70  log << MSG::ERROR << "[AlgIndex " << iAlgo
71  << "] Transition to EVTREJECT possible only from SCHEDULED state! The state is " << m_states[iAlgo] << endmsg;
72  return StatusCode::FAILURE;
73  } else {
74  m_states[iAlgo] = EVTREJECTED;
75  return StatusCode::SUCCESS;
76  }
77  default:
78  //
79  m_states[iAlgo] = ERROR;
80  return StatusCode::SUCCESS;
81  }
82 
83  return StatusCode::FAILURE;
84 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > m_MS
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

Member Data Documentation

SmartIF<IMessageSvc> AlgsExecutionStates::m_MS
private

Definition at line 76 of file AlgsExecutionStates.h.

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

Definition at line 75 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 42 of file AlgsExecutionStates.h.


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