diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e9d07d9..fc12d311 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,12 +55,9 @@ repos: files: \.(yml|yaml)$ - repo: https://github.com/tcort/markdown-link-check - rev: v3.12.2 + rev: v3.13.6 hooks: - id: markdown-link-check - args: - - "-c" - - "markdown-link-check-config.json" - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.10 diff --git a/fuse_core/include/fuse_core/callback_wrapper.hpp b/fuse_core/include/fuse_core/callback_wrapper.hpp index 3180a840..7f920f6b 100644 --- a/fuse_core/include/fuse_core/callback_wrapper.hpp +++ b/fuse_core/include/fuse_core/callback_wrapper.hpp @@ -99,6 +99,12 @@ namespace fuse_core class CallbackWrapperBase { public: + virtual ~CallbackWrapperBase() = default; + CallbackWrapperBase() = default; + CallbackWrapperBase(CallbackWrapperBase const&) = default; + CallbackWrapperBase(CallbackWrapperBase&&) = default; + CallbackWrapperBase& operator=(CallbackWrapperBase const&) = default; + CallbackWrapperBase& operator=(CallbackWrapperBase&&) = default; /** * @brief Call this function. This is used by the callback queue. */ @@ -153,7 +159,7 @@ inline void CallbackWrapper::call() class CallbackAdapter : public rclcpp::Waitable { public: - explicit CallbackAdapter(std::shared_ptr context_ptr); + explicit CallbackAdapter(std::shared_ptr const& context_ptr); /** * @brief tell the CallbackGroup how many guard conditions are ready in this waitable @@ -183,6 +189,17 @@ class CallbackAdapter : public rclcpp::Waitable void removeAllCallbacks(); + void set_on_ready_callback(std::function /*callback*/) override + { + } + void clear_on_ready_callback() override + { + } + std::shared_ptr take_data_by_entity_id(size_t /*id*/) override + { + return nullptr; + } + private: rcl_guard_condition_t gc_; //!< guard condition to drive the waitable diff --git a/fuse_core/src/callback_wrapper.cpp b/fuse_core/src/callback_wrapper.cpp index 84dc2fba..fbbcdecb 100644 --- a/fuse_core/src/callback_wrapper.cpp +++ b/fuse_core/src/callback_wrapper.cpp @@ -37,12 +37,12 @@ namespace fuse_core { -CallbackAdapter::CallbackAdapter(std::shared_ptr context_ptr) +CallbackAdapter::CallbackAdapter(std::shared_ptr const& context_ptr) + : gc_(rcl_get_zero_initialized_guard_condition()) { - rcl_guard_condition_options_t guard_condition_options = rcl_guard_condition_get_default_options(); + rcl_guard_condition_options_t const guard_condition_options = rcl_guard_condition_get_default_options(); // Guard condition is used by the wait set to handle execute-or-not logic - gc_ = rcl_get_zero_initialized_guard_condition(); if (RCL_RET_OK != rcl_guard_condition_init(&gc_, context_ptr->get_rcl_context().get(), guard_condition_options)) { throw std::runtime_error("Could not init guard condition for callback waitable."); @@ -74,7 +74,7 @@ bool CallbackAdapter::is_ready(rcl_wait_set_t const& wait_set) */ void CallbackAdapter::add_to_wait_set(rcl_wait_set_t& wait_set) { - if (RCL_RET_OK != rcl_wait_set_add_guard_condition(&wait_set, &gc_, NULL)) + if (RCL_RET_OK != rcl_wait_set_add_guard_condition(&wait_set, &gc_, nullptr)) { RCLCPP_WARN(rclcpp::get_logger("fuse"), "Could not add callback waitable to wait set."); } @@ -89,7 +89,7 @@ std::shared_ptr CallbackAdapter::take_data() std::shared_ptr cb_wrapper = nullptr; // fetch the callback ptr and release the lock without spending time in the callback { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); if (!callback_queue_.empty()) { cb_wrapper = callback_queue_.front(); @@ -122,7 +122,7 @@ void CallbackAdapter::execute(std::shared_ptr const& data) void CallbackAdapter::addCallback(const std::shared_ptr& callback) { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); callback_queue_.push_back(callback); if (RCL_RET_OK != rcl_trigger_guard_condition(&gc_)) { @@ -134,7 +134,7 @@ void CallbackAdapter::addCallback(const std::shared_ptr& ca void CallbackAdapter::addCallback(std::shared_ptr&& callback) { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); callback_queue_.push_back(std::move(callback)); if (RCL_RET_OK != rcl_trigger_guard_condition(&gc_)) { @@ -146,7 +146,7 @@ void CallbackAdapter::addCallback(std::shared_ptr&& callbac void CallbackAdapter::removeAllCallbacks() { - std::lock_guard lock(queue_mutex_); + std::lock_guard const lock(queue_mutex_); callback_queue_.clear(); }