| The Gaudi Framework v32r1 (f65d50dc)

Validators.cpp
Go to the documentation of this file.
1 #include "Validators.h"
2
3 namespace concurrency {
4 //---------------------------------------------------------------------------
5 bool NodePropertiesValidator::visit( DecisionNode& node ) {
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 //---------------------------------------------------------------------------
25 bool ActiveLineageScout::visit( DecisionNode& node ) {
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 //---------------------------------------------------------------------------
53 void ActiveLineageScout::visitParents( DecisionNode& node ) {
54
55 for ( auto& parent : node.m_parents ) {
56 m_active = true;
57 m_previousNodeName = node.getNodeName();
58 parent->accept( *this );
59
60 // Any active parent means that this node is active
61 if ( this->reply() ) break;
62 }
63 }
64
65 //---------------------------------------------------------------------------
66 void SubSlotScout::visitParents( DecisionNode& node ) {
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;
72 m_slot = m_slot->parentSlot;
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 );
80 m_previousNodeName = node.getNodeName();
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
concurrency::ActiveLineageScout::visitParents
virtual void visitParents(DecisionNode &)
Definition: Validators.cpp:53
EventSlot::entryPoint
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:84
EventSlot
Class representing an event slot.
Definition: EventSlot.h:14
concurrency::DecisionNode::m_parents
std::vector< DecisionNode * > m_parents
Direct parent nodes.
Definition: PrecedenceRulesGraph.h:469
concurrency::DecisionNode
Definition: PrecedenceRulesGraph.h:430
concurrency::ControlFlowNode::getNodeName
const std::string & getNodeName() const
Get node name.
Definition: PrecedenceRulesGraph.h:420
concurrency::NodePropertiesValidator::visit
bool visit(DecisionNode &) override
Definition: Validators.cpp:5
concurrency::ActiveLineageScout::m_active
bool m_active
Definition: Validators.h:60
concurrency
Definition: PrecedenceRulesGraph.cpp:27
concurrency::ActiveLineageScout::visit
bool visit(DecisionNode &) override
Definition: Validators.cpp:25
EventSlot::controlFlowState
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:77
Validators.h
concurrency::NodePropertiesValidator::m_status
std::ostringstream m_status
Definition: Validators.h:28
concurrency::ActiveLineageScout::m_previousNodeName
std::string m_previousNodeName
Definition: Validators.h:61
concurrency::SubSlotScout::m_foundEntryPoint
bool m_foundEntryPoint
Definition: Validators.h:84
concurrency::SubSlotScout::reply
bool reply() const override
Definition: Validators.h:79
concurrency::SubSlotScout::visitParents
void visitParents(DecisionNode &) override
Definition: Validators.cpp:66
concurrency::DecisionNode::getDaughters
const std::vector< ControlFlowNode * > & getDaughters() const
Get children nodes.
Definition: PrecedenceRulesGraph.h:450
concurrency::DecisionNode::m_modePromptDecision
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
Definition: PrecedenceRulesGraph.h:459
concurrency::DecisionNode::m_modeConcurrent
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
Definition: PrecedenceRulesGraph.h:456
EventSlot::parentSlot
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86
concurrency::ControlFlowNode::getNodeIndex
const unsigned int & getNodeIndex() const
Get node index.
Definition: PrecedenceRulesGraph.h:418
concurrency::ActiveLineageScout::m_slot
const EventSlot * m_slot
Definition: Validators.h:58
concurrency::NodePropertiesValidator::m_foundViolations
bool m_foundViolations
Definition: Validators.h:29
concurrency::ActiveLineageScout::reply
virtual bool reply() const
Definition: Validators.h:53