ROS 2 rclcpp + rcl - rolling  rolling-20536064
ROS 2 C++ Client Library with ROS Client Library
dynamic_message.hpp
1 // Copyright 2023 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__DYNAMIC_TYPESUPPORT__DYNAMIC_MESSAGE_HPP_
16 #define RCLCPP__DYNAMIC_TYPESUPPORT__DYNAMIC_MESSAGE_HPP_
17 
18 #include <rcl/allocator.h>
19 #include <rcl/types.h>
20 #include <rosidl_dynamic_typesupport/types.h>
21 
22 #include <memory>
23 #include <string>
24 
25 #include "rclcpp/dynamic_typesupport/dynamic_serialization_support.hpp"
26 #include "rclcpp/macros.hpp"
27 #include "rclcpp/visibility_control.hpp"
28 
29 namespace rclcpp
30 {
31 namespace dynamic_typesupport
32 {
33 
36 class DynamicMessage : public std::enable_shared_from_this<DynamicMessage>
37 {
38 public:
39  RCLCPP_SMART_PTR_ALIASES_ONLY(DynamicMessage)
40 
41  RCLCPP_PUBLIC
42  virtual ~DynamicMessage();
43 
44 protected:
45  // NOTE(methylDragon):
46  // This is just here to extend the lifetime of the serialization support
47  // It isn't actually used by the builder since the builder should compose its own support
48  //
49  // ... Though ideally it should be the exact same support as the one stored in the
50  // DynamicSerializationSupport
51  DynamicSerializationSupport::SharedPtr serialization_support_;
52 
53  rosidl_dynamic_typesupport_dynamic_data_t rosidl_dynamic_data_;
54  bool is_loaned_;
55 
56  // Used for returning the loaned value, and lifetime management
57  DynamicMessage::SharedPtr parent_data_;
58 
59 private:
60  RCLCPP_DISABLE_COPY(DynamicMessage)
61 
62  RCLCPP_PUBLIC
64 };
65 
66 } // namespace dynamic_typesupport
67 } // namespace rclcpp
68 
69 #endif // RCLCPP__DYNAMIC_TYPESUPPORT__DYNAMIC_MESSAGE_HPP_
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.