Function like object hosting a list of FunctionPointerWithContext. More...
#include <CallChainOfFunctionPointersWithContext.h>
Public Types | |
typedef FunctionPointerWithContext< ContextType > * | pFunctionPointerWithContext_t |
Alias of the FunctionPointerWithContext type this object can store. More... | |
Public Member Functions | |
CallChainOfFunctionPointersWithContext () | |
Create an empty callchain. More... | |
virtual | ~CallChainOfFunctionPointersWithContext () |
Destruction of the callchain. More... | |
pFunctionPointerWithContext_t | add (void(*function)(ContextType context)) |
Add a function pointer at the front of the chain. More... | |
template<typename T > | |
pFunctionPointerWithContext_t | add (T *tptr, void(T::*mptr)(ContextType context)) |
Add a member function bound to its instance at the front of the chain. More... | |
pFunctionPointerWithContext_t | add (const FunctionPointerWithContext< ContextType > &func) |
Add a FunctionPointerWithContext at the front of the chain. More... | |
bool | detach (const FunctionPointerWithContext< ContextType > &toDetach) |
Detach a function pointer from a callchain. More... | |
void | clear () |
Remove all functions registered in the chain. More... | |
bool | hasCallbacksAttached () const |
Check whether the callchain contains any callbacks. More... | |
void | call (ContextType context) |
Call sequentially each member of the chain. More... | |
void | call (ContextType context) const |
Call sequentially each member of the chain. More... | |
void | operator() (ContextType context) const |
Call sequentially each member of the chain. More... | |
bool | toBool () const |
Test if the callchain is empty or not. More... | |
operator BoolType_t () const | |
Bool operator implementation, derived class must provide a bool toBool() const function. More... | |
Protected Types | |
typedef void(base::* | BoolType_t) () const |
The bool type is a pointer to method that can be used in boolean context. More... | |
Protected Member Functions | |
void | invalidTag () const |
Nonimplemented call, use to disallow conversion between unrelated types. More... | |
void | trueTag () const |
Special member function that indicates a true value. More... | |
Function like object hosting a list of FunctionPointerWithContext.
Upon call, each FunctionPointerWithContext instance present in the object will be called in sequence with the initial parameters.
It can be seen as a variation of the observer pattern this object being the observable, instances of the FunctionPointerWithContext being the observable and the notify/update operation being the function call.
Example:
ContextType | Type of the parameter accepted by the callbacks hosted in the object. |
Definition at line 85 of file common/CallChainOfFunctionPointersWithContext.h.
|
protectedinherited |
The bool type is a pointer to method that can be used in boolean context.
Definition at line 50 of file common/SafeBool.h.
typedef FunctionPointerWithContext<ContextType>* pFunctionPointerWithContext_t |
Alias of the FunctionPointerWithContext type this object can store.
Definition at line 91 of file common/CallChainOfFunctionPointersWithContext.h.
Create an empty callchain.
Definition at line 97 of file common/CallChainOfFunctionPointersWithContext.h.
|
virtual |
Destruction of the callchain.
Definition at line 110 of file common/CallChainOfFunctionPointersWithContext.h.
pFunctionPointerWithContext_t add | ( | void(*)(ContextType context) | function | ) |
Add a function pointer at the front of the chain.
[in] | function | A pointer to a void function. |
function
. Definition at line 122 of file common/CallChainOfFunctionPointersWithContext.h.
pFunctionPointerWithContext_t add | ( | T * | tptr, |
void(T::*)(ContextType context) | mptr | ||
) |
Add a member function bound to its instance at the front of the chain.
[in] | tptr | Pointer to the object to call the member function on. |
[in] | mptr | Pointer to the member function to be called. |
tptr
and mptr
. Definition at line 137 of file common/CallChainOfFunctionPointersWithContext.h.
pFunctionPointerWithContext_t add | ( | const FunctionPointerWithContext< ContextType > & | func | ) |
Add a FunctionPointerWithContext at the front of the chain.
[in] | func | The FunctionPointerWithContext to add. |
func
. Definition at line 149 of file common/CallChainOfFunctionPointersWithContext.h.
void call | ( | ContextType | context | ) |
Call sequentially each member of the chain.
[in] | context | Parameter to pass to the functions called. |
Definition at line 224 of file common/CallChainOfFunctionPointersWithContext.h.
void call | ( | ContextType | context | ) | const |
Call sequentially each member of the chain.
[in] | context | Parameter to pass to the functions called. |
Definition at line 234 of file common/CallChainOfFunctionPointersWithContext.h.
void clear | ( | ) |
Remove all functions registered in the chain.
Definition at line 197 of file common/CallChainOfFunctionPointersWithContext.h.
bool detach | ( | const FunctionPointerWithContext< ContextType > & | toDetach | ) |
Detach a function pointer from a callchain.
[in] | toDetach | FunctionPointerWithContext instance to detach from this callchain. |
Definition at line 165 of file common/CallChainOfFunctionPointersWithContext.h.
bool hasCallbacksAttached | ( | ) | const |
Check whether the callchain contains any callbacks.
Definition at line 214 of file common/CallChainOfFunctionPointersWithContext.h.
|
protectedinherited |
Nonimplemented call, use to disallow conversion between unrelated types.
|
inherited |
Bool operator implementation, derived class must provide a bool toBool() const function.
Definition at line 119 of file common/SafeBool.h.
void operator() | ( | ContextType | context | ) | const |
Call sequentially each member of the chain.
[in] | context | Parameter to pass to the functions called. |
Definition at line 269 of file common/CallChainOfFunctionPointersWithContext.h.
bool toBool | ( | ) | const |
Test if the callchain is empty or not.
Definition at line 294 of file common/CallChainOfFunctionPointersWithContext.h.
|
protectedinherited |
Special member function that indicates a true value.
Definition at line 60 of file common/SafeBool.h.