The Gaudi Framework  v30r1 (5d4f4ae2)
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 499 of file PRGraphVisitors.cpp.

500  {
501 
502  // std::cout << "1-st level Decision: " << node.getNodeName() << std::endl;
503  bool allChildDecisionsResolved = true;
504  for ( auto child : node.getDaughters() ) {
505  int& childDecision = m_slot->controlFlowState[child->getNodeIndex()];
506 
507  if ( childDecision == 1 && node.m_modeOR && node.m_modePromptDecision ) {
508  m_slot->controlFlowState[node.getNodeIndex()] = 1;
509  return true;
510  }
511 
512  if ( childDecision == -1 ) {
513  allChildDecisionsResolved = false;
514  }
515  }
516 
517  if ( allChildDecisionsResolved ) m_slot->controlFlowState[node.getNodeIndex()] = 1;
518 
519  return allChildDecisionsResolved;
520  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54
bool concurrency::RunSimulator::visit ( AlgorithmNode node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 531 of file PRGraphVisitors.cpp.

532  {
533 
534  auto& states = m_slot->algsStates;
535  int& decision = m_slot->controlFlowState[node.getNodeIndex()];
536 
537  auto dataPromoter = DataReadyPromoter( *m_slot, m_cause );
538 
539  if ( State::INITIAL == states[node.getAlgoIndex()] ) {
540  states.updateState( node.getAlgoIndex(), State::CONTROLREADY );
541  if ( dataPromoter.visit( node ) ) {
542  states.updateState( node.getAlgoIndex(), State::SCHEDULED );
543  states.updateState( node.getAlgoIndex(), State::EVTACCEPTED );
544  decision = 1;
546  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
547  return true;
548  }
549  } else if ( State::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit( node ) ) {
550  states.updateState( node.getAlgoIndex(), State::SCHEDULED );
551  states.updateState( node.getAlgoIndex(), State::EVTACCEPTED );
552  decision = 1;
554  // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
555  return true;
556  }
557 
558  return false;
559  }
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:50
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54
bool concurrency::RunSimulator::visitEnter ( DecisionNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 491 of file PRGraphVisitors.cpp.

492  {
493 
494  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
495  return false;
496  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 523 of file PRGraphVisitors.cpp.

524  {
525 
526  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
527  return false;
528  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:54

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: