just a fork
Fork of BLE_API by
Diff: ble/CallChainOfFunctionPointersWithContext.h
- Revision:
- 919:c5b9fac295f5
- Parent:
- 918:2b12b53101ea
- Child:
- 920:d18cff0c4b09
--- a/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:04 2015 +0000 +++ b/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:04 2015 +0000 @@ -97,6 +97,14 @@ return common_add(new FunctionPointerWithContext<ContextType>(tptr, mptr)); } + /** Add a function at the front of the chain. + * + * @param func The FunctionPointerWithContext to add. + */ + void add(const FunctionPointerWithContext<ContextType>& func) { + common_add(new FunctionPointerWithContext<ContextType>(func)); + } + /** * Detach a function pointer from a callchain * @@ -153,6 +161,29 @@ } } + /** + * @brief same as above but const + */ + void call(ContextType context) const { + if (chainHead) { + chainHead->call(context); + } + } + + /** + * @brief same as above but with function call operator + */ + void operator()(ContextType context) const { + call(context); + } + + typedef void (CallChainOfFunctionPointersWithContext::*bool_type)() const; + void True() const {} + + operator bool_type() const { + return chainHead == NULL ? 0 : &CallChainOfFunctionPointersWithContext::True; + } + private: pFunctionPointerWithContext_t common_add(pFunctionPointerWithContext_t pf) { if (chainHead == NULL) {