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