The Gaudi Framework  v32r2 (46d42edc)
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  //--------------------------------------------------------------------------
14  public:
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  //--------------------------------------------------------------------------
34  public:
36  ActiveLineageScout( const EventSlot* slot, const ControlFlowNode& node )
37  : m_slot( slot ), m_startNode( node ), m_previousNodeName( node.getNodeName() ){};
38 
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;
51  };
52 
53  virtual bool reply() const { return m_active; };
54 
55  virtual void visitParents( DecisionNode& );
56 
57  protected:
58  const EventSlot* m_slot;
60  bool m_active{true};
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 );
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_ */
const ControlFlowNode & m_startNode
Definition: Validators.h:59
virtual void visitParents(DecisionNode &)
Definition: Validators.cpp:53
Class representing an event slot.
Definition: EventSlot.h:14
const std::string & getNodeName() const
Get node name.
SubSlotScout(const EventSlot *slot, const ControlFlowNode &node)
Constructor.
Definition: Validators.h:68
bool visit(DecisionNode &) override
Definition: Validators.cpp:5
ActiveLineageScout(const EventSlot *slot, const ControlFlowNode &node)
Constructor.
Definition: Validators.h:36
virtual bool visit(DecisionNode &)
Definition: IGraphVisitor.h:16
virtual bool visitEnter(DecisionNode &) const
Definition: IGraphVisitor.h:15
bool visit(DecisionNode &) override
Definition: Validators.cpp:25
bool visitEnter(AlgorithmNode &) const override
Definition: Validators.h:18
STL class.
bool visitEnter(ConditionNode &) const override
Definition: Validators.h:44
bool reply() const override
Definition: Validators.h:79
T str(T... args)
void visitParents(DecisionNode &) override
Definition: Validators.cpp:66
bool visitEnter(DataNode &) const override
Definition: Validators.h:43
bool visitEnter(ConditionNode &) const override
Definition: Validators.h:20
bool visitEnter(DataNode &) const override
Definition: Validators.h:19
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86
bool visitEnter(AlgorithmNode &) const override
Definition: Validators.h:42
const EventSlot * m_slot
Definition: Validators.h:58
void reset() override
Definition: Validators.h:71
virtual bool reply() const
Definition: Validators.h:53