ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
init_options.hpp
1 // Copyright 2018 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__INIT_OPTIONS_HPP_
16 #define RCLCPP__INIT_OPTIONS_HPP_
17 
18 #include <memory>
19 #include <mutex>
20 
21 #include "rcl/init_options.h"
22 #include "rclcpp/visibility_control.hpp"
23 
24 namespace rclcpp
25 {
26 
29 {
30 public:
32  bool shutdown_on_signal = true;
33 
35 
40  RCLCPP_PUBLIC
42 
44 
49  RCLCPP_PUBLIC
50  explicit InitOptions(const rcl_init_options_t & init_options);
51 
53  RCLCPP_PUBLIC
54  InitOptions(const InitOptions & other);
55 
57  RCLCPP_PUBLIC
58  bool
60 
62  RCLCPP_PUBLIC
63  InitOptions &
64  auto_initialize_logging(bool initialize_logging);
65 
67  RCLCPP_PUBLIC
68  InitOptions &
69  operator=(const InitOptions & other);
70 
71  RCLCPP_PUBLIC
72  virtual
73  ~InitOptions();
74 
76 
80  RCLCPP_PUBLIC
81  const rcl_init_options_t *
82  get_rcl_init_options() const;
83 
85  RCLCPP_PUBLIC
86  void
88 
90  RCLCPP_PUBLIC
91  void
92  set_domain_id(size_t domain_id);
93 
95  RCLCPP_PUBLIC
96  size_t
97  get_domain_id() const;
98 
99 protected:
100  void
101  finalize_init_options();
102 
103 private:
104  void
105  finalize_init_options_impl();
106 
107  mutable std::mutex init_options_mutex_;
108  std::unique_ptr<rcl_init_options_t> init_options_;
109  bool initialize_logging_{true};
110 };
111 
112 } // namespace rclcpp
113 
114 #endif // RCLCPP__INIT_OPTIONS_HPP_
#define rcl_get_default_allocator
Return a properly initialized rcl_allocator_t with default values.
Definition: allocator.h:37
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:31
Encapsulation of options for initializing rclcpp.
RCLCPP_PUBLIC const rcl_init_options_t * get_rcl_init_options() const
Return the rcl init options.
RCLCPP_PUBLIC bool auto_initialize_logging() const
Return true if logging should be initialized when rclcpp::Context::init is called.
RCLCPP_PUBLIC InitOptions & operator=(const InitOptions &other)
Assignment operator.
RCLCPP_PUBLIC void use_default_domain_id()
Retrieve default domain id and set.
RCLCPP_PUBLIC size_t get_domain_id() const
Return domain id.
bool shutdown_on_signal
If true, the context will be shutdown on SIGINT by the signal handler (if it was installed).
RCLCPP_PUBLIC InitOptions(rcl_allocator_t allocator=rcl_get_default_allocator())
Constructor.
RCLCPP_PUBLIC void set_domain_id(size_t domain_id)
Set the domain id.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
Encapsulation of init options and implementation defined init options.
Definition: init_options.h:36