The Sparta Modeling Framework
Loading...
Searching...
No Matches
EventNode.hpp
Go to the documentation of this file.
1// <EventNode.h> -*- C++ -*-
2
3
10#pragma once
11
12#include <set>
13#include <memory>
14#include <string>
15
20
21namespace sparta
22{
23
24 // Forward declare the Scheduler -- not used by EventNode
25 class Scheduler;
26 class Scheduleable;
27 class StartupEvent;
28
35 class EventNode : public TreeNode
36 {
37 protected:
38
45 EventNode(TreeNode * event_set,
46 const std::string & name,
47 sparta::SchedulingPhase sched_phase) :
48 TreeNode(nullptr, name, name + " EventNode"),
49 sched_phase_(sched_phase)
50 {
51 sparta_assert(event_set != nullptr,
52 "Events must created with an EventSet: " << name);
53 setExpectedParent_(event_set);
54 ensureParentIsEventSet_(event_set);
55 event_set->addChild(this);
56 }
57
59 EventNode(const EventNode&) = delete;
60
62 EventNode(EventNode&&) = delete;
63
65 EventNode& operator=(const EventNode &) = delete;
66
68 virtual ~EventNode() = default;
69
71 static Scheduler * determineScheduler(const Clock * clk) {
72 if (!clk) {
73 return nullptr;
74 }
75 auto scheduler = clk->getScheduler();
76 sparta_assert(scheduler, "Clock with no scheduler passed to EventNode::determineScheduler()");
77 return scheduler;
78 }
79
80 friend StartupEvent;
81
82 public:
83
87 const char * getLabel() const {
88 return getName().c_str();
89 }
90
94 return sched_phase_;
95 }
96
99
115 virtual void participateInAutoPrecedence(bool participate) {
116 participate_in_auto_precedence_ = participate;
117 }
118
122 virtual bool doesParticipateInAutoPrecedence() const {
123 return participate_in_auto_precedence_;
124 }
125
126 private:
127
129 void ensureParentIsEventSet_(sparta::TreeNode* parent);
130
132 const sparta::SchedulingPhase sched_phase_;
133
135 bool participate_in_auto_precedence_ = true;
136 };
137}
138
139
File that defines the Clock class.
File that defines the phases used in simulation.
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Basic Node framework in sparta device tree composite pattern.
A representation of simulated time.
Definition Clock.hpp:51
Scheduler * getScheduler() const
Definition Clock.hpp:302
EventNode is the base class for all event types in SPARTA. Not to be used by the modeler....
Definition EventNode.hpp:36
EventNode(TreeNode *event_set, const std::string &name, sparta::SchedulingPhase sched_phase)
Create an Event Node.
Definition EventNode.hpp:45
const char * getLabel() const
Get the name of this EventNode as registered in the consumer handler for the TopoSortable.
Definition EventNode.hpp:87
virtual ~EventNode()=default
Destroy! Does nothing.
virtual void participateInAutoPrecedence(bool participate)
Turn on/off auto precedence for this EvendNode.
EventNode(EventNode &&)=delete
Do not allow moves.
EventNode & operator=(const EventNode &)=delete
Do not allow assignments.
sparta::SchedulingPhase getSchedulingPhase() const
Get the scheduling phase of this event node.
Definition EventNode.hpp:93
EventNode(const EventNode &)=delete
Do not allow copies.
virtual Scheduleable & getScheduleable()=0
Get the scheduleable associated with this event node.
virtual bool doesParticipateInAutoPrecedence() const
Does this EventNode participate in auto-precedence establishment by sparta::Unit?
static Scheduler * determineScheduler(const Clock *clk)
Center point of Scheduler location.
Definition EventNode.hpp:71
A class that defines the basic scheduling interface to the Scheduler. Not intended to be used by mode...
A class that lets you schedule events now and in the future.
StartupEvent is a simple class for scheduling a starting event on the Scheduler. It does not support ...
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
void addChild(TreeNode *child, bool inherit_phase=true)
Adds a TreeNode to this node as a child.
const std::string & getName() const override
Gets the name of this node.
void setExpectedParent_(const TreeNode *parent)
Tracks a node as an expected parent without actually adding this node as a child. This is used almost...
Macros for handling exponential backoff.
SchedulingPhase
The SchedulingPhases used for events (Tick, Update, PortUpdate, etc)