Skip to content

Commit

Permalink
Normalized callback initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Nov 13, 2024
1 parent 24d846e commit bcfae7d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
Binary file modified database
Binary file not shown.
Binary file modified resources/database/vscp-hashtypeevents.sqlite3
Binary file not shown.
8 changes: 4 additions & 4 deletions src/vscp/common/vscp-client-canal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ vscpClientCanal::getResponseTimeout(void)
//

int
vscpClientCanal::setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> callback)
vscpClientCanal::setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> callback, void *pData)
{
// Can not be called when connected
if (m_bConnected) {
Expand All @@ -516,7 +516,7 @@ vscpClientCanal::setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> ca
}

spdlog::debug("CANAL CLIENT: ev callback set.");
CVscpClient::setCallbackEv(callback);
CVscpClient::setCallbackEv(callback, pData);
return VSCP_ERROR_SUCCESS;
}

Expand All @@ -525,7 +525,7 @@ vscpClientCanal::setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> ca
//

int
vscpClientCanal::setCallbackEx(std::function<void(vscpEventEx &ex, void *pobj)> callback)
vscpClientCanal::setCallbackEx(std::function<void(vscpEventEx &ex, void *pobj)> callback, void *pData)
{
// Can not be called when connected
if (m_bConnected) {
Expand All @@ -534,7 +534,7 @@ vscpClientCanal::setCallbackEx(std::function<void(vscpEventEx &ex, void *pobj)>
}

spdlog::debug("CANAL CLIENT: ex callback set.");
CVscpClient::setCallbackEx(callback);
CVscpClient::setCallbackEx(callback, pData);
return VSCP_ERROR_SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions src/vscp/common/vscp-client-canal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(vscpEvent &ev, void *pobj)> callback);
virtual int setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> 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<void(vscpEventEx &ex, void *pobj)> callback);
virtual int setCallbackEx(std::function<void(vscpEventEx &ex, void *pobj)> callback, void *pData = nullptr);

/*!
Return a JSON representation of connection
Expand Down
8 changes: 4 additions & 4 deletions src/vscp/common/vscp-client-socketcan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,14 @@ vscpClientSocketCan::sendToCallbacks(vscpEvent *pev)
//

int
vscpClientSocketCan::setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> callback)
vscpClientSocketCan::setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> 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;
}
Expand All @@ -713,14 +713,14 @@ vscpClientSocketCan::setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)
//

int
vscpClientSocketCan::setCallbackEx(std::function<void(vscpEventEx &ex, void *pobj)> callback)
vscpClientSocketCan::setCallbackEx(std::function<void(vscpEventEx &ex, void *pobj)> 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;
}

Expand Down
18 changes: 10 additions & 8 deletions src/vscp/common/vscp-client-socketcan.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@
#include <time.h>
#include <unistd.h>

#include <canal.h>
#include <canal-macro.h>
#include <canal.h>
#include <guid.h>
#include <hlo.h>
#include <remotevariablecodes.h>
#include <vscp.h>
#include <vscp-class.h>
#include <vscp-type.h>
#include <vscp-client-base.h>
#include <vscp-type.h>
#include <vscp.h>
#include <vscpdatetime.h>
#include <vscphelper.h>

#include <nlohmann/json.hpp>
#include <nlohmann/json.hpp>

#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/spdlog.h"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<void(vscpEvent &ev, void *pobj)> callback);
//using CVscpClient::setCallbackEv;
virtual int setCallbackEv(std::function<void(vscpEvent &ev, void *pobj)> 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<void(vscpEventEx &ex, void *pobj)> callback);
//using CVscpClient::setCallbackEx;
virtual int setCallbackEx(std::function<void(vscpEventEx &ex, void *pobj)> callback, void *pData = nullptr);

/*!
Return a JSON representation of connection
Expand Down Expand Up @@ -293,7 +295,7 @@ class vscpClientSocketCan : public CVscpClient {
// ------------------------------------------------------------------------

// Event lists
//std::list<vscpEvent *> m_sendList;
// std::list<vscpEvent *> m_sendList;
std::list<vscpEvent *> m_receiveList;

/*!
Expand Down

0 comments on commit bcfae7d

Please sign in to comment.