Skip to content

Commit 871522c

Browse files
authored
Merge pull request #14256 from pan-/ble-chainable-event-handler-test
BLE: Add API to test the presence of an event handler in a chain.
2 parents 533e633 + edd7678 commit 871522c

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

connectivity/FEATURE_BLE/include/ble/common/ChainableEventHandler.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ class ChainableEventHandler
7171
*
7272
* @param[in] event_handler Pointer to event handler to remove
7373
*/
74-
void removeEventHandler(T* target) {
74+
void removeEventHandler(T* event_handler) {
7575
node_t* to_remove = head;
76-
if(head->eh == target) {
76+
if(head->eh == event_handler) {
7777
head = head->next;
7878
} else {
7979
auto* it = head;
8080
while(it->next) {
81-
if(it->next->eh == target) {
81+
if(it->next->eh == event_handler) {
8282
to_remove = it->next;
8383
break;
8484
}
@@ -94,6 +94,22 @@ class ChainableEventHandler
9494
delete to_remove;
9595
}
9696

97+
/**
98+
* Test if an event handler is present in the chain or not.
99+
*
100+
* @param[in] event_handler Pointer to event handler to check
101+
*/
102+
bool isEventHandlerPresent(T* event_handler) {
103+
auto* it = head;
104+
while (it) {
105+
if (it == event_handler) {
106+
return true;
107+
}
108+
it = it->next;
109+
}
110+
return false;
111+
}
112+
97113
protected:
98114

99115
template<typename... FnArgs, typename... Args>

0 commit comments

Comments
 (0)