The Gaudi Framework  v29r3 (fa547fc2)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
concurrency::recursive_CF::AlgorithmNode Class Reference

#include <src/ControlFlowGraph.h>

Inheritance diagram for concurrency::recursive_CF::AlgorithmNode:
Collaboration diagram for concurrency::recursive_CF::AlgorithmNode:

Public Member Functions

 AlgorithmNode (ControlFlowGraph &graph, Algorithm *algoPtr, unsigned int nodeIndex, unsigned int algoIndex, bool inverted, bool allPass)
 Constructor. More...
 
void initialize (const std::unordered_map< std::string, unsigned int > &algname_index_map) override
 Initialize. More...
 
AlgorithmgetAlgorithm () const
 get Algorithm representatives More...
 
int updateState (AlgsExecutionStates &states, std::vector< int > &node_decisions) const override
 Method to set algos to CONTROLREADY, if possible. More...
 
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. More...
 
- Public Member Functions inherited from concurrency::recursive_CF::ControlFlowNode
 ControlFlowNode (ControlFlowGraph &graph, unsigned int nodeIndex, const std::string &name)
 Constructor. More...
 
virtual ~ControlFlowNode ()
 Destructor. More...
 
const unsigned int & getNodeIndex () const
 Get node index. More...
 
const std::stringgetNodeName () const
 Get node name. More...
 

Private Attributes

unsigned int m_algoIndex
 The index of the algorithm. More...
 
std::string m_algoName
 The name of the algorithm. More...
 
bool m_inverted
 Whether the selection result is negated or not. More...
 
bool m_allPass
 Whether the selection result is relevant or always "pass". More...
 
Algorithmm_algorithm
 Algorithm representative behind the AlgorithmNode. More...
 

Additional Inherited Members

- Public Attributes inherited from concurrency::recursive_CF::ControlFlowNode
ControlFlowGraphm_graph
 
- Protected Member Functions inherited from concurrency::recursive_CF::ControlFlowNode
std::string stateToString (const int &stateId) const
 Translation between state id and name. More...
 
- Protected Attributes inherited from concurrency::recursive_CF::ControlFlowNode
unsigned int m_nodeIndex
 
std::string m_nodeName
 

Detailed Description

Definition at line 101 of file ControlFlowGraph.h.

Constructor & Destructor Documentation

concurrency::recursive_CF::AlgorithmNode::AlgorithmNode ( ControlFlowGraph graph,
Algorithm algoPtr,
unsigned int  nodeIndex,
unsigned int  algoIndex,
bool  inverted,
bool  allPass 
)
inline

Constructor.

Definition at line 105 of file ControlFlowGraph.h.

107  : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
108  , m_algoIndex( algoIndex )
109  , m_algoName( algoPtr->name() )
110  , m_inverted( inverted )
111  , m_allPass( allPass )
112  , m_algorithm( algoPtr ){};
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
std::string m_algoName
The name of the algorithm.
ControlFlowNode(ControlFlowGraph &graph, unsigned int nodeIndex, const std::string &name)
Constructor.
bool m_allPass
Whether the selection result is relevant or always "pass".
bool m_inverted
Whether the selection result is negated or not.
unsigned int m_algoIndex
The index of the algorithm.

Member Function Documentation

Algorithm* concurrency::recursive_CF::AlgorithmNode::getAlgorithm ( ) const
inline

get Algorithm representatives

Definition at line 117 of file ControlFlowGraph.h.

117 { return m_algorithm; }
Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
void concurrency::recursive_CF::AlgorithmNode::initialize ( const std::unordered_map< std::string, unsigned int > &  algname_index_map)
overridevirtual

Initialize.

Implements concurrency::recursive_CF::ControlFlowNode.

Definition at line 97 of file ControlFlowGraph.cpp.

98  {
99 
100  m_algoIndex = algname_index_map.at( m_algoName );
101  }
std::string m_algoName
The name of the algorithm.
unsigned int m_algoIndex
The index of the algorithm.
void concurrency::recursive_CF::AlgorithmNode::printState ( std::stringstream output,
AlgsExecutionStates states,
const std::vector< int > &  node_decisions,
const unsigned int &  recursionLevel 
) const
overridevirtual

Print a string representing the control flow state.

Implements concurrency::recursive_CF::ControlFlowNode.

Definition at line 104 of file ControlFlowGraph.cpp.

106  {
107  output << std::string( recursionLevel, ' ' ) << m_nodeName << " (" << m_nodeIndex << ")"
108  << ", w/ decision: " << stateToString( node_decisions[m_nodeIndex] ) << "(" << node_decisions[m_nodeIndex]
109  << ")"
110  << ", in state: " << AlgsExecutionStates::stateNames[states[m_algoIndex]] << std::endl;
111  }
std::string stateToString(const int &stateId) const
Translation between state id and name.
T endl(T...args)
STL class.
unsigned int m_algoIndex
The index of the algorithm.
static std::map< State, std::string > stateNames
int concurrency::recursive_CF::AlgorithmNode::updateState ( AlgsExecutionStates states,
std::vector< int > &  node_decisions 
) const
overridevirtual

Method to set algos to CONTROLREADY, if possible.

Implements concurrency::recursive_CF::ControlFlowNode.

Definition at line 114 of file ControlFlowGraph.cpp.

115  {
116  // check whether we already had a result earlier
117  // if (-1 != node_decisions[m_nodeIndex] ) { return node_decisions[m_nodeIndex]; }
118  // since we reached this point in the control flow, this algorithm is supposed to run
119  // if it hasn't already
120  const State& state = states[m_algoIndex];
121  unsigned int decision = -1;
122  if ( State::INITIAL == state ) {
123  states.updateState( m_algoIndex, State::CONTROLREADY ).ignore();
124  }
125  // now derive the proper result to pass back
126  if ( true == m_allPass ) {
127  decision = 1;
128  } else if ( State::EVTACCEPTED == state ) {
129  decision = !m_inverted;
130  } else if ( State::EVTREJECTED == state ) {
131  decision = m_inverted;
132  } else {
133  decision = -1; // result not known yet
134  }
135  node_decisions[m_nodeIndex] = decision;
136  return decision;
137  }
bool m_allPass
Whether the selection result is relevant or always "pass".
bool m_inverted
Whether the selection result is negated or not.
void ignore() const
Definition: StatusCode.h:84
unsigned int m_algoIndex
The index of the algorithm.
State
Execution states of the algorithms.
StatusCode updateState(unsigned int iAlgo, State newState)

Member Data Documentation

unsigned int concurrency::recursive_CF::AlgorithmNode::m_algoIndex
private

The index of the algorithm.

Definition at line 126 of file ControlFlowGraph.h.

std::string concurrency::recursive_CF::AlgorithmNode::m_algoName
private

The name of the algorithm.

Definition at line 128 of file ControlFlowGraph.h.

Algorithm* concurrency::recursive_CF::AlgorithmNode::m_algorithm
private

Algorithm representative behind the AlgorithmNode.

Definition at line 134 of file ControlFlowGraph.h.

bool concurrency::recursive_CF::AlgorithmNode::m_allPass
private

Whether the selection result is relevant or always "pass".

Definition at line 132 of file ControlFlowGraph.h.

bool concurrency::recursive_CF::AlgorithmNode::m_inverted
private

Whether the selection result is negated or not.

Definition at line 130 of file ControlFlowGraph.h.


The documentation for this class was generated from the following files: