concurrency::RunSimulator Class Reference

#include <src/EFGraphVisitors.h>

Inheritance diagram for concurrency::RunSimulator:
Collaboration diagram for concurrency::RunSimulator:

Public Member Functions

 RunSimulator (const int &slotNum)
 Constructor. More...
 
 ~RunSimulator () override
 Destructor. More...
 
bool visitEnter (DecisionNode &node) const override
 
bool visit (DecisionNode &node) override
 
bool visitLeave (DecisionNode &node) const override
 
bool visitEnter (AlgorithmNode &node) const override
 
bool visit (AlgorithmNode &node) override
 
void reset () override
 
- Public Member Functions inherited from concurrency::IGraphVisitor
virtual ~IGraphVisitor ()
 

Additional Inherited Members

- Public Attributes inherited from concurrency::IGraphVisitor
int m_nodesSucceeded
 
int m_slotNum
 

Detailed Description

Definition at line 9 of file EFGraphVisitors.h.

Constructor & Destructor Documentation

concurrency::RunSimulator::RunSimulator ( const int &  slotNum)
inline

Constructor.

Definition at line 12 of file EFGraphVisitors.h.

12  {
13  m_nodesSucceeded = 0;
14  m_slotNum = slotNum;
15  };
concurrency::RunSimulator::~RunSimulator ( )
inlineoverride

Destructor.

Definition at line 17 of file EFGraphVisitors.h.

17 {}

Member Function Documentation

void concurrency::RunSimulator::reset ( )
inlineoverridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 31 of file EFGraphVisitors.h.

bool concurrency::RunSimulator::visit ( DecisionNode node)
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 14 of file EFGraphVisitors.cpp.

14  {
15 
16  //std::cout << "1-st level Decision: " << node.getNodeName() << std::endl;
17  bool allChildDecisionsResolved = true;
18  for (auto child : node.getDaughters()) {
19  int& childDecision = child->m_graph->getNodeDecisions(m_slotNum)[child->getNodeIndex()];
20 
21  if (childDecision == 1 && node.m_modeOR && node.m_isLazy) {
22  node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] = 1;
23  return true;
24  }
25 
26  if (childDecision == -1) {
27  allChildDecisionsResolved = false;
28  }
29  }
30 
31  if (allChildDecisionsResolved)
32  node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] = 1;
33 
34  return allChildDecisionsResolved;
35  }
bool concurrency::RunSimulator::visit ( AlgorithmNode node)
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 56 of file EFGraphVisitors.cpp.

56  {
57 
58  std::vector<int>& decisions = node.m_graph->getNodeDecisions(m_slotNum);
59  AlgsExecutionStates& states = node.m_graph->getAlgoStates(m_slotNum);
60  int& decision = decisions[node.getNodeIndex()];
61 
62  if (State::INITIAL == states[node.getAlgoIndex()]) {
63  states.updateState(node.getAlgoIndex(), State::CONTROLREADY);
64  if (node.dataDependenciesSatisfied(m_slotNum)) {
65  states.updateState(node.getAlgoIndex(), State::DATAREADY);
66  states.updateState(node.getAlgoIndex(), State::SCHEDULED);
67  states.updateState(node.getAlgoIndex(), State::EVTACCEPTED);
68  decision = 1;
70  //std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
71  return true;
72  }
73  } else if (State::CONTROLREADY == states[node.getAlgoIndex()] && node.dataDependenciesSatisfied(m_slotNum)) {
74  states.updateState(node.getAlgoIndex(), State::DATAREADY);
75  states.updateState(node.getAlgoIndex(), State::SCHEDULED);
76  states.updateState(node.getAlgoIndex(), State::EVTACCEPTED);
77  decision = 1;
79  //std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
80  return true;
81  }
82 
83  return false;
84  }
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
StatusCode updateState(unsigned int iAlgo, State newState)
bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 6 of file EFGraphVisitors.cpp.

6  {
7 
8  if (node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] != 1)
9  return true;
10  return false;
11  }
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 48 of file EFGraphVisitors.cpp.

48  {
49 
50  if (node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] != 1)
51  return true;
52  return false;
53  }
bool concurrency::RunSimulator::visitLeave ( DecisionNode node) const
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 38 of file EFGraphVisitors.cpp.

38  {
39 
40  if (node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] != 1)
41  return true;
42  return false;
43  }

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