The Sparta Modeling Framework
Loading...
Searching...
No Matches
PeventTrigger.hpp
1// <PeventTrigger> -*- C++ -*-
2
7#pragma once
8#include "sparta/trigger/Triggerable.hpp"
9#include "sparta/pevents/PeventTreeNode.hpp"
10#include "sparta/simulation/TreeNodePrivateAttorney.hpp"
11namespace sparta
12{
13 using namespace pevents;
14namespace trigger
15{
16
24class PeventTrigger : public Triggerable
25{
26
27public:
28 PeventTrigger(TreeNode* root) :
29 Triggerable(),
30 root_(root)
31 {}
32 virtual ~PeventTrigger(){}
33
34 // Recursively go through and finaly start collectors.
35 // turnOn's for all collectors should of already been done.
36 virtual void go() override
37 {
38 go_(root_);
39 }
41 virtual void stop() override {}
43 virtual void repeat() override {}
44private:
45
46 void go_(TreeNode* root)
47 {
48 PeventCollectorTreeNode* c_node = dynamic_cast<PeventCollectorTreeNode*>(root);
49 if(c_node)
50 {
51 c_node->go();
52 }
53 for(TreeNode* node : TreeNodePrivateAttorney::getAllChildren(root))
54 {
55 go_(node);
56 }
57 }
58 TreeNode* root_;
59};
60
61 }//namespace trigger
62}//namespace sparta
63
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
A simple interface with 2 methods.
virtual void stop() override
The method called when a trigger fires a turn off.
virtual void repeat() override
The method to call on periodic repeats of the trigger.
Macros for handling exponential backoff.