The Gaudi Framework  v32r2 (46d42edc)
Validators.cpp
Go to the documentation of this file.
1 #include "Validators.h"
2 
3 namespace concurrency {
4  //---------------------------------------------------------------------------
6 
7  if ( node.m_modeConcurrent && node.m_modePromptDecision ) {
8 
9  if ( !m_foundViolations )
10  m_status
11  << " 'Concurrent'/'Prompt' contradiction(s) found. Settings are mutually exclusive within a task group. "
12  "Discarding 'Prompt' for ";
13 
14  m_status << ( m_foundViolations ? ", " : "" ) << node.getNodeName();
15 
16  if ( !m_foundViolations ) m_foundViolations = true;
17 
18  return false;
19  }
20 
21  return true;
22  }
23 
24  //---------------------------------------------------------------------------
26 
27  // Test if this node is already resolved
28  if ( m_slot->controlFlowState[node.getNodeIndex()] != -1 ) {
29  m_active = false;
30  return m_active;
31  }
32 
33  // Test if the node that sent this scout is out-of-sequence in this node
34  if ( !node.m_modeConcurrent ) {
35 
36  for ( auto& child : node.getDaughters() ) {
37 
38  if ( child->getNodeName() == m_previousNodeName ) break;
39 
40  if ( m_slot->controlFlowState[child->getNodeIndex()] == -1 ) {
41  m_active = false;
42  return m_active;
43  }
44  }
45  }
46 
47  this->visitParents( node );
48 
49  return this->reply();
50  }
51 
52  //---------------------------------------------------------------------------
54 
55  for ( auto& parent : node.m_parents ) {
56  m_active = true;
58  parent->accept( *this );
59 
60  // Any active parent means that this node is active
61  if ( this->reply() ) break;
62  }
63  }
64 
65  //---------------------------------------------------------------------------
67 
68  // Leave a sub-slot if this is the exit node
69  const EventSlot* oldSlot = nullptr;
70  if ( m_slot->parentSlot && m_slot->entryPoint == node.getNodeName() ) {
71  oldSlot = m_slot;
73  m_foundEntryPoint = true;
74  }
75 
76  // Examine all parents
77  for ( auto& parent : node.m_parents ) {
78  m_active = true;
79  m_foundEntryPoint = ( m_slot->parentSlot == nullptr );
81  parent->accept( *this );
82 
83  // Any active parent means that this node is active
84  if ( this->reply() ) break;
85  }
86 
87  if ( oldSlot ) m_slot = oldSlot;
88  }
89 } // namespace concurrency
virtual void visitParents(DecisionNode &)
Definition: Validators.cpp:53
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:84
Class representing an event slot.
Definition: EventSlot.h:14
std::vector< DecisionNode * > m_parents
Direct parent nodes.
const std::string & getNodeName() const
Get node name.
bool visit(DecisionNode &) override
Definition: Validators.cpp:5
bool visit(DecisionNode &) override
Definition: Validators.cpp:25
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77
bool reply() const override
Definition: Validators.h:79
void visitParents(DecisionNode &) override
Definition: Validators.cpp:66
const std::vector< ControlFlowNode * > & getDaughters() const
Get children nodes.
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86
const unsigned int & getNodeIndex() const
Get node index.
const EventSlot * m_slot
Definition: Validators.h:58
virtual bool reply() const
Definition: Validators.h:53