add "LE Device Address" 0x1B to advertising data types
Fork of BLE_API by
Diff: ble/CallChainOfFunctionPointersWithContext.h
- Revision:
- 965:212c16f6247f
- Parent:
- 961:259acb1c9d04
- Child:
- 966:9451b90bbb66
diff -r 9d12fedb6d69 -r 212c16f6247f ble/CallChainOfFunctionPointersWithContext.h --- a/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:34 2015 +0000 +++ b/ble/CallChainOfFunctionPointersWithContext.h Thu Nov 26 12:52:34 2015 +0000 @@ -118,9 +118,15 @@ while (current) { if(*current == toDetach) { - if(previous == NULL) { + if(previous == NULL) { + if(currentCalled == current) { + currentCalled = NULL; + } chainHead = current->getNext(); } else { + if(currentCalled == current) { + currentCalled = previous; + } previous->chainAsNext(current->getNext()); } delete current; @@ -155,17 +161,23 @@ * chained FunctionPointers. */ void call(ContextType context) { - if (chainHead) { - chainHead->call(context); - } + ((const CallChainOfFunctionPointersWithContext*) this)->call(context); } /** * @brief same as above but const */ void call(ContextType context) const { - if (chainHead) { - chainHead->call(context); + 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(); + } } } @@ -197,6 +209,8 @@ private: pFunctionPointerWithContext_t chainHead; + mutable pFunctionPointerWithContext_t currentCalled; + /* Disallow copy constructor and assignment operators. */ private: