188 template<>
class Event<void>
191 Event(
const Event&) =
default;
192 Event& operator=(
const Event&) =
default;
208 template<
typename T>
struct Event_trait
210 static constexpr const bool IS_EVENT =
false;
215 template<
typename T>
struct Event_trait<Event<T>>
217 static constexpr const bool IS_EVENT =
true;
222 template<
typename EVENT>
class EventHandler;
243 static_assert(Event_trait<EVENT>::IS_EVENT,
"EVENT type must be an events::Event<T>");
260 this->
traverse(HandlerCaller(event));
267 explicit HandlerCaller(
const EVENT& event)
INLINE : event_{
event} {}
268 bool operator()(EventHandler<EVENT>& handler)
INLINE
270 if (handler.type() == event_.type()) handler.on_event(event_);
289 static_assert(Event_trait<EVENT>::IS_EVENT,
"EVENT type must be an events::Event<T>");
321 friend class Dispatcher<EVENT>;
A wrapper for items stored in a LinkedList.
Linked list of type T_ items.
void traverse(F func)
Traverse all items of this list and execute f functor.
Utility to dispatch an event to a list of EventHandlers that are registered for its type.
void dispatch(const EVENT &event)
Dispatch the given event to the right EventHandler, based on the event type.
Abstract event handler, used by Dispatcher to get called back when an event of the expected type is d...
EventHandler(uint8_t type=Type::NO_EVENT) INLINE
Create an Event Handler for given type of event.
uint8_t type() const INLINE
The type of event that this handler accepts and can act upon.
virtual void on_event(const EVENT &event)=0
This pure virtual method is called by Dispatcher::dispatch() when event.type() matches the type suppo...
A standard Event as managed by FastArduino event API.
T TYPE
The type of additional event value, as defined in template paraneter T.
T value() const INLINE
The associated value of this event.
uint8_t type() const INLINE
The type of this event.
Event(uint8_t type=Type::NO_EVENT, T value=T{}) INLINE
Create a new event with the given type and the given value.
#define INLINE
Specific GCC attribute to force the compiler to always inline code of a given function.
Utility API to handle linked list containers.
const uint8_t NO_EVENT
Special event type attached to no event at all.
const uint8_t USER_EVENT
The first ordinal event type that you may use for your own custom events.
const uint8_t WDT_TIMER
Type of events generated by watchdog::Watchdog for each watchdog timeout interrupt.
const uint8_t RTT_TIMER
Type of events generated by timer::RTTEventCallback whenever elapsed RTT::millis() reaches a multiple...
Defines all API to handle events within FastArduino programs.
Utility API to handle ring-buffer queue containers.