From f13ffb25d30b03f751e97faa992cdfa886942cea Mon Sep 17 00:00:00 2001 From: Mauro Passerino Date: Mon, 15 Feb 2021 15:14:29 -0300 Subject: [PATCH] use void * to pass executor ptr --- rclcpp/include/rclcpp/client.hpp | 2 +- rclcpp/include/rclcpp/executors/events_executor.hpp | 6 ++---- .../rclcpp/executors/events_executor_notify_waitable.hpp | 2 +- .../rclcpp/experimental/subscription_intra_process_base.hpp | 2 +- rclcpp/include/rclcpp/qos_event.hpp | 2 +- rclcpp/include/rclcpp/service.hpp | 2 +- rclcpp/include/rclcpp/subscription_base.hpp | 2 +- rclcpp/include/rclcpp/waitable.hpp | 2 +- rclcpp/src/rclcpp/client.cpp | 2 +- rclcpp/src/rclcpp/qos_event.cpp | 2 +- rclcpp/src/rclcpp/service.cpp | 2 +- rclcpp/src/rclcpp/subscription_base.cpp | 2 +- rclcpp/src/rclcpp/subscription_intra_process_base.cpp | 2 +- rclcpp/src/rclcpp/waitable.cpp | 2 +- rclcpp/test/rclcpp/executors/test_executors.cpp | 2 +- 15 files changed, 16 insertions(+), 18 deletions(-) diff --git a/rclcpp/include/rclcpp/client.hpp b/rclcpp/include/rclcpp/client.hpp index e5e7bd50a3..47b657fe5c 100644 --- a/rclcpp/include/rclcpp/client.hpp +++ b/rclcpp/include/rclcpp/client.hpp @@ -159,7 +159,7 @@ class ClientBase RCLCPP_PUBLIC void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const; protected: diff --git a/rclcpp/include/rclcpp/executors/events_executor.hpp b/rclcpp/include/rclcpp/executors/events_executor.hpp index cdf357f9dd..b257bf9789 100644 --- a/rclcpp/include/rclcpp/executors/events_executor.hpp +++ b/rclcpp/include/rclcpp/executors/events_executor.hpp @@ -185,16 +185,14 @@ class EventsExecutor : public rclcpp::Executor // This function is called by the DDS entities when an event happened, // like a subscription receiving a message. static void - push_event(const void * executor_ptr, rmw_listener_event_t event) + push_event(void * executor_ptr, rmw_listener_event_t event) { // Check if the executor pointer is not valid if (!executor_ptr) { throw std::runtime_error("The executor pointer is not valid."); } - // Cast executor_ptr to this (need to remove constness) - auto this_executor = const_cast( - static_cast(executor_ptr)); + auto this_executor = static_cast(executor_ptr); // Event queue mutex scope { diff --git a/rclcpp/include/rclcpp/executors/events_executor_notify_waitable.hpp b/rclcpp/include/rclcpp/executors/events_executor_notify_waitable.hpp index 3e868314ab..b9987d4bd4 100644 --- a/rclcpp/include/rclcpp/executors/events_executor_notify_waitable.hpp +++ b/rclcpp/include/rclcpp/executors/events_executor_notify_waitable.hpp @@ -61,7 +61,7 @@ class EventsExecutorNotifyWaitable final : public EventWaitable RCLCPP_PUBLIC void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const override { for (auto gc : notify_guard_conditions_) { diff --git a/rclcpp/include/rclcpp/experimental/subscription_intra_process_base.hpp b/rclcpp/include/rclcpp/experimental/subscription_intra_process_base.hpp index cca9a6cc46..645d6b65cc 100644 --- a/rclcpp/include/rclcpp/experimental/subscription_intra_process_base.hpp +++ b/rclcpp/include/rclcpp/experimental/subscription_intra_process_base.hpp @@ -77,7 +77,7 @@ class SubscriptionIntraProcessBase : public rclcpp::Waitable RCLCPP_PUBLIC void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const override; protected: diff --git a/rclcpp/include/rclcpp/qos_event.hpp b/rclcpp/include/rclcpp/qos_event.hpp index 4883c7f184..9a3716528e 100644 --- a/rclcpp/include/rclcpp/qos_event.hpp +++ b/rclcpp/include/rclcpp/qos_event.hpp @@ -111,7 +111,7 @@ class QOSEventHandlerBase : public Waitable RCLCPP_PUBLIC void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const override; protected: diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index 35efd0cc8d..00d4227e62 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -129,7 +129,7 @@ class ServiceBase RCLCPP_PUBLIC void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const; protected: diff --git a/rclcpp/include/rclcpp/subscription_base.hpp b/rclcpp/include/rclcpp/subscription_base.hpp index ea60a062cc..fa7789ceb6 100644 --- a/rclcpp/include/rclcpp/subscription_base.hpp +++ b/rclcpp/include/rclcpp/subscription_base.hpp @@ -272,7 +272,7 @@ class SubscriptionBase : public std::enable_shared_from_this RCLCPP_PUBLIC void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const; protected: diff --git a/rclcpp/include/rclcpp/waitable.hpp b/rclcpp/include/rclcpp/waitable.hpp index 8e6608ee62..449fcb5b46 100644 --- a/rclcpp/include/rclcpp/waitable.hpp +++ b/rclcpp/include/rclcpp/waitable.hpp @@ -212,7 +212,7 @@ class Waitable virtual void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const; private: diff --git a/rclcpp/src/rclcpp/client.cpp b/rclcpp/src/rclcpp/client.cpp index 789919c0b6..dd9e7d4e7e 100644 --- a/rclcpp/src/rclcpp/client.cpp +++ b/rclcpp/src/rclcpp/client.cpp @@ -201,7 +201,7 @@ ClientBase::exchange_in_use_by_wait_set_state(bool in_use_state) void ClientBase::set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const { rcl_ret_t ret = rcl_client_set_listener_callback( diff --git a/rclcpp/src/rclcpp/qos_event.cpp b/rclcpp/src/rclcpp/qos_event.cpp index 82b4ed7eb9..d9e27dc32f 100644 --- a/rclcpp/src/rclcpp/qos_event.cpp +++ b/rclcpp/src/rclcpp/qos_event.cpp @@ -70,7 +70,7 @@ QOSEventHandlerBase::is_ready(rcl_wait_set_t * wait_set) void QOSEventHandlerBase::set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const { rcl_ret_t ret = rcl_event_set_listener_callback( diff --git a/rclcpp/src/rclcpp/service.cpp b/rclcpp/src/rclcpp/service.cpp index 766de70826..e0afdbcad9 100644 --- a/rclcpp/src/rclcpp/service.cpp +++ b/rclcpp/src/rclcpp/service.cpp @@ -87,7 +87,7 @@ ServiceBase::exchange_in_use_by_wait_set_state(bool in_use_state) void ServiceBase::set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const { rcl_ret_t ret = rcl_service_set_listener_callback( diff --git a/rclcpp/src/rclcpp/subscription_base.cpp b/rclcpp/src/rclcpp/subscription_base.cpp index 0eb2b3a62e..5f37848726 100644 --- a/rclcpp/src/rclcpp/subscription_base.cpp +++ b/rclcpp/src/rclcpp/subscription_base.cpp @@ -291,7 +291,7 @@ SubscriptionBase::exchange_in_use_by_wait_set_state( void SubscriptionBase::set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const { rcl_ret_t ret = rcl_subscription_set_listener_callback( diff --git a/rclcpp/src/rclcpp/subscription_intra_process_base.cpp b/rclcpp/src/rclcpp/subscription_intra_process_base.cpp index 876e73ff8b..1c906e95cd 100644 --- a/rclcpp/src/rclcpp/subscription_intra_process_base.cpp +++ b/rclcpp/src/rclcpp/subscription_intra_process_base.cpp @@ -39,7 +39,7 @@ SubscriptionIntraProcessBase::get_actual_qos() const void SubscriptionIntraProcessBase::set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const { rcl_ret_t ret = rcl_guard_condition_set_listener_callback( diff --git a/rclcpp/src/rclcpp/waitable.cpp b/rclcpp/src/rclcpp/waitable.cpp index 040716c40f..4c5bd672ce 100644 --- a/rclcpp/src/rclcpp/waitable.cpp +++ b/rclcpp/src/rclcpp/waitable.cpp @@ -62,7 +62,7 @@ Waitable::exchange_in_use_by_wait_set_state(bool in_use_state) void Waitable::set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const { (void)executor; diff --git a/rclcpp/test/rclcpp/executors/test_executors.cpp b/rclcpp/test/rclcpp/executors/test_executors.cpp index bbb68298ee..0be4691152 100644 --- a/rclcpp/test/rclcpp/executors/test_executors.cpp +++ b/rclcpp/test/rclcpp/executors/test_executors.cpp @@ -469,7 +469,7 @@ class TestWaitable : public rclcpp::Waitable void set_events_executor_callback( - const rclcpp::executors::EventsExecutor * executor, + rclcpp::executors::EventsExecutor * executor, rmw_listener_callback_t executor_callback) const override { rcl_ret_t ret = rcl_guard_condition_set_listener_callback(