16 else if ( 1 == stateId )
26 for (
auto node : m_children )
delete node;
33 for (
auto daughter : m_children ) daughter->initialize( algname_index_map );
40 if (
std::find( m_children.begin(), m_children.end(), node ) == m_children.end() ) m_children.push_back( node );
45 const std::vector<int>& node_decisions,
const unsigned int& recursionLevel )
const 51 for (
auto daughter : m_children ) {
52 daughter->printState( output, states, node_decisions, recursionLevel + 2 );
61 int decision = ( ( m_allPass && m_modePromptDecision ) ? 1 : -1 );
62 bool hasUndecidedChild =
false;
63 for (
auto daughter : m_children ) {
64 if ( m_modePromptDecision && ( -1 != decision || hasUndecidedChild ) ) {
69 auto res = daughter->updateState( states, node_decisions );
71 hasUndecidedChild =
true;
72 }
else if (
false == m_modeOR && res == 0 ) {
75 else if (
true == m_modeOR && res == 1 ) {
80 if ( !hasUndecidedChild && -1 == decision ) {
82 if (
true == m_modeOR ) {
92 if ( m_allPass ) decision = 1;
100 m_algoIndex = algname_index_map.
at( m_algoName );
105 const std::vector<int>& node_decisions,
const unsigned int& recursionLevel )
const 121 unsigned int decision = -1;
122 if ( State::INITIAL == state ) {
126 if (
true == m_allPass ) {
128 }
else if ( State::EVTACCEPTED == state ) {
129 decision = !m_inverted;
130 }
else if ( State::EVTREJECTED == state ) {
131 decision = m_inverted;
142 m_headNode->initialize( algname_index_map );
152 auto& algoName = algo->
name();
154 auto itP = m_decisionNameToDecisionHubMap.
find( parentName );
156 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
157 parentNode = itP->second;
158 auto itA = m_algoNameToAlgoNodeMap.find( algoName );
160 if ( itA != m_algoNameToAlgoNodeMap.end() ) {
161 algoNode = itA->second;
167 m_algoNameToAlgoNodeMap[algoName] = algoNode;
174 error() <<
"Decision hub node " << parentName <<
", requested to be parent, is not registered." <<
endmsg;
182 bool modeConcurrent,
bool modePromptDecision,
bool modeOR,
188 auto& decisionHubName = decisionHubAlgo->
name();
190 auto itP = m_decisionNameToDecisionHubMap.
find( parentName );
192 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
193 parentNode = itP->second;
194 auto itA = m_decisionNameToDecisionHubMap.find( decisionHubName );
196 if ( itA != m_decisionNameToDecisionHubMap.end() ) {
197 decisionHubNode = itA->second;
200 *
this, m_nodeCounter, decisionHubName, modeConcurrent, modePromptDecision, modeOR, allPass );
202 m_decisionNameToDecisionHubMap[decisionHubName] = decisionHubNode;
204 verbose() <<
"Decision hub node " << decisionHubName <<
" added @ " << decisionHubNode <<
endmsg;
210 error() <<
"Decision hub node " << parentName <<
", requested to be parent, is not registered." <<
endmsg;
218 bool modeOR,
bool allPass )
221 auto itH = m_decisionNameToDecisionHubMap.find( headName );
222 if ( itH != m_decisionNameToDecisionHubMap.end() ) {
223 m_headNode = itH->second;
226 modePromptDecision, modeOR, allPass );
228 m_decisionNameToDecisionHubMap[headName] = m_headNode;
235 m_headNode->updateState( algo_states, node_decisions );
242 dumpControlFlow( ost, m_headNode, 0 );
253 if ( node != m_headNode ) {
257 ost << ( ( dn->
m_modeOR ) ?
" [OR] " :
"" );
258 ost << ( ( dn->
m_allPass ) ?
" [PASS] " :
"" );
263 dumpControlFlow( ost, *itr, indent + 1 );
265 }
else if ( an != 0 ) {
269 ost <<
" [n= " << ar->cardinality() <<
"]";
270 ost << ( ( !ar->isClonable() ) ?
" [unclonable] " :
"" );
void addDaughterNode(ControlFlowNode *node)
Add a daughter node.
const std::string & name() const override
The identifying name of the algorithm object.
void addHeadNode(const std::string &headName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
Add a node, which has no parents.
const std::string & getNodeName() const
Get node name.
std::string stateToString(const int &stateId) const
Translation between state id and name.
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
StatusCode addDecisionHubNode(Algorithm *daughterAlgo, const std::string &parentName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
Add a node, which aggregates decisions of direct daughter nodes.
bool m_allPass
Whether always passing regardless of daughter results.
void updateEventState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const
Start revision of states and decisions.
Algorithm * getAlgorithm() const
get Algorithm representatives
int updateState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const override
Method to set algos to CONTROLREADY, if possible.
void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const override
Print a string representing the control flow state.
void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const override
Print a string representing the control flow state.
int updateState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const override
Method to set algos to CONTROLREADY, if possible.
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
const std::vector< ControlFlowNode * > & getDaughters() const
This class is used for returning status codes from appropriate routines.
~DecisionNode() override
Destructor.
void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map) override
Initialize.
Base class from which all concrete algorithm classes should be derived.
void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map) override
Initialize.
void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map)
Initialize graph.
State
Execution states of the algorithms.
StatusCode addAlgorithmNode(Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
Add algorithm node.
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
static std::map< State, std::string > stateNames
StatusCode updateState(unsigned int iAlgo, State newState)