The Gaudi Framework  v28r2p1 (f1a77ff4)
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.

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

Definition at line 48 of file AlgsExecutionStates.h.

48 {};

Member Function Documentation

bool AlgsExecutionStates::algsPresent ( State  state) const
inline

Definition at line 54 of file AlgsExecutionStates.h.

54  {
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.

58  {
59  int execAlgos=std::count_if(m_states.begin(),m_states.end(),[](State s) {return (s == EVTACCEPTED || s== EVTREJECTED);});
60  return m_states.size() == (unsigned int)execAlgos;
61  };
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:245
State
Execution states of the algorithms.
Iterator AlgsExecutionStates::begin ( State  kind)
inline

Definition at line 135 of file AlgsExecutionStates.h.

136  {
137  return(Iterator(Iterator::POS::BEGIN, kind, m_states));
138  }
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 140 of file AlgsExecutionStates.h.

141  {
142  return(Iterator(Iterator::POS::END, kind, m_states));
143  }
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 63 of file AlgsExecutionStates.h.

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

Definition at line 52 of file AlgsExecutionStates.h.

size_t AlgsExecutionStates::size ( ) const
inline

Definition at line 69 of file AlgsExecutionStates.h.

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

Definition at line 73 of file AlgsExecutionStates.h.

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

Definition at line 14 of file AlgsExecutionStates.cpp.

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

Member Data Documentation

SmartIF<IMessageSvc> AlgsExecutionStates::m_MS
private

Definition at line 79 of file AlgsExecutionStates.h.

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

Definition at line 78 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: