diff --git a/src/sorters.hpp b/src/sorters.hpp index a5b5ebd..6da03eb 100644 --- a/src/sorters.hpp +++ b/src/sorters.hpp @@ -6,6 +6,7 @@ #include #include +#include "Invoker.hpp" #include "steppable.hpp" //ground truth domain data @@ -40,4 +41,10 @@ public: bool step(); }; +struct SortBinding { + std::shared_ptr input; + std::unique_ptr sort; + std::unique_ptr invoker; +}; + #endif diff --git a/src/timer.cpp b/src/timer.cpp index 5fab8b1..d06d30e 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -16,7 +16,7 @@ void Timer::add_time(milliseconds deltatime) { accumulator += deltatime; if (accumulator >= triggerinterval) { accumulator -= triggerinterval; - callback(); + request(); triggercount++; if (!isinfinite && triggercount >= triggeramount){ isexpired=true; @@ -24,6 +24,10 @@ void Timer::add_time(milliseconds deltatime) { } }; +void Timer::request() { + callback(); +} + void TimerManager::add_timer(size_t triggeramount, function myaction, std::chrono::milliseconds triggerinterval) { Timer mynewtimer(triggeramount, myaction, triggerinterval); timers.push_back(std::move(mynewtimer)); diff --git a/src/timer.hpp b/src/timer.hpp index 47a6b7a..72a2e6d 100644 --- a/src/timer.hpp +++ b/src/timer.hpp @@ -7,8 +7,9 @@ #include #include +#include "Invoker.hpp" //check if the timer is still valid, check if enough time has passed and if so, actuate action -class Timer { +class Timer: public Invoker { public: size_t triggeramount; bool isexpired = false; @@ -18,9 +19,11 @@ public: std::function callback; Timer(size_t triggeramount, std::function myaction, std::chrono::milliseconds triggerinterval); - + void add_time(std::chrono::milliseconds deltatime); + void request(); + private: std::chrono::milliseconds accumulator = std::chrono::milliseconds(0); std::chrono::milliseconds triggerinterval = std::chrono::milliseconds(1000); //default to 1 sec