prova invio BLE
Dependents: BLE_HeartRate_IDB04A1
Fork of BLE_API by
Diff: ble/CallChainOfFunctionPointersWithContext.h
- Revision:
- 952:8a6c287de1be
- Parent:
- 949:1902cbd0dd83
- Child:
- 953:f6eb43f524b2
diff -r 2dc552be2b94 -r 8a6c287de1be ble/CallChainOfFunctionPointersWithContext.h --- a/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:09 2015 +0000 +++ b/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:33 2015 +0000 @@ -97,6 +97,34 @@ return common_add(new FunctionPointerWithContext<ContextType>(tptr, mptr)); } + /** + * 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) { + chainHead = current->getNext(); + } else { + previous->chainAsNext(current->getNext()); + } + delete current; + return true; + } + + previous = current; + current = current->getNext(); + } + return false; + } + /** Clear the call chain (remove all functions in the chain). */ void clear(void) {