From bcfae7d4e508975027ef0dbc6542d37cd93b9c20 Mon Sep 17 00:00:00 2001 From: Ake Hedman Date: Wed, 13 Nov 2024 15:28:19 +0100 Subject: [PATCH] Normalized callback initializers --- database | Bin 1507328 -> 1507328 bytes .../database/vscp-hashtypeevents.sqlite3 | Bin 1507328 -> 1507328 bytes src/vscp/common/vscp-client-canal.cpp | 8 ++++---- src/vscp/common/vscp-client-canal.h | 4 ++-- src/vscp/common/vscp-client-socketcan.cpp | 8 ++++---- src/vscp/common/vscp-client-socketcan.h | 18 ++++++++++-------- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/database b/database index 87b0bc90b5414d2038c2d21e2a6b2a6e16663155..b1628d11ad25d780a0481d9c05f7faa779d8e0a1 100644 GIT binary patch delta 105 zcmZo@h-m<#7RDB)7UmX~7Soo callback) +vscpClientCanal::setCallbackEv(std::function callback, void *pData) { // Can not be called when connected if (m_bConnected) { @@ -516,7 +516,7 @@ vscpClientCanal::setCallbackEv(std::function ca } spdlog::debug("CANAL CLIENT: ev callback set."); - CVscpClient::setCallbackEv(callback); + CVscpClient::setCallbackEv(callback, pData); return VSCP_ERROR_SUCCESS; } @@ -525,7 +525,7 @@ vscpClientCanal::setCallbackEv(std::function ca // int -vscpClientCanal::setCallbackEx(std::function callback) +vscpClientCanal::setCallbackEx(std::function callback, void *pData) { // Can not be called when connected if (m_bConnected) { @@ -534,7 +534,7 @@ vscpClientCanal::setCallbackEx(std::function } spdlog::debug("CANAL CLIENT: ex callback set."); - CVscpClient::setCallbackEx(callback); + CVscpClient::setCallbackEx(callback, pData); return VSCP_ERROR_SUCCESS; } diff --git a/src/vscp/common/vscp-client-canal.h b/src/vscp/common/vscp-client-canal.h index fef2c87a4..e89a08c50 100644 --- a/src/vscp/common/vscp-client-canal.h +++ b/src/vscp/common/vscp-client-canal.h @@ -161,13 +161,13 @@ class vscpClientCanal : public CVscpClient { Set (and enable) receive callback for events @return Return VSCP_ERROR_SUCCESS of OK and error code else. */ - virtual int setCallbackEv(std::function callback); + virtual int setCallbackEv(std::function callback, void *pData = nullptr); /*! Set (and enable) receive callback ex events @return Return VSCP_ERROR_SUCCESS of OK and error code else. */ - virtual int setCallbackEx(std::function callback); + virtual int setCallbackEx(std::function callback, void *pData = nullptr); /*! Return a JSON representation of connection diff --git a/src/vscp/common/vscp-client-socketcan.cpp b/src/vscp/common/vscp-client-socketcan.cpp index d379f4e66..49e452004 100644 --- a/src/vscp/common/vscp-client-socketcan.cpp +++ b/src/vscp/common/vscp-client-socketcan.cpp @@ -696,14 +696,14 @@ vscpClientSocketCan::sendToCallbacks(vscpEvent *pev) // int -vscpClientSocketCan::setCallbackEv(std::function callback) +vscpClientSocketCan::setCallbackEv(std::function callback, void *pData ) { // Can not be called when connected if (m_bConnected) { return VSCP_ERROR_ERROR; } - CVscpClient::setCallbackEv(callback); + CVscpClient::setCallbackEv(callback, pData); return VSCP_ERROR_SUCCESS; } @@ -713,14 +713,14 @@ vscpClientSocketCan::setCallbackEv(std::function callback) +vscpClientSocketCan::setCallbackEx(std::function callback, void *pData ) { // Can not be called when connected if (m_bConnected) { return VSCP_ERROR_ERROR; } - CVscpClient::setCallbackEx(callback); + CVscpClient::setCallbackEx(callback, pData); return VSCP_ERROR_SUCCESS; } diff --git a/src/vscp/common/vscp-client-socketcan.h b/src/vscp/common/vscp-client-socketcan.h index 8a3eef153..75e927551 100644 --- a/src/vscp/common/vscp-client-socketcan.h +++ b/src/vscp/common/vscp-client-socketcan.h @@ -43,19 +43,19 @@ #include #include -#include #include +#include #include #include #include -#include #include -#include #include +#include +#include #include #include -#include +#include #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/spdlog.h" @@ -123,7 +123,7 @@ class vscpClientSocketCan : public CVscpClient { Set state of connected flag @param b True for connected, false for not connected. */ - void setConnected(bool b=true) {m_bConnected = b;}; + void setConnected(bool b = true) { m_bConnected = b; }; /*! Send VSCP event to remote host. @@ -211,13 +211,15 @@ class vscpClientSocketCan : public CVscpClient { Set (and enable) receive callback for events @return Return VSCP_ERROR_SUCCESS of OK and error code else. */ - virtual int setCallbackEv(std::function callback); + //using CVscpClient::setCallbackEv; + virtual int setCallbackEv(std::function callback, void *pData = nullptr); /*! Set (and enable) receive callback ex events @return Return VSCP_ERROR_SUCCESS of OK and error code else. */ - virtual int setCallbackEx(std::function callback); + //using CVscpClient::setCallbackEx; + virtual int setCallbackEx(std::function callback, void *pData = nullptr); /*! Return a JSON representation of connection @@ -293,7 +295,7 @@ class vscpClientSocketCan : public CVscpClient { // ------------------------------------------------------------------------ // Event lists - //std::list m_sendList; + // std::list m_sendList; std::list m_receiveList; /*!