The Gaudi Framework  v29r0 (ff2e7097)
concurrency::RunSimulator Class Reference

#include <src/PRGraphVisitors.h>

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

Public Member Functions

 RunSimulator (EventSlot &slot, const Cause &cause)
 Constructor. More...
 
bool visitEnter (DecisionNode &) const override
 
bool visit (DecisionNode &) override
 
bool visitEnter (AlgorithmNode &) const override
 
bool visit (AlgorithmNode &) override
 
void reset () override
 
- Public Member Functions inherited from concurrency::IGraphVisitor
virtual ~IGraphVisitor ()=default
 
virtual bool visitEnter (DataNode &) const
 
virtual bool visit (DataNode &)
 
virtual bool visitEnter (ConditionNode &) const
 
virtual bool visit (ConditionNode &)
 

Public Attributes

EventSlotm_slot
 
Cause m_cause
 
int m_nodesSucceeded {0}
 

Detailed Description

Definition at line 135 of file PRGraphVisitors.h.

Constructor & Destructor Documentation

concurrency::RunSimulator::RunSimulator ( EventSlot slot,
const Cause cause 
)
inline

Constructor.

Definition at line 139 of file PRGraphVisitors.h.

139 : m_slot( &slot ), m_cause( cause ){};

Member Function Documentation

void concurrency::RunSimulator::reset ( )
inlineoverridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 152 of file PRGraphVisitors.h.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 408 of file PRGraphVisitors.cpp.

409  {
410 
411  // std::cout << "1-st level Decision: " << node.getNodeName() << std::endl;
412  bool allChildDecisionsResolved = true;
413  for ( auto child : node.getDaughters() ) {
414  int& childDecision = m_slot->controlFlowState[child->getNodeIndex()];
415 
416  if ( childDecision == 1 && node.m_modeOR && node.m_modePromptDecision ) {
417  m_slot->controlFlowState[node.getNodeIndex()] = 1;
418  return true;
419  }
420 
421  if ( childDecision == -1 ) {
422  allChildDecisionsResolved = false;
423  }
424  }
425 
426  if ( allChildDecisionsResolved ) m_slot->controlFlowState[node.getNodeIndex()] = 1;
427 
428  return allChildDecisionsResolved;
429  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::RunSimulator::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 440 of file PRGraphVisitors.cpp.

441  {
442 
443  auto& states = m_slot->algsStates;
444  int& decision = m_slot->controlFlowState[node.getNodeIndex()];
445 
446  auto dataPromoter = DataReadyPromoter( *m_slot, m_cause );
447 
448  if ( State::INITIAL == states[node.getAlgoIndex()] ) {
449  states.updateState( node.getAlgoIndex(), State::CONTROLREADY );
450  if ( dataPromoter.visit( node ) ) {
451  states.updateState( node.getAlgoIndex(), State::SCHEDULED );
452  states.updateState( node.getAlgoIndex(), State::EVTACCEPTED );
453  decision = 1;
455  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
456  return true;
457  }
458  } else if ( State::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit( node ) ) {
459  states.updateState( node.getAlgoIndex(), State::SCHEDULED );
460  states.updateState( node.getAlgoIndex(), State::EVTACCEPTED );
461  decision = 1;
463  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
464  return true;
465  }
466 
467  return false;
468  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:37
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 400 of file PRGraphVisitors.cpp.

401  {
402 
403  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
404  return false;
405  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 432 of file PRGraphVisitors.cpp.

433  {
434 
435  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
436  return false;
437  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43

Member Data Documentation

Cause concurrency::RunSimulator::m_cause

Definition at line 155 of file PRGraphVisitors.h.

int concurrency::RunSimulator::m_nodesSucceeded {0}

Definition at line 156 of file PRGraphVisitors.h.

EventSlot* concurrency::RunSimulator::m_slot

Definition at line 152 of file PRGraphVisitors.h.


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