Skip to content

Commit

Permalink
Add rmw listener apis (#44)
Browse files Browse the repository at this point in the history
* Add stubs for setting listener callbacks

Signed-off-by: Mauro Passerino <[email protected]>

* Address PR suggestions

Signed-off-by: Mauro Passerino <[email protected]>

* Fix linter issues

Signed-off-by: Mauro Passerino <[email protected]>

Co-authored-by: Mauro Passerino <[email protected]>
Co-authored-by: Alberto Soragna <[email protected]>
  • Loading branch information
3 people authored and asorbini committed Mar 18, 2022
1 parent bbdf5af commit 4129331
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 0 deletions.
39 changes: 39 additions & 0 deletions rmw_connextdds/src/rmw_api_impl_ndds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ rmw_take_event(
return rmw_api_connextdds_take_event(event_handle, event_info, taken);
}

rmw_ret_t
rmw_event_set_callback(
rmw_event_t * event,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_event_set_callback(event, callback, user_data);
}
/*****************************************************************************
* Info API
*****************************************************************************/
Expand Down Expand Up @@ -634,6 +642,27 @@ rmw_destroy_service(
{
return rmw_api_connextdds_destroy_service(node, service);
}

rmw_ret_t
rmw_service_set_on_new_request_callback(
rmw_service_t * rmw_service,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_service_set_on_new_request_callback(
rmw_service, callback, user_data);
}

rmw_ret_t
rmw_client_set_on_new_response_callback(
rmw_client_t * rmw_client,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_client_set_on_new_response_callback(
rmw_client, callback, user_data);
}

/*****************************************************************************
* Subscription API
*****************************************************************************/
Expand Down Expand Up @@ -812,6 +841,16 @@ rmw_return_loaned_message_from_subscription(
subscription, loaned_message);
}

rmw_ret_t
rmw_subscription_set_on_new_message_callback(
rmw_subscription_t * rmw_subscription,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_subscription_set_on_new_message_callback(
rmw_subscription, callback, user_data);
}

/*****************************************************************************
* WaitSet API
*****************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions rmw_connextdds_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ set(RMW_CONNEXT_COMMON_SOURCE_CPP
src/common/rmw_impl.cpp
src/common/rmw_impl_waitset_std.cpp
src/common/rmw_info.cpp
src/common/rmw_listener.cpp
src/common/rmw_node.cpp
src/common/rmw_publication.cpp
src/common/rmw_qos.cpp
Expand Down
29 changes: 29 additions & 0 deletions rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ rmw_api_connextdds_take_event(
void * event_info,
bool * taken);

RMW_CONNEXTDDS_PUBLIC
rmw_ret_t
rmw_api_connextdds_event_set_callback(
rmw_event_t * event,
rmw_event_callback_t callback,
const void * user_data);

/*****************************************************************************
* Info API
*****************************************************************************/
Expand Down Expand Up @@ -423,6 +430,21 @@ rmw_ret_t
rmw_api_connextdds_destroy_service(
rmw_node_t * node,
rmw_service_t * service);

RMW_CONNEXTDDS_PUBLIC
rmw_ret_t
rmw_api_connextdds_service_set_on_new_request_callback(
rmw_service_t * rmw_service,
rmw_event_callback_t callback,
const void * user_data);

RMW_CONNEXTDDS_PUBLIC
rmw_ret_t
rmw_api_connextdds_client_set_on_new_response_callback(
rmw_client_t * rmw_client,
rmw_event_callback_t callback,
const void * user_data);

/*****************************************************************************
* Subscription API
*****************************************************************************/
Expand Down Expand Up @@ -547,6 +569,13 @@ rmw_api_connextdds_return_loaned_message_from_subscription(
const rmw_subscription_t * subscription,
void * loaned_message);

RMW_CONNEXTDDS_PUBLIC
rmw_ret_t
rmw_api_connextdds_subscription_set_on_new_message_callback(
rmw_subscription_t * rmw_subscription,
rmw_event_callback_t callback,
const void * user_data);

/*****************************************************************************
* WaitSet API
*****************************************************************************/
Expand Down
76 changes: 76 additions & 0 deletions rmw_connextdds_common/src/common/rmw_listener.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2021 Real-Time Innovations, Inc. (RTI)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "rmw_connextdds/rmw_impl.hpp"

/******************************************************************************
* Event Listener API
******************************************************************************/
rmw_ret_t
rmw_api_connextdds_event_set_callback(
rmw_event_t * event,
rmw_event_callback_t callback,
const void * user_data)
{
UNUSED_ARG(event);
UNUSED_ARG(callback);
UNUSED_ARG(user_data);
RMW_CONNEXT_LOG_ERROR_SET("rmw_event_set_callback not implemented")
return RMW_RET_UNSUPPORTED;
}

/******************************************************************************
* Service Listener API
******************************************************************************/
rmw_ret_t
rmw_api_connextdds_service_set_on_new_request_callback(
rmw_service_t * rmw_service,
rmw_event_callback_t callback,
const void * user_data)
{
UNUSED_ARG(rmw_service);
UNUSED_ARG(callback);
UNUSED_ARG(user_data);
RMW_CONNEXT_LOG_ERROR_SET("rmw_service_set_on_new_request_callback not implemented")
return RMW_RET_UNSUPPORTED;
}

rmw_ret_t
rmw_api_connextdds_client_set_on_new_response_callback(
rmw_client_t * rmw_client,
rmw_event_callback_t callback,
const void * user_data)
{
UNUSED_ARG(rmw_client);
UNUSED_ARG(callback);
UNUSED_ARG(user_data);
RMW_CONNEXT_LOG_ERROR_SET("rmw_client_set_on_new_response_callback not implemented")
return RMW_RET_UNSUPPORTED;
}

/******************************************************************************
* Subscription Listener API
******************************************************************************/
rmw_ret_t
rmw_api_connextdds_subscription_set_on_new_message_callback(
rmw_subscription_t * rmw_subscription,
rmw_event_callback_t callback,
const void * user_data)
{
UNUSED_ARG(rmw_subscription);
UNUSED_ARG(callback);
UNUSED_ARG(user_data);
RMW_CONNEXT_LOG_ERROR_SET("rmw_subscription_set_on_new_message_callback not implemented")
return RMW_RET_UNSUPPORTED;
}
40 changes: 40 additions & 0 deletions rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ rmw_take_event(
return rmw_api_connextdds_take_event(event_handle, event_info, taken);
}

rmw_ret_t
rmw_event_set_callback(
rmw_event_t * event,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_event_set_callback(event, callback, user_data);
}

/*****************************************************************************
* Info API
*****************************************************************************/
Expand Down Expand Up @@ -633,6 +642,27 @@ rmw_destroy_service(
{
return rmw_api_connextdds_destroy_service(node, service);
}

rmw_ret_t
rmw_service_set_on_new_request_callback(
rmw_service_t * rmw_service,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_service_set_on_new_request_callback(
rmw_service, callback, user_data);
}

rmw_ret_t
rmw_client_set_on_new_response_callback(
rmw_client_t * rmw_client,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_client_set_on_new_response_callback(
rmw_client, callback, user_data);
}

/*****************************************************************************
* Subscription API
*****************************************************************************/
Expand Down Expand Up @@ -809,6 +839,16 @@ rmw_return_loaned_message_from_subscription(
subscription, loaned_message);
}

rmw_ret_t
rmw_subscription_set_on_new_message_callback(
rmw_subscription_t * rmw_subscription,
rmw_event_callback_t callback,
const void * user_data)
{
return rmw_api_connextdds_subscription_set_on_new_message_callback(
rmw_subscription, callback, user_data);
}

/*****************************************************************************
* WaitSet API
*****************************************************************************/
Expand Down

0 comments on commit 4129331

Please sign in to comment.