rclcpp  master
C++ ROS Client Library API
serialized_message.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__SERIALIZED_MESSAGE_HPP_
16 #define RCLCPP__SERIALIZED_MESSAGE_HPP_
17 
18 #include "rcl/allocator.h"
19 #include "rcl/types.h"
20 
22 
23 namespace rclcpp
24 {
25 
28 {
29 public:
31 
38  explicit SerializedMessage(
39  const rcl_allocator_t & allocator = rcl_get_default_allocator());
40 
42 
51  size_t initial_capacity,
52  const rcl_allocator_t & allocator = rcl_get_default_allocator());
53 
55  SerializedMessage(const SerializedMessage & other);
56 
58  explicit SerializedMessage(const rcl_serialized_message_t & other);
59 
62 
64  explicit SerializedMessage(rcl_serialized_message_t && other);
65 
67  SerializedMessage & operator=(const SerializedMessage & other);
68 
70  SerializedMessage & operator=(const rcl_serialized_message_t & other);
71 
73  SerializedMessage & operator=(SerializedMessage && other);
74 
76  SerializedMessage & operator=(rcl_serialized_message_t && other);
77 
79  virtual ~SerializedMessage();
80 
82  rcl_serialized_message_t & get_rcl_serialized_message();
83 
84  // Get a const handle to the underlying rcl_serialized_message_t
85  const rcl_serialized_message_t & get_rcl_serialized_message() const;
86 
88 
92  size_t size() const;
93 
95 
99  size_t capacity() const;
100 
102 
106  void reserve(size_t capacity);
107 
109 
113  rcl_serialized_message_t release_rcl_serialized_message();
114 
115 private:
116  rcl_serialized_message_t serialized_message_;
117 };
118 
119 } // namespace rclcpp
120 
121 #endif // RCLCPP__SERIALIZED_MESSAGE_HPP_
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
RCLCPP_PUBLIC_TYPE
#define RCLCPP_PUBLIC_TYPE
Definition: visibility_control.hpp:53
visibility_control.hpp
rclcpp::SerializedMessage
Object oriented version of rcl_serialized_message_t with destructor to avoid memory leaks.
Definition: serialized_message.hpp:27