concurrency::Trigger Class Reference

A visitor, performing full top-down traversals of a graph. More...

#include <src/PRGraphVisitors.h>

Inheritance diagram for concurrency::Trigger:
Collaboration diagram for concurrency::Trigger:

Public Member Functions

 Trigger (const int &slotNum)
 Constructor. More...
 
 ~Trigger () override
 Destructor. More...
 
bool visitEnter (DecisionNode &node) const override
 
bool visit (DecisionNode &node) override
 
bool visitLeave (DecisionNode &) 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

A visitor, performing full top-down traversals of a graph.

Definition at line 38 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 41 of file PRGraphVisitors.h.

41  {
42  m_nodesSucceeded = 0;
43  m_slotNum = slotNum;
44  };
concurrency::Trigger::~Trigger ( )
inlineoverride

Destructor.

Definition at line 46 of file PRGraphVisitors.h.

46 {}

Member Function Documentation

void concurrency::Trigger::reset ( )
inlineoverridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 60 of file PRGraphVisitors.h.

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

Implements concurrency::IGraphVisitor.

Definition at line 97 of file PRGraphVisitors.cpp.

97  {
98 
99  //std::cout << "1-st level Decision: " << node.getNodeName() << std::endl;
100  bool allChildDecisionsResolved = true;
101  for (auto child : node.getDaughters()) {
102  int& childDecision = child->m_graph->getNodeDecisions(m_slotNum)[child->getNodeIndex()];
103 
104  if (childDecision == 1 && node.m_modeOR && node.m_modePromptDecision) {
105  node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] = 1;
106  return true;
107  }
108 
109  if (childDecision == -1) {
110  allChildDecisionsResolved = false;
111  }
112  }
113 
114  if (allChildDecisionsResolved)
115  node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] = 1;
116 
117  return allChildDecisionsResolved;
118  }
bool concurrency::Trigger::visit ( AlgorithmNode node)
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 131 of file PRGraphVisitors.cpp.

131  {
132 
133  bool result = false;
134 
135  auto& decisions = node.m_graph->getNodeDecisions(m_slotNum);
136  auto& states = node.m_graph->getAlgoStates(m_slotNum);
137 
138  // Try to shift an algorithm with I->CF, and then, if successful, with CF->DF
139  if (node.promoteToControlReadyState(m_slotNum,states,decisions))
140  result = node.promoteToDataReadyState(m_slotNum);
141 
142  //returns true only when an algorithm is DF-ready
143  // i.e., the visitor reached its final goal with the algorithm
144  return result;
145  }
bool concurrency::Trigger::visitEnter ( DecisionNode node) const
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 89 of file PRGraphVisitors.cpp.

89  {
90 
91  if (node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] != -1)
92  return false;
93  return true;
94  }
bool concurrency::Trigger::visitEnter ( AlgorithmNode node) const
overridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 123 of file PRGraphVisitors.cpp.

123  {
124 
125  if (node.m_graph->getNodeDecisions(m_slotNum)[node.getNodeIndex()] != -1)
126  return false;
127  return true;
128  }
bool concurrency::Trigger::visitLeave ( DecisionNode ) const
inlineoverridevirtual

Implements concurrency::IGraphVisitor.

Definition at line 52 of file PRGraphVisitors.h.

52 {return true;};

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