19#ifndef MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
20#define MBED_CALLCHAIN_OF_FUNCTION_POINTERS_WITH_CONTEXT_H
84template <
typename ContextType>
86 public SafeBool<CallChainOfFunctionPointersWithContext<ContextType> > {
171 if(*current == toDetach) {
172 if(previous == NULL) {
173 if(currentCalled == current) {
174 currentCalled = NULL;
176 chainHead = current->
getNext();
178 if(currentCalled == current) {
179 currentCalled = previous;
216 return (chainHead != NULL);
234 void call(ContextType context)
const
236 currentCalled = chainHead;
238 while(currentCalled) {
239 currentCalled->
call(context);
241 if(currentCalled == NULL) {
242 currentCalled = chainHead;
244 currentCalled = currentCalled->
getNext();
296 return chainHead != NULL;
307 if (chainHead == NULL) {
Function like object hosting a list of FunctionPointerWithContext.
bool toBool() const
Test if the callchain is empty or not.
void call(ContextType context)
Call sequentially each member of the chain.
CallChainOfFunctionPointersWithContext()
Create an empty callchain.
FunctionPointerWithContext< ContextType > * pFunctionPointerWithContext_t
Alias of the FunctionPointerWithContext type this object can store.
pFunctionPointerWithContext_t add(void(*function)(ContextType context))
Add a function pointer at the front of the chain.
bool detach(const FunctionPointerWithContext< ContextType > &toDetach)
Detach a function pointer from a callchain.
pFunctionPointerWithContext_t add(T *tptr, void(T::*mptr)(ContextType context))
Add a member function bound to its instance at the front of the chain.
virtual ~CallChainOfFunctionPointersWithContext()
Destruction of the callchain.
pFunctionPointerWithContext_t add(const FunctionPointerWithContext< ContextType > &func)
Add a FunctionPointerWithContext at the front of the chain.
void clear()
Remove all functions registered in the chain.
void call(ContextType context) const
Call sequentially each member of the chain.
bool hasCallbacksAttached() const
Check whether the callchain contains any callbacks.
void operator()(ContextType context) const
Call sequentially each member of the chain.
Function like object adapter over freestanding and member functions.
pFunctionPointerWithContext_t getNext() const
Access the next element in the call chain.
void call(ContextType context) const
Call the adapted function and functions chained to the instance.
void chainAsNext(pFunctionPointerWithContext_t next)
Set a FunctionPointer instance as the next element in the chain of callable objects.
Safe conversion of objects in boolean context.