Tool Libs
UMIT-TIROL Institute of Automation and Control Engineering library collection
 
Loading...
Searching...
No Matches
evented.h
Go to the documentation of this file.
1
5#pragma once
6#include "schedule.h"
7namespace Schedule {
26namespace Evented {
32 uint32_t time{};
33 bool schedule(uint32_t t) override {
34 time = t;
35 return true;
36 }
37 };
39 struct Func: public Schedulable {
40 using Call = void (*)(uint32_t);
41 Call func{};
42 Func(Call f): func(f) { }
43 void call() override {
44 return func(time);
45 }
46 };
47
49 template<typename T>
50 struct Method: public Schedulable {
51 using Call = void (T::*)(uint32_t);
52 T* base;
53 Call method;
54 Method(T* b, Call m): base(b), method(m) { }
55 void call() override {
56 return (base->*method)(time);
57 }
58 };
59
63 void call(Func::Call func) {
64 list.append(new Func{func});
65 }
67 template<typename T>
68 void call(T& base, typename Method<T>::Call method) {
69 list.append(new Method<T>{&base, method});
70 }
76 list.append(obj);
77 }
78};
79}}
namespace wrapping all functionality to do with scheduling
Definition evented.h:7
Copyright (c) 2023 IACE.
oneshot callable function wrapper
Definition evented.h:39
void call() override
this method is called to run the Schedulable
Definition evented.h:43
oneshot callable method wrapper
Definition evented.h:50
void call() override
this method is called to run the Schedulable
Definition evented.h:55
registry of evented calls
Definition evented.h:61
void call(Schedule::Schedulable *obj)
register plain Schedulable
Definition evented.h:75
void call(Func::Call func)
register function to be scheduled for calling on Event
Definition evented.h:63
void call(T &base, typename Method< T >::Call method)
register method to be scheduled for calling on Event
Definition evented.h:68
oneshot Schedulable keeps track of the scheduling time, as this will be passed on to the wrapped call
Definition evented.h:31
bool schedule(uint32_t t) override
return true if object should be scheduled at this time
Definition evented.h:33
a registry of Schedulable which can be given to the Scheduler for actual scheduling of calls
Definition schedule.h:36
represents an object that can be scheduled for later calling
Definition schedule.h:20