rclcpp  master
C++ ROS Client Library API
guard_condition.hpp
Go to the documentation of this file.
1 // Copyright 2020 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__GUARD_CONDITION_HPP_
16 #define RCLCPP__GUARD_CONDITION_HPP_
17 
18 #include <atomic>
19 
20 #include "rcl/guard_condition.h"
21 
22 #include "rclcpp/context.hpp"
24 #include "rclcpp/macros.hpp"
26 
27 namespace rclcpp
28 {
29 
32 {
33 public:
35 
36  // TODO(wjwwood): support custom allocator, maybe restrict to polymorphic allocator
38 
48  explicit GuardCondition(
49  rclcpp::Context::SharedPtr context =
51 
53  virtual
55 
58  rclcpp::Context::SharedPtr
59  get_context() const;
60 
63  const rcl_guard_condition_t &
65 
67 
75  void
76  trigger();
77 
79 
89  bool
90  exchange_in_use_by_wait_set_state(bool in_use_state);
91 
92 protected:
93  rclcpp::Context::SharedPtr context_;
96 };
97 
98 } // namespace rclcpp
99 
100 #endif // RCLCPP__GUARD_CONDITION_HPP_
rclcpp::GuardCondition
A condition that can be waited on in a single wait set and asynchronously triggered.
Definition: guard_condition.hpp:31
rclcpp::GuardCondition::trigger
void trigger()
Notify the wait set waiting on this condition, if any, that the condition had been met.
rclcpp::GuardCondition::get_rcl_guard_condition
const rcl_guard_condition_t & get_rcl_guard_condition() const
Return the underlying rcl guard condition structure.
guard_condition.h
rclcpp::GuardCondition::context_
rclcpp::Context::SharedPtr context_
Definition: guard_condition.hpp:93
rclcpp::GuardCondition::GuardCondition
GuardCondition(rclcpp::Context::SharedPtr context=rclcpp::contexts::get_global_default_context())
Construct the guard condition, optionally specifying which Context to use.
context.hpp
rclcpp::GuardCondition::in_use_by_wait_set_
std::atomic< bool > in_use_by_wait_set_
Definition: guard_condition.hpp:95
rcl_guard_condition_t
rclcpp::GuardCondition::rcl_guard_condition_
rcl_guard_condition_t rcl_guard_condition_
Definition: guard_condition.hpp:94
rclcpp::contexts::get_global_default_context
DefaultContext::SharedPtr get_global_default_context()
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
RCLCPP_PUBLIC
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
macros.hpp
rclcpp::GuardCondition::get_context
rclcpp::Context::SharedPtr get_context() const
Return the context used when creating this guard condition.
rclcpp::GuardCondition::exchange_in_use_by_wait_set_state
bool exchange_in_use_by_wait_set_state(bool in_use_state)
Exchange the "in use by wait set" state for this guard condition.
std::atomic< bool >
default_context.hpp
rclcpp::GuardCondition::~GuardCondition
virtual ~GuardCondition()
visibility_control.hpp
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51