The Sparta Modeling Framework
Loading...
Searching...
No Matches
StartupEvent.hpp
Go to the documentation of this file.
1// <StartupEvent.h> -*- C++ -*-
2
3
10#pragma once
11
12#include <set>
13#include <memory>
14
18
19namespace sparta
20{
21 namespace trigger {
22 // Temporary.
23 class CycleTrigger;
24 class TimeTrigger;
25 class CounterTrigger;
26 class ManagedTrigger;
27 }
28
62 {
63 public:
64
71 const SpartaHandler & consumer_startupevent_handler)
72 {
74 "You cannot create a StartupEvent outside of resource construction");
75 Scheduler * scheduler = node->getScheduler();
76 if (!scheduler) {
77 scheduler = dynamic_cast<Scheduler*>(node);
78 }
79 if (!scheduler) {
80 std::ostringstream oss;
81 oss << "Could not resolve the Scheduler from the node given to a StartupEvent at location '"
82 << node->getLocation() << "'" << std::endl;
83 throw SpartaException(oss.str());
84 }
85 scheduler->scheduleStartupHandler_(consumer_startupevent_handler);
86 }
87
88 private:
89 // Temporary, until these classes are fixed.
90 friend class trigger::CycleTrigger;
91 friend class trigger::TimeTrigger;
92 friend class trigger::CounterTrigger;
93 friend class trigger::ManagedTrigger;
94
95 StartupEvent(Scheduler * scheduler,
96 const SpartaHandler & consumer_startupevent_handler)
97 {
98 sparta_assert(!scheduler->isFinalized(),
99 "You cannot create a StartupEvent outside of resource construction");
100 scheduler->scheduleStartupHandler_(consumer_startupevent_handler);
101 }
102
103 };
104}
105
106
File that defines the EventNode class.
A simple time-based, event precedence based scheduler.
#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.
TreePhase getPhase() const
Gets the trees current phase.
@ TREE_FINALIZED
Tree and all resources have been instantiated. No more configuration/connection allowed.
A class that lets you schedule events now and in the future.
bool isFinalized() const noexcept override
Is the scheduler finalized.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
StartupEvent is a simple class for scheduling a starting event on the Scheduler. It does not support ...
StartupEvent(TreeNode *node, const SpartaHandler &consumer_startupevent_handler)
Create and schedule a StartupEvent with the given handler.
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
std::string getLocation() const override final
Scheduler * getScheduler(const bool must_exist=false)
Get the scheduler associated with this tree node's root.
Macros for handling exponential backoff.