From b8e3317836152b1523a3a504aed51604d6501a68 Mon Sep 17 00:00:00 2001 From: Mauro Passerino Date: Tue, 27 Apr 2021 09:36:54 -0300 Subject: [PATCH] Address PR suggestions Signed-off-by: Mauro Passerino --- rmw_connextdds/src/rmw_api_impl_ndds.cpp | 30 +++----- rmw_connextdds_common/CMakeLists.txt | 1 + .../include/rmw_connextdds/rmw_api_impl.hpp | 29 +++++++ .../src/common/rmw_listener.cpp | 77 +++++++++++++++++++ .../src/rmw_api_impl_rtime.cpp | 31 +++----- 5 files changed, 126 insertions(+), 42 deletions(-) create mode 100644 rmw_connextdds_common/src/common/rmw_listener.cpp diff --git a/rmw_connextdds/src/rmw_api_impl_ndds.cpp b/rmw_connextdds/src/rmw_api_impl_ndds.cpp index ae5b000d..43239399 100644 --- a/rmw_connextdds/src/rmw_api_impl_ndds.cpp +++ b/rmw_connextdds/src/rmw_api_impl_ndds.cpp @@ -126,11 +126,7 @@ rmw_event_set_callback( rmw_event_callback_t callback, const void * user_data) { - (void)event; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_event_set_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_event_set_callback(event, callback, user_data); } /***************************************************************************** * Info API @@ -602,11 +598,8 @@ rmw_service_set_on_new_request_callback( rmw_event_callback_t callback, const void * user_data) { - (void)rmw_service; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_service_set_on_new_request_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_service_set_on_new_request_callback( + rmw_service, callback, user_data); } rmw_ret_t @@ -615,11 +608,8 @@ rmw_client_set_on_new_response_callback( rmw_event_callback_t callback, const void * user_data) { - (void)rmw_client; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_client_set_on_new_response_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_client_set_on_new_response_callback( + rmw_client, callback, user_data); } /***************************************************************************** @@ -782,16 +772,14 @@ rmw_return_loaned_message_from_subscription( subscription, loaned_message); } -rmw_ret_t rmw_subscription_set_on_new_message_callback( +rmw_ret_t +rmw_subscription_set_on_new_message_callback( rmw_subscription_t * rmw_subscription, rmw_event_callback_t callback, const void * user_data) { - (void)rmw_subscription; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_subscription_set_on_new_message_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_subscription_set_on_new_message_callback( + rmw_subscription, callback, user_data); } /***************************************************************************** diff --git a/rmw_connextdds_common/CMakeLists.txt b/rmw_connextdds_common/CMakeLists.txt index 5ead1d96..f26c3a14 100644 --- a/rmw_connextdds_common/CMakeLists.txt +++ b/rmw_connextdds_common/CMakeLists.txt @@ -132,6 +132,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 diff --git a/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp b/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp index 187eba40..d8cce978 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp @@ -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 *****************************************************************************/ @@ -393,6 +400,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 *****************************************************************************/ @@ -505,6 +527,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 *****************************************************************************/ diff --git a/rmw_connextdds_common/src/common/rmw_listener.cpp b/rmw_connextdds_common/src/common/rmw_listener.cpp new file mode 100644 index 00000000..00935b00 --- /dev/null +++ b/rmw_connextdds_common/src/common/rmw_listener.cpp @@ -0,0 +1,77 @@ +// 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; +} + diff --git a/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp b/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp index 4a02889c..6e95d11e 100644 --- a/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp +++ b/rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp @@ -126,11 +126,7 @@ rmw_event_set_callback( rmw_event_callback_t callback, const void * user_data) { - (void)event; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_event_set_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_event_set_callback(event, callback, user_data); } /***************************************************************************** @@ -603,11 +599,8 @@ rmw_service_set_on_new_request_callback( rmw_event_callback_t callback, const void * user_data) { - (void)rmw_service; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_service_set_on_new_request_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_service_set_on_new_request_callback( + rmw_service, callback, user_data); } rmw_ret_t @@ -616,11 +609,8 @@ rmw_client_set_on_new_response_callback( rmw_event_callback_t callback, const void * user_data) { - (void)rmw_client; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_client_set_on_new_response_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_client_set_on_new_response_callback( + rmw_client, callback, user_data); } /***************************************************************************** @@ -783,17 +773,16 @@ rmw_return_loaned_message_from_subscription( subscription, loaned_message); } -rmw_ret_t rmw_subscription_set_on_new_message_callback( +rmw_ret_t +rmw_subscription_set_on_new_message_callback( rmw_subscription_t * rmw_subscription, rmw_event_callback_t callback, const void * user_data) { - (void)rmw_subscription; - (void)callback; - (void)user_data; - RMW_SET_ERROR_MSG("rmw_subscription_set_on_new_message_callback not implemented"); - return RMW_RET_UNSUPPORTED; + return rmw_api_connextdds_subscription_set_on_new_message_callback( + rmw_subscription, callback, user_data); } + /***************************************************************************** * WaitSet API *****************************************************************************/