📛 Renames cb to callback

This commit is contained in:
Rune Harlyk
2024-11-23 12:57:17 +01:00
parent e109f3584a
commit b37e8706a6
@@ -40,19 +40,19 @@ typedef std::function<void(const String &originId, StateUpdateResult &result)> S
typedef struct StateUpdateHandlerInfo { typedef struct StateUpdateHandlerInfo {
static inline update_handler_id_t currentUpdatedHandlerId = 0; static inline update_handler_id_t currentUpdatedHandlerId = 0;
update_handler_id_t _id; update_handler_id_t _id;
StateUpdateCallback _cb; StateUpdateCallback _callback;
bool _allowRemove; bool _allowRemove;
StateUpdateHandlerInfo(StateUpdateCallback cb, bool allowRemove) StateUpdateHandlerInfo(StateUpdateCallback callback, bool allowRemove)
: _id(++currentUpdatedHandlerId), _cb(cb), _allowRemove(allowRemove) {}; : _id(++currentUpdatedHandlerId), _callback(callback), _allowRemove(allowRemove) {};
} StateUpdateHandlerInfo_t; } StateUpdateHandlerInfo_t;
typedef struct StateHookHandlerInfo { typedef struct StateHookHandlerInfo {
static inline hook_handler_id_t currentHookHandlerId = 0; static inline hook_handler_id_t currentHookHandlerId = 0;
hook_handler_id_t _id; hook_handler_id_t _id;
StateHookCallback _cb; StateHookCallback _callback;
bool _allowRemove; bool _allowRemove;
StateHookHandlerInfo(StateHookCallback cb, bool allowRemove) StateHookHandlerInfo(StateHookCallback callback, bool allowRemove)
: _id(++currentHookHandlerId), _cb(cb), _allowRemove(allowRemove) {}; : _id(++currentHookHandlerId), _callback(callback), _allowRemove(allowRemove) {};
} StateHookHandlerInfo_t; } StateHookHandlerInfo_t;
template <class T> template <class T>
@@ -62,11 +62,10 @@ class StatefulService {
StatefulService(Args &&...args) StatefulService(Args &&...args)
: _state(std::forward<Args>(args)...), _accessMutex(xSemaphoreCreateRecursiveMutex()) {} : _state(std::forward<Args>(args)...), _accessMutex(xSemaphoreCreateRecursiveMutex()) {}
update_handler_id_t addUpdateHandler(StateUpdateCallback cb, bool allowRemove = true) { update_handler_id_t addUpdateHandler(StateUpdateCallback callback, bool allowRemove = true) {
if (!cb) { if (!callback) return 0;
return 0;
} StateUpdateHandlerInfo_t updateHandler(callback, allowRemove);
StateUpdateHandlerInfo_t updateHandler(cb, allowRemove);
_updateHandlers.push_back(updateHandler); _updateHandlers.push_back(updateHandler);
return updateHandler._id; return updateHandler._id;
} }
@@ -81,11 +80,10 @@ class StatefulService {
} }
} }
hook_handler_id_t addHookHandler(StateHookCallback cb, bool allowRemove = true) { hook_handler_id_t addHookHandler(StateHookCallback callback, bool allowRemove = true) {
if (!cb) { if (!callback) return 0;
return 0;
} StateHookHandlerInfo_t hookHandler(callback, allowRemove);
StateHookHandlerInfo_t hookHandler(cb, allowRemove);
_hookHandlers.push_back(hookHandler); _hookHandlers.push_back(hookHandler);
return hookHandler._id; return hookHandler._id;
} }
@@ -144,13 +142,13 @@ class StatefulService {
void callUpdateHandlers(const String &originId) { void callUpdateHandlers(const String &originId) {
for (const StateUpdateHandlerInfo_t &updateHandler : _updateHandlers) { for (const StateUpdateHandlerInfo_t &updateHandler : _updateHandlers) {
updateHandler._cb(originId); updateHandler._callback(originId);
} }
} }
void callHookHandlers(const String &originId, StateUpdateResult &result) { void callHookHandlers(const String &originId, StateUpdateResult &result) {
for (const StateHookHandlerInfo_t &hookHandler : _hookHandlers) { for (const StateHookHandlerInfo_t &hookHandler : _hookHandlers) {
hookHandler._cb(originId, result); hookHandler._callback(originId, result);
} }
} }