The Gaudi Framework  v30r0 (c919700c)
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 413 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 445 of file PRGraphVisitors.cpp.

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

Reimplemented from concurrency::IGraphVisitor.

Definition at line 405 of file PRGraphVisitors.cpp.

406  {
407 
408  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
409  return false;
410  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:37
bool concurrency::RunSimulator::visitEnter ( AlgorithmNode node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 437 of file PRGraphVisitors.cpp.

438  {
439 
440  if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
441  return false;
442  }
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:37

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: