1 #ifndef GAUDIHIVE_CONTROLFLOWGRAPH_H 2 #define GAUDIHIVE_CONTROLFLOWGRAPH_H 6 #include <unordered_map> 19 namespace recursive_CF
41 const std::vector<int>& node_decisions,
const unsigned int& recursionLevel )
const = 0;
62 bool modePromptDecision,
bool modeOR,
bool allPass )
64 , m_modeConcurrent( modeConcurrent )
65 , m_modePromptDecision( modePromptDecision )
67 , m_allPass( allPass )
83 const unsigned int& recursionLevel )
const override;
106 bool inverted,
bool allPass )
108 , m_algoIndex( algoIndex )
109 , m_algoName( algoPtr->
name() )
110 , m_inverted( inverted )
111 , m_allPass( allPass )
112 , m_algorithm( algoPtr ){};
122 const unsigned int& recursionLevel )
const override;
152 if ( m_headNode != 0 )
delete m_headNode;
158 void addHeadNode(
const std::string& headName,
bool modeConcurrent,
bool modePromptDecision,
bool modeOR,
167 bool modePromptDecision,
bool modeOR,
bool allPass );
174 const unsigned int& recursionLevel )
const 176 m_headNode->printState( output, states, node_decisions, recursionLevel );
195 unsigned int m_nodeCounter{0};
197 unsigned int m_algoCounter{0};
DecisionNode(ControlFlowGraph &graph, unsigned int nodeIndex, const std::string &name, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
Constructor.
virtual void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const =0
Print a string representing the control flow state.
std::unordered_map< std::string, DecisionNode * > DecisionHubsMap
std::vector< ControlFlowNode * > m_children
All direct daughter nodes in the tree.
Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
const std::string & getNodeName() const
Get node name.
std::string stateToString(const int &stateId) const
Translation between state id and name.
const unsigned int & getNodeIndex() const
Get node index.
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
unsigned int getControlFlowNodeCounter() const
Get total number of graph nodes.
~ControlFlowGraph() override
Destructor.
bool m_allPass
Whether always passing regardless of daughter results.
Algorithm * getAlgorithm() const
get Algorithm representatives
AlgsExecutionStates::State State
virtual int updateState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const =0
Method to set algos to CONTROLREADY, if possible.
std::string m_algoName
The name of the algorithm.
const std::string & name() const override
Retrieve name of the service.
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
AlgorithmNode(ControlFlowGraph &graph, Algorithm *algoPtr, unsigned int nodeIndex, unsigned int algoIndex, bool inverted, bool allPass)
Constructor.
const std::vector< ControlFlowNode * > & getDaughters() const
ControlFlowNode(ControlFlowGraph &graph, unsigned int nodeIndex, const std::string &name)
Constructor.
ControlFlowGraph * m_graph
This class is used for returning status codes from appropriate routines.
virtual ~ControlFlowNode()
Destructor.
virtual void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map)=0
Initialize.
bool m_allPass
Whether the selection result is relevant or always "pass".
bool m_inverted
Whether the selection result is negated or not.
Base class from which all concrete algorithm classes should be derived.
DecisionNode * getHeadNode() const
Get head node.
void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const
Print a string representing the control flow state.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
unsigned int m_algoIndex
The index of the algorithm.
ControlFlowGraph(const std::string &name, SmartIF< ISvcLocator > svc)
Constructor.
State
Execution states of the algorithms.
std::unordered_map< std::string, AlgorithmNode * > AlgoNodesMap
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)