| The Gaudi Framework v32r1 (f65d50dc)

Validators.h
Go to the documentation of this file.
1 #ifndef VALIDATORS_H_
2 #define VALIDATORS_H_
3
4 #include "../../EventSlot.h"
5 #include "../PrecedenceRulesGraph.h"
6 #include "IGraphVisitor.h"
7
8 #include <sstream>
9
10 namespace concurrency {
11
12 //--------------------------------------------------------------------------
13 class NodePropertiesValidator : public IGraphVisitor {
14 public:
15 using IGraphVisitor::visit;
16 using IGraphVisitor::visitEnter;
17
18 bool visitEnter( AlgorithmNode& ) const override { return false; };
19 bool visitEnter( DataNode& ) const override { return false; };
20 bool visitEnter( ConditionNode& ) const override { return false; };
21
22 bool visit( DecisionNode& ) override;
23
24 std::string reply() const { return m_status.str(); };
25 bool passed() const { return !m_foundViolations; };
26
27 private:
28 std::ostringstream m_status{" No 'Concurrent'/'Prompt' contradictions found"};
29 bool m_foundViolations{false};
30 };
31
32 //--------------------------------------------------------------------------
33 class ActiveLineageScout : public IGraphVisitor {
34 public:
36 ActiveLineageScout( const EventSlot* slot, const ControlFlowNode& node )
37 : m_slot( slot ), m_startNode( node ), m_previousNodeName( node.getNodeName() ){};
38
39 using IGraphVisitor::visit;
40 using IGraphVisitor::visitEnter;
41
42 bool visitEnter( AlgorithmNode& ) const override { return false; };
43 bool visitEnter( DataNode& ) const override { return false; };
44 bool visitEnter( ConditionNode& ) const override { return false; };
45
46 bool visit( DecisionNode& ) override;
47
48 void reset() override {
49 m_active = true;
50 m_previousNodeName = m_startNode.getNodeName();
51 };
52
53 virtual bool reply() const { return m_active; };
54
55 virtual void visitParents( DecisionNode& );
56
57 protected:
58 const EventSlot* m_slot;
59 const ControlFlowNode& m_startNode;
60 bool m_active{true};
61 std::string m_previousNodeName;
62 };
63
64 //--------------------------------------------------------------------------
65 class SubSlotScout final : public ActiveLineageScout {
66 public:
68 SubSlotScout( const EventSlot* slot, const ControlFlowNode& node )
69 : ActiveLineageScout( slot, node ), m_foundEntryPoint( slot->parentSlot == nullptr ){};
70
71 void reset() override {
72 m_active = true;
73
74 // Only look for an entry point if we're in a sub-slot
75 m_foundEntryPoint = ( m_slot->parentSlot == nullptr );
76 m_previousNodeName = m_startNode.getNodeName();
77 };
78
79 bool reply() const override { return m_active && m_foundEntryPoint; };
80
81 void visitParents( DecisionNode& ) override;
82
83 private:
84 bool m_foundEntryPoint{true};
85 };
86 } // namespace concurrency
87
88 #endif /* VALIDATORS_H_ */
concurrency::ActiveLineageScout::m_startNode
const ControlFlowNode & m_startNode
Definition: Validators.h:59
concurrency::ActiveLineageScout::visitParents
virtual void visitParents(DecisionNode &)
Definition: Validators.cpp:53
EventSlot
Class representing an event slot.
Definition: EventSlot.h:14
concurrency::DecisionNode
Definition: PrecedenceRulesGraph.h:430
concurrency::ControlFlowNode::getNodeName
const std::string & getNodeName() const
Get node name.
Definition: PrecedenceRulesGraph.h:420
concurrency::SubSlotScout::SubSlotScout
SubSlotScout(const EventSlot *slot, const ControlFlowNode &node)
Constructor.
Definition: Validators.h:68
concurrency::NodePropertiesValidator::visit
bool visit(DecisionNode &) override
Definition: Validators.cpp:5
concurrency::ActiveLineageScout::ActiveLineageScout
ActiveLineageScout(const EventSlot *slot, const ControlFlowNode &node)
Constructor.
Definition: Validators.h:36
concurrency::DataNode
Definition: PrecedenceRulesGraph.h:555
concurrency::ActiveLineageScout::m_active
bool m_active
Definition: Validators.h:60
concurrency
Definition: PrecedenceRulesGraph.cpp:27
concurrency::SubSlotScout
Definition: Validators.h:65
concurrency::IGraphVisitor::visit
virtual bool visit(DecisionNode &)
Definition: IGraphVisitor.h:16
concurrency::IGraphVisitor::visitEnter
virtual bool visitEnter(DecisionNode &) const
Definition: IGraphVisitor.h:15
concurrency::ActiveLineageScout::visit
bool visit(DecisionNode &) override
Definition: Validators.cpp:25
concurrency::ControlFlowNode
Definition: PrecedenceRulesGraph.h:405
concurrency::NodePropertiesValidator::visitEnter
bool visitEnter(AlgorithmNode &) const override
Definition: Validators.h:18
std::string
STL class.
concurrency::ActiveLineageScout::visitEnter
bool visitEnter(ConditionNode &) const override
Definition: Validators.h:44
concurrency::NodePropertiesValidator::m_status
std::ostringstream m_status
Definition: Validators.h:28
std::ostringstream
STL class.
concurrency::ActiveLineageScout::m_previousNodeName
std::string m_previousNodeName
Definition: Validators.h:61
concurrency::ActiveLineageScout::reset
void reset() override
Definition: Validators.h:48
concurrency::SubSlotScout::m_foundEntryPoint
bool m_foundEntryPoint
Definition: Validators.h:84
concurrency::SubSlotScout::reply
bool reply() const override
Definition: Validators.h:79
std::ostringstream::str
T str(T... args)
concurrency::IGraphVisitor
Definition: IGraphVisitor.h:11
concurrency::SubSlotScout::visitParents
void visitParents(DecisionNode &) override
Definition: Validators.cpp:66
concurrency::ActiveLineageScout
Definition: Validators.h:33
concurrency::ActiveLineageScout::visitEnter
bool visitEnter(DataNode &) const override
Definition: Validators.h:43
concurrency::NodePropertiesValidator::passed
bool passed() const
Definition: Validators.h:25
concurrency::NodePropertiesValidator::visitEnter
bool visitEnter(ConditionNode &) const override
Definition: Validators.h:20
concurrency::NodePropertiesValidator::visitEnter
bool visitEnter(DataNode &) const override
Definition: Validators.h:19
concurrency::ConditionNode
Definition: PrecedenceRulesGraph.h:593
EventSlot::parentSlot
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86
concurrency::AlgorithmNode
Definition: PrecedenceRulesGraph.h:475
concurrency::ActiveLineageScout::visitEnter
bool visitEnter(AlgorithmNode &) const override
Definition: Validators.h:42
IGraphVisitor.h
concurrency::NodePropertiesValidator::reply
std::string reply() const
Definition: Validators.h:24
concurrency::NodePropertiesValidator
Definition: Validators.h:13
concurrency::ActiveLineageScout::m_slot
const EventSlot * m_slot
Definition: Validators.h:58
concurrency::NodePropertiesValidator::m_foundViolations
bool m_foundViolations
Definition: Validators.h:29
concurrency::SubSlotScout::reset
void reset() override
Definition: Validators.h:71
concurrency::ActiveLineageScout::reply
virtual bool reply() const
Definition: Validators.h:53