10#ifndef NROS_RCLCPP_GUARD_CONDITION_HPP
11#define NROS_RCLCPP_GUARD_CONDITION_HPP
18#include "rclcpp/detail/hosted_block.hpp"
20#include "rclcpp/detail/nros_cpp_ffi.h"
56 if (!initialized_)
return Result(ErrorCode::NotInitialized);
57 return Result(nros_cpp_guard_condition_trigger(storage_));
74 if (!initialized_)
return false;
75 return nros_cpp_guard_condition_is_triggered(storage_);
81 if (!initialized_)
return Result(ErrorCode::NotInitialized);
82 return Result(nros_cpp_guard_condition_clear(storage_));
94 detail::destroy_hosted_block(closure_);
100 : initialized_(other.initialized_), closure_(other.closure_), executor_(other.executor_),
101 handle_id_(other.handle_id_) {
102 if (other.initialized_) {
103 nros_cpp_guard_condition_relocate(other.storage_, storage_);
104 other.initialized_ = false;
106 other.closure_ =
nullptr;
107 other.executor_ =
nullptr;
108 other.handle_id_ = 0;
112 if (
this != &other) {
114 if (other.initialized_) {
115 nros_cpp_guard_condition_relocate(other.storage_, storage_);
117 other.initialized_ =
false;
119 executor_ = other.executor_;
120 handle_id_ = other.handle_id_;
121 other.executor_ =
nullptr;
122 other.handle_id_ = 0;
123 detail::destroy_hosted_block(closure_);
124 closure_ = other.closure_;
125 other.closure_ =
nullptr;
133 : storage_(), initialized_(false), closure_(nullptr), executor_(nullptr), handle_id_(0) {}
139 detail::destroy_hosted_block(closure_);
147 if (executor_ !=
nullptr) {
148 (void)nros_cpp_guard_condition_release(executor_, handle_id_);
150 nros_cpp_guard_condition_destroy(storage_);
151 initialized_ =
false;
157 GuardCondition(
const GuardCondition&) =
delete;
158 GuardCondition&
operator=(
const GuardCondition&) =
delete;
160 friend class ::rclcpp::Node;
162 alignas(8) uint8_t storage_[NROS_GUARD_CONDITION_SIZE];
void attach_closure_block(detail::HostedBlockBase *block)
Definition guard_condition.hpp:138
Result trigger()
Definition guard_condition.hpp:55
bool is_triggered() const
Definition guard_condition.hpp:73
GuardCondition()
Definition guard_condition.hpp:132
Result clear()
Definition guard_condition.hpp:80
bool is_valid() const
Check if the guard condition is initialized and valid.
Definition guard_condition.hpp:61
GuardCondition(GuardCondition &&other)
Definition guard_condition.hpp:99
GuardCondition & operator=(GuardCondition &&other)
Definition guard_condition.hpp:111
~GuardCondition()
Definition guard_condition.hpp:90
Inline storage-size macros for opaque entity buffers.
Client & operator=(Client &&other)
Definition client.hpp:1002
rclcpp::Result, rclcpp::ErrorCode, and the RCLCPP_TRY macro.