18#ifndef MBED_CHAINABLEEVENTHANDLER_H_
19#define MBED_CHAINABLEEVENTHANDLER_H_
55 auto eh =
new (std::nothrow) node_t { event_handler,
nullptr };
56 if(!eh) {
return false; }
75 node_t* to_remove = head;
76 if(head->eh == event_handler) {
81 if(it->next->eh == event_handler) {
88 it->next = to_remove->next;
105 if (it == event_handler) {
115 template<
typename... FnArgs,
typename... Args>
116 void execute_on_all(
void (T::*fn)(FnArgs...), Args&&... args) {
121 (it->eh->*fn)(args...);
130 node_t* next =
nullptr;
133 node_t *head =
nullptr;
Base class for chainable EventHandlers.
bool addEventHandler(T *event_handler)
Add an EventHandler to be notified of events sent to this ChainableEventHandler.
bool isEventHandlerPresent(T *event_handler)
Test if an event handler is present in the chain or not.
void removeEventHandler(T *event_handler)
Remove an EventHandler previously added with addEventHandler.