| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

AlgsExecutionStates.cpp
Go to the documentation of this file.
1 #include "AlgsExecutionStates.h"
2
3 // A simple map to easily translate a state to its name
4 std::map<AlgsExecutionStates::State, std::string> AlgsExecutionStates::stateNames = {
5 {INITIAL, "INITIAL"}, {CONTROLREADY, "CONTROLREADY"}, {DATAREADY, "DATAREADY"}, {SCHEDULED, "SCHEDULED"},
6 {EVTACCEPTED, "EVTACCEPTED"}, {EVTREJECTED, "EVTREJECTED"}, {ERROR, "ERROR"}};
7
8 StatusCode AlgsExecutionStates::updateState( unsigned int iAlgo, State newState )
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 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode::SUCCESS
Definition: StatusCode.h:31
AlgsExecutionStates::ERROR
Definition: AlgsExecutionStates.h:39
StatusCode::FAILURE
Definition: StatusCode.h:31
std::map
STL class.
AlgsExecutionStates::SCHEDULED
Definition: AlgsExecutionStates.h:36
AlgsExecutionStates::EVTACCEPTED
Definition: AlgsExecutionStates.h:37
AlgsExecutionStates::INITIAL
Definition: AlgsExecutionStates.h:33
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
AlgsExecutionStates::m_MS
SmartIF< IMessageSvc > m_MS
Definition: AlgsExecutionStates.h:76
AlgsExecutionStates::CONTROLREADY
Definition: AlgsExecutionStates.h:34
std::vector::size
T size(T...args)
AlgsExecutionStates::m_states
std::vector< State > m_states
Definition: AlgsExecutionStates.h:75
AlgsExecutionStates::DATAREADY
Definition: AlgsExecutionStates.h:35
MSG::ERROR
Definition: IMessageSvc.h:16
AlgsExecutionStates::EVTREJECTED
Definition: AlgsExecutionStates.h:38
AlgsExecutionStates.h
AlgsExecutionStates::State
State
Execution states of the algorithms.
Definition: AlgsExecutionStates.h:32
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
AlgsExecutionStates::stateNames
static std::map< State, std::string > stateNames
Definition: AlgsExecutionStates.h:42
Gaudi.Configuration.log
log
Definition: Configuration.py:13
AlgsExecutionStates::updateState
StatusCode updateState(unsigned int iAlgo, State newState)
Definition: AlgsExecutionStates.cpp:8