prova invio BLE
Dependents: BLE_HeartRate_IDB04A1
Fork of BLE_API by
Diff: ble/CallChainOfFunctionPointersWithContext.h
- Revision:
- 966:9451b90bbb66
- Parent:
- 965:212c16f6247f
- Child:
- 969:61f13bc8edbf
--- a/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:34 2015 +0000 +++ b/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:34 2015 +0000 @@ -97,47 +97,6 @@ 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 - * - * @oaram toDetach FunctionPointerWithContext to detach from this callchain - * - * @return true if a function pointer has been detached and false otherwise - */ - void detach(const FunctionPointerWithContext<ContextType>& toDetach) { - pFunctionPointerWithContext_t current = chainHead; - pFunctionPointerWithContext_t previous = NULL; - - while (current) { - if(*current == toDetach) { - if(previous == NULL) { - if(currentCalled == current) { - currentCalled = NULL; - } - chainHead = current->getNext(); - } else { - if(currentCalled == current) { - currentCalled = previous; - } - previous->chainAsNext(current->getNext()); - } - delete current; - return; - } - - previous = current; - current = current->getNext(); - } - } - /** Clear the call chain (remove all functions in the chain). */ void clear(void) { @@ -161,40 +120,11 @@ * chained FunctionPointers. */ void call(ContextType context) { - ((const CallChainOfFunctionPointersWithContext*) this)->call(context); - } - - /** - * @brief same as above but const - */ - void call(ContextType context) const { - currentCalled = chainHead; - - while(currentCalled) { - currentCalled->call(context); - // if this was the head and the call removed the head - if(currentCalled == NULL) { - currentCalled = chainHead; - } else { - currentCalled = currentCalled->getNext(); - } + 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) { @@ -209,8 +139,6 @@ private: pFunctionPointerWithContext_t chainHead; - mutable pFunctionPointerWithContext_t currentCalled; - /* Disallow copy constructor and assignment operators. */ private: