CARLA
 
载入中...
搜索中...
未找到
PointPubSubTypes.h
浏览该文件的文档.
1// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2//
3// 根据 Apache License, Version 2.0(“许可证”)授权;
4// 除非遵守该许可证,否则您不得使用此文件。
5// 您可以在以下网址获取许可证的副本:
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// 除非适用法律要求或书面同意,否则根据许可证分发的软件是以“原样”方式分发的,
10// 不附带任何明示或暗示的担保或条件。
11// 请参阅许可证以获取有关权限和限制的具体语言。
12
13/*!
14 * @file PointPubSubTypes.h
15 * 此头文件包含对点类型的序列化函数的声明。
16 *
17 * 此文件是由工具 fastcdrgen 生成的。
18 */
19
20#ifndef _FAST_DDS_GENERATED_GEOMETRY_MSGS_MSG_POINT_PUBSUBTYPES_H_
21#define _FAST_DDS_GENERATED_GEOMETRY_MSGS_MSG_POINT_PUBSUBTYPES_H_
22
23#include <fastdds/dds/topic/TopicDataType.hpp> // 引入 Fast DDS 主题数据类型头文件
24#include <fastrtps/utils/md5.h> // 引入 MD5 工具以进行校验和计算
25
26#include "Point.h" // 引入 Point 结构的定义
27
28// 检查 API 版本兼容性
29#if !defined(GEN_API_VER) || (GEN_API_VER != 1)
30#error \
31 生成的 Point 与当前安装的 Fast DDS 不兼容。请使用 fastddsgen 重新生成。
32#endif // GEN_API_VER
33
34namespace geometry_msgs
35{
36 namespace msg
37 {
38 #ifndef SWIG
39 namespace detail {
40
41 // 辅助模板,用于检索 Point 的成员变量
42 template<typename Tag, typename Tag::type M>
43 struct Point_rob
44 {
45 friend constexpr typename Tag::type get(
46 Tag)
47 {
48 return M; // 返回成员变量
49 }
50 };
51
52 // Point 成员变量的标记结构
53 struct Point_f
54 {
55 typedef double Point::* type; // 定义类型为指向 Point 的 double 成员的指针
56 friend constexpr type get(
57 Point_f); // 友元函数以访问成员
58 };
59
60 // 显式特化以访问 Point 的 m_z 成员
61 template struct Point_rob<Point_f, &Point::m_z>;
62
63 // 计算 Point 结构中成员变量的偏移量的函数
64 template <typename T, typename Tag>
65 inline size_t constexpr Point_offset_of() {
66 return ((::size_t) &reinterpret_cast<char const volatile&>((((T*)0)->*get(Tag()))));
67 }
68 }
69 #endif
70
71 /*!
72 * @brief 此类表示用户在 IDL 文件中定义的 Point 类型的 TopicDataType。
73 * @ingroup POINT
74 */
75 class PointPubSubType : public eprosima::fastdds::dds::TopicDataType
76 {
77 public:
78
79 typedef Point type; // 将类型定义为 Point
80
82
83 eProsima_user_DllExport virtual ~PointPubSubType() override; // 析构函数
84
85 // 将 Point 数据序列化到有效负载中
86 eProsima_user_DllExport virtual bool serialize(
87 void* data,
88 eprosima::fastrtps::rtps::SerializedPayload_t* payload) override;
89
90 // 将有效负载反序列化回 Point 数据
91 eProsima_user_DllExport virtual bool deserialize(
92 eprosima::fastrtps::rtps::SerializedPayload_t* payload,
93 void* data) override;
94
95 // 提供获取序列化数据大小的函数
96 eProsima_user_DllExport virtual std::function<uint32_t()> getSerializedSizeProvider(
97 void* data) override;
98
99 // 获取 Point 实例的键
100 eProsima_user_DllExport virtual bool getKey(
101 void* data,
102 eprosima::fastrtps::rtps::InstanceHandle_t* ihandle,
103 bool force_md5 = false) override;
104
105 // 创建一个新的 Point 实例
106 eProsima_user_DllExport virtual void* createData() override;
107
108 // 删除 Point 实例
109 eProsima_user_DllExport virtual void deleteData(
110 void* data) override;
111
112 #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
113 // 检查 Point 类型是否是有界的
114 eProsima_user_DllExport inline bool is_bounded() const override
115 {
116 return true; // Point 是有界类型
117 }
118
119 #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
120
121 #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
122 // 检查 Point 类型是否是简单类型(没有嵌套类型)
123 eProsima_user_DllExport inline bool is_plain() const override
124 {
125 return is_plain_impl(); // 调用实现函数
126 }
127
128 #endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
129
130 #ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE
131 // 在提供的内存中构造 Point 的样本
132 eProsima_user_DllExport inline bool construct_sample(
133 void* memory) const override
134 {
135 new (memory) Point(); // 在指定内存中使用 placement new 创建 Point
136 return true; // 表示成功
137 }
138
139 #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE
140
141 MD5 m_md5; // 用于数据完整性的 MD5 校验和
142 unsigned char* m_keyBuffer; // 实例键的缓冲区
143
144 private:
145
146 // 确定 Point 是否是简单类型的实现
147 static constexpr bool is_plain_impl()
148 {
149 return 24ULL == (detail::Point_offset_of<Point, detail::Point_f>() + sizeof(double));
150 } // 检查大小是否与预期值匹配
151 };
152 }
153}
154
155#endif // _FAST_DDS_GENERATED_GEOMETRY_MSGS_MSG_POINT_PUBSUBTYPES_H_
#define eProsima_user_DllExport
Definition CameraInfo.h:44
Traits::size_t size_t
此类表示用户在 IDL 文件中定义的 Point 类型的 TopicDataType。 <>
static constexpr bool is_plain_impl()
This class represents the structure Point defined by the user in the IDL file.
Definition Point.h:71
size_t constexpr Point_offset_of()
friend constexpr type get(Point_f)
friend constexpr Tag::type get(Tag)