Skip to content

Commit

Permalink
Reintroduce C API functions that were removed with 5.10 (accidentiall…
Browse files Browse the repository at this point in the history
…y) (#677)
  • Loading branch information
Kerstin-Keller authored May 20, 2022
1 parent 493b920 commit 01068ca
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 2 deletions.
12 changes: 12 additions & 0 deletions ecal/core/include/ecal/cimpl/ecal_client_cimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ extern "C"

/**
* @brief Add server response callback.
* @since eCAL 5.10.0
*
* @param handle_ Client handle.
* @param callback_ Callback function for server response.
Expand All @@ -117,6 +118,17 @@ extern "C"
**/
ECALC_API int eCAL_Client_AddResponseCallback(ECAL_HANDLE handle_, ResponseCallbackCT callback_, void* par_);

/**
* @brief Add server response callback.
*
* @param handle_ Client handle.
* @param callback_ Callback function for server response.
* @param par_ User defined context that will be forwarded to the callback function.
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Client_AddResponseCallbackC(ECAL_HANDLE handle_, ResponseCallbackCT callback_, void* par_);

/**
* @brief Remove server response callback.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extern "C"

/**
* @brief Add callback function for incoming receives.
* @since eCAL 5.10.0
*
* @param handle_ Subscriber handle.
* @param callback_ The callback function to add.
Expand All @@ -60,6 +61,17 @@ extern "C"
**/
ECALC_API int eCAL_Proto_Dyn_JSON_Sub_AddReceiveCallback(ECAL_HANDLE handle_, ReceiveCallbackCT callback_, void* par_);

/**
* @brief Add callback function for incoming receives.
*
* @param handle_ Subscriber handle.
* @param callback_ The callback function to add.
* @param par_ User defined context that will be forwarded to the callback function.
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Proto_Dyn_JSON_Sub_AddReceiveCallbackC(ECAL_HANDLE handle_, ReceiveCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for incoming receives.
*
Expand Down
13 changes: 13 additions & 0 deletions ecal/core/include/ecal/cimpl/ecal_publisher_cimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ extern "C"

/**
* @brief Add callback function for publisher events.
* @since eCAL 5.10.0
*
* @param handle_ Publisher handle.
* @param type_ The event type to react on.
Expand All @@ -241,6 +242,18 @@ extern "C"
**/
ECALC_API int eCAL_Pub_AddEventCallback(ECAL_HANDLE handle_, enum eCAL_Publisher_Event type_, PubEventCallbackCT callback_, void* par_);

/**
* @brief Add callback function for publisher events.
*
* @param handle_ Publisher handle.
* @param type_ The event type to react on.
* @param callback_ The callback function to add.
* @param par_ User defined context that will be forwarded to the callback function.
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Pub_AddEventCallbackC(ECAL_HANDLE handle_, enum eCAL_Publisher_Event type_, PubEventCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for publisher events.
*
Expand Down
28 changes: 27 additions & 1 deletion ecal/core/include/ecal/cimpl/ecal_server_cimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extern "C"

/**
* @brief Add a server method callback.
* @since eCAL 5.10.0
*
* @param handle_ Server handle.
* @param method_ Service method name.
Expand All @@ -61,10 +62,25 @@ extern "C"
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Server_AddMethodCallbackC(ECAL_HANDLE handle_, const char* method_, const char* req_type_, const char* resp_type_, MethodCallbackCT callback_, void * par_);
ECALC_API int eCAL_Server_AddMethodCallback(ECAL_HANDLE handle_, const char* method_, const char* req_type_, const char* resp_type_, MethodCallbackCT callback_, void * par_);

/**
* @brief Add a server method callback.
*
* @param handle_ Server handle.
* @param method_ Service method name.
* @param req_type_ Method request type (default = "").
* @param resp_type_ Method response type (default = "").
* @param callback_ Callback function for server request.
* @param par_ User defined context that will be forwarded to the request function.
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Server_AddMethodCallbackC(ECAL_HANDLE handle_, const char* method_, const char* req_type_, const char* resp_type_, MethodCallbackCT callback_, void* par_);

/**
* @brief Remove a server method callback.
* @since eCAL 5.10.0
*
* @param handle_ Server handle.
* @param method_ Service method name.
Expand All @@ -73,6 +89,16 @@ extern "C"
**/
ECALC_API int eCAL_Server_RemMethodCallback(ECAL_HANDLE handle_, const char* method_);

/**
* @brief Remove a server method callback.
*
* @param handle_ Server handle.
* @param method_ Service method name.
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Server_RemMethodCallbackC(ECAL_HANDLE handle_, const char* method_);

/**
* @brief Add server event callback function.
*
Expand Down
25 changes: 25 additions & 0 deletions ecal/core/include/ecal/cimpl/ecal_subscriber_cimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ extern "C"

/**
* @brief Add callback function for incoming receives.
* @since eCAL 5.10.0
*
* @param handle_ Subscriber handle.
* @param callback_ The callback function to add.
Expand All @@ -187,6 +188,17 @@ extern "C"
**/
ECALC_API int eCAL_Sub_AddReceiveCallback(ECAL_HANDLE handle_, ReceiveCallbackCT callback_, void* par_);

/**
* @brief Add callback function for incoming receives.
*
* @param handle_ Subscriber handle.
* @param callback_ The callback function to add.
* @param par_ User defined context that will be forwarded to the callback function.
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Sub_AddReceiveCallbackC(ECAL_HANDLE handle_, ReceiveCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for incoming receives.
*
Expand All @@ -198,6 +210,7 @@ extern "C"

/**
* @brief Add callback function for subscriber events.
* @since eCAL 5.10.0
*
* @param handle_ Subscriber handle.
* @param type_ The event type to react on.
Expand All @@ -208,6 +221,18 @@ extern "C"
**/
ECALC_API int eCAL_Sub_AddEventCallback(ECAL_HANDLE handle_, enum eCAL_Subscriber_Event type_, SubEventCallbackCT callback_, void* par_);

/**
* @brief Add callback function for subscriber events.
*
* @param handle_ Subscriber handle.
* @param type_ The event type to react on.
* @param callback_ The callback function to add.
* @param par_ User defined context that will be forwarded to the callback function.
*
* @return None zero if succeeded.
**/
ECALC_API int eCAL_Sub_AddEventCallbackC(ECAL_HANDLE handle_, enum eCAL_Subscriber_Event type_, SubEventCallbackCT callback_, void* par_);

/**
* @brief Remove callback function for subscriber events.
*
Expand Down
38 changes: 37 additions & 1 deletion ecal/core/src/ecalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ extern "C"
return(0);
}

ECALC_API int eCAL_Pub_AddEventCallbackC(ECAL_HANDLE handle_, eCAL_Publisher_Event type_, PubEventCallbackCT callback_, void* par_)
{
return eCAL_Pub_AddEventCallback(handle_, type_, callback_, par_);
}

ECALC_API int eCAL_Pub_RemEventCallback(ECAL_HANDLE handle_, eCAL_Publisher_Event type_)
{
if (handle_ == NULL) return(0);
Expand Down Expand Up @@ -869,6 +874,11 @@ extern "C"
return(0);
}

ECALC_API int eCAL_Sub_AddReceiveCallbackC(ECAL_HANDLE handle_, ReceiveCallbackCT callback_, void* par_)
{
return eCAL_Sub_AddReceiveCallback(handle_, callback_, par_);
}

ECALC_API int eCAL_Sub_RemReceiveCallback(ECAL_HANDLE handle_)
{
if(handle_ == NULL) return(0);
Expand All @@ -886,6 +896,11 @@ extern "C"
return(0);
}

ECALC_API int eCAL_Sub_AddEventCallbackC(ECAL_HANDLE handle_, eCAL_Subscriber_Event type_, SubEventCallbackCT callback_, void* par_)
{
return eCAL_Sub_AddEventCallback(handle_, type_, callback_, par_);
}

ECALC_API int eCAL_Sub_RemEventCallback(ECAL_HANDLE handle_, eCAL_Subscriber_Event type_)
{
if (handle_ == NULL) return(0);
Expand Down Expand Up @@ -976,6 +991,11 @@ extern "C"
return(sub->AddReceiveCallback(callback));
}

int eCAL_Proto_Dyn_JSON_Sub_AddReceiveCallbackC(ECAL_HANDLE handle_, const ReceiveCallbackCT callback_, void* par_)
{
return eCAL_Proto_Dyn_JSON_Sub_AddReceiveCallback(handle_, callback_, par_);
}

int eCAL_Proto_Dyn_JSON_Sub_RemReceiveCallback(ECAL_HANDLE handle_)
{
eCAL::protobuf::CDynamicJSONSubscriber* sub = static_cast<eCAL::protobuf::CDynamicJSONSubscriber*>(handle_);
Expand Down Expand Up @@ -1136,21 +1156,31 @@ extern "C"
return(1);
}

ECALC_API int eCAL_Server_AddMethodCallbackC(ECAL_HANDLE handle_, const char* method_, const char* req_type_, const char* resp_type_, MethodCallbackCT callback_, void* par_)
ECALC_API int eCAL_Server_AddMethodCallback(ECAL_HANDLE handle_, const char* method_, const char* req_type_, const char* resp_type_, MethodCallbackCT callback_, void* par_)
{
if (handle_ == NULL) return(0);
eCAL::CServiceServer* server = static_cast<eCAL::CServiceServer*>(handle_);
auto callback = std::bind(g_method_callback, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, callback_, par_);
return server->AddMethodCallback(method_, req_type_, resp_type_, callback);
}

ECALC_API int eCAL_Server_AddMethodCallbackC(ECAL_HANDLE handle_, const char* method_, const char* req_type_, const char* resp_type_, MethodCallbackCT callback_, void* par_)
{
return eCAL_Server_AddMethodCallback(handle_, method_, req_type_, resp_type_, callback_, par_);
}

ECALC_API int eCAL_Server_RemMethodCallback(ECAL_HANDLE handle_, const char* method_)
{
if (handle_ == NULL) return(0);
eCAL::CServiceServer* server = static_cast<eCAL::CServiceServer*>(handle_);
return server->RemMethodCallback(method_);
}

ECALC_API int eCAL_Server_RemMethodCallbackC(ECAL_HANDLE handle_, const char* method_)
{
return eCAL_Server_RemMethodCallback(handle_, method_);
}

ECALC_API int eCAL_Server_AddEventCallback(ECAL_HANDLE handle_, eCAL_Server_Event type_, ServerEventCallbackCT callback_, void* par_)
{
if (handle_ == NULL) return(0);
Expand Down Expand Up @@ -1290,6 +1320,12 @@ int eCAL_Client_AddResponseCallback(ECAL_HANDLE handle_, ResponseCallbackCT call
return client->AddResponseCallback(callback);
}

int eCAL_Client_AddResponseCallbackC(ECAL_HANDLE handle_, ResponseCallbackCT callback_, void* par_)
{
return eCAL_Client_AddResponseCallback(handle_, callback_, par_);
}


int eCAL_Client_RemResponseCallback(ECAL_HANDLE handle_)
{
if(handle_ == NULL) return(0);
Expand Down

0 comments on commit 01068ca

Please sign in to comment.