| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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"},
6 {CONTROLREADY,"CONTROLREADY"},
7 {DATAREADY,"DATAREADY"},
8 {SCHEDULED,"SCHEDULED"},
9 {EVTACCEPTED,"EVTACCEPTED"},
10 {EVTREJECTED,"EVTREJECTED"},
11 {ERROR,"ERROR"}
12 };
13
14 StatusCode AlgsExecutionStates::updateState(unsigned int iAlgo,State newState) {
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 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode::SUCCESS
Definition: StatusCode.h:30
AlgsExecutionStates::ERROR
Definition: AlgsExecutionStates.h:39
StatusCode::FAILURE
Definition: StatusCode.h:29
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:26
AlgsExecutionStates::m_MS
SmartIF< IMessageSvc > m_MS
Definition: AlgsExecutionStates.h:79
AlgsExecutionStates::CONTROLREADY
Definition: AlgsExecutionStates.h:34
std::vector::size
T size(T...args)
AlgsExecutionStates::m_states
std::vector< State > m_states
Definition: AlgsExecutionStates.h:78
AlgsExecutionStates::DATAREADY
Definition: AlgsExecutionStates.h:35
MSG::ERROR
Definition: IMessageSvc.h:21
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:244
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:14