CARLA
 
载入中...
搜索中...
未找到
Clock.cpp
浏览该文件的文档.
1// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
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/*!
16 * @file Clock.cpp
17 * This source file contains the definition of the described types in the IDL file.
18 *
19 * This file was generated by the tool gen.
20 */
21
22#ifdef _WIN32
23// Remove linker warning LNK4221 on Visual Studio
24namespace {
25char dummy;
26} // namespace
27#endif // _WIN32
28
29#include "Clock.h" // 引入头文件 Clock.h
30#include <fastcdr/Cdr.h> // 引入 Fast CDR 库中的 Cdr 类
31#include <fastcdr/exceptions/BadParamException.h> // 引入 Fast CDR 异常类
32
33using namespace eprosima::fastcdr::exception; // 使用 Fast CDR 的异常命名空间
34
35#include <utility> // 引入 utility 头文件以使用 std::move
36
37// 定义最大 CDR 类型大小为 0
38#define Time_max_cdr_typesize 0ULL;
39#define rosgraph_msg_Clock_max_cdr_typesize 0ULL;
40#define Time_max_key_cdr_typesize 0ULL;
41#define rosgraph_msg_Clock_max_key_cdr_typesize 0ULL;
42
43// Clock 类的构造函数
47
48// Clock 类的析构函数
52
53// 拷贝构造函数,复制另一个 Clock 对象
55 const rosgraph::msg::Clock& x)
56{
57 m_clock = x.m_clock; // 复制 m_clock 成员变量
58}
59
60// 移动构造函数,移动另一个 Clock 对象的资源
62 rosgraph::msg::Clock&& x) noexcept
63{
64 m_clock = x.m_clock; // 移动 m_clock 成员变量
65}
66
67// 拷贝赋值运算符,赋值另一个 Clock 对象
69 const rosgraph::msg::Clock& x)
70{
71 m_clock = x.m_clock; // 赋值 m_clock 成员变量
72 return *this; // 返回当前对象的引用
73}
74
75// 移动赋值运算符,赋值另一个 Clock 对象的资源
77 rosgraph::msg::Clock&& x) noexcept
78{
79 m_clock = x.m_clock; // 移动 m_clock 成员变量
80 return *this; // 返回当前对象的引用
81}
82
83// 判断两个 Clock 对象是否相等
85 const Clock& x) const
86{
87 return (m_clock == x.m_clock); // 比较 m_clock 是否相等
88}
89
90// 判断两个 Clock 对象是否不相等
92 const Clock& x) const
93{
94 return !(*this == x); // 调用 == 运算符返回相反结果
95}
96
97// 获取最大 CDR 序列化大小
99 size_t current_alignment)
100{
101 static_cast<void>(current_alignment); // 防止未使用参数警告
102 return rosgraph_msg_Clock_max_cdr_typesize; // 返回最大 CDR 类型大小
103}
104
105// 获取特定数据的 CDR 序列化大小
107 const rosgraph::msg::Clock& data,
108 size_t current_alignment)
109{
110 (void)data; // 防止未使用参数警告
111 size_t initial_alignment = current_alignment; // 保存初始对齐值
112
113 // 计算 m_clock 的序列化大小
115
116 return current_alignment - initial_alignment; // 返回序列化大小
117}
118
119// 序列化 Clock 对象
121 eprosima::fastcdr::Cdr& scdr) const
122{
123 scdr << m_clock; // 将 m_clock 写入 Cdr 对象
124}
125
126// 反序列化 Clock 对象
128 eprosima::fastcdr::Cdr& dcdr)
129{
130 dcdr >> m_clock; // 从 Cdr 对象读取 m_clock
131}
132
133/*!
134 * @brief 该函数复制成员 clock 的值
135 * @param _clock 要复制到成员 clock 的新值
136 */
138 const builtin_interfaces::msg::Time& _clock)
139{
140 m_clock = _clock; // 复制传入的新值
141}
142
143/*!
144 * @brief 该函数移动成员 clock 的值
145 * @param _clock 要移动到成员 clock 的新值
146 */
149{
150 m_clock = std::move(_clock); // 移动传入的新值
151}
152
153/*!
154 * @brief 该函数返回成员 clock 的常量引用
155 * @return 成员 clock 的常量引用
156 */
158{
159 return m_clock; // 返回 m_clock 的常量引用
160}
161
162/*!
163 * @brief 该函数返回成员 clock 的引用
164 * @return 成员 clock 的引用
165 */
167{
168 return m_clock; // 返回 m_clock 的引用
169}
170
171// 获取键的最大 CDR 序列化大小
173 size_t current_alignment)
174{
175 static_cast<void>(current_alignment); // 防止未使用参数警告
176 return rosgraph_msg_Clock_max_key_cdr_typesize; // 返回最大键 CDR 类型大小
177}
178
179// 判断键是否已定义
181{
182 return false; // 当前类未定义键
183}
184
185// 序列化键(此处无实际操作)
187 eprosima::fastcdr::Cdr& scdr) const
188{
189 (void) scdr; // 防止未使用参数警告
190}
#define rosgraph_msg_Clock_max_cdr_typesize
Definition Clock.cpp:39
#define rosgraph_msg_Clock_max_key_cdr_typesize
Definition Clock.cpp:41
return current_alignment initial_alignment
此类表示用户在IDL文件中定义的Time结构。
static eProsima_user_DllExport size_t getCdrSerializedSize(const builtin_interfaces::msg::Time &data, size_t current_alignment=0)
此函数根据缓冲区对齐方式返回数据的序列化大小。
Definition Time.cpp:119
This class represents the structure Clock defined by the user in the IDL file.
Definition Clock.h:74
eProsima_user_DllExport Clock & operator=(const Clock &x)
Copy assignment.
Definition Clock.cpp:68
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
Definition Clock.cpp:186
static eProsima_user_DllExport size_t getKeyMaxCdrSerializedSize(size_t current_alignment=0)
This function returns the maximum serialized size of the Key of an object depending on the buffer ali...
Definition Clock.cpp:172
static eProsima_user_DllExport size_t getMaxCdrSerializedSize(size_t current_alignment=0)
This function returns the maximum serialized size of an object depending on the buffer alignment.
Definition Clock.cpp:98
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr)
This function deserializes an object using CDR serialization.
Definition Clock.cpp:127
eProsima_user_DllExport const builtin_interfaces::msg::Time & clock() const
This function returns a constant reference to member clock
Definition Clock.cpp:157
eProsima_user_DllExport ~Clock()
Default destructor.
Definition Clock.cpp:49
builtin_interfaces::msg::Time m_clock
Definition Clock.h:210
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
Definition Clock.cpp:120
static eProsima_user_DllExport bool isKeyDefined()
This function tells you if the Key has been defined for this type
Definition Clock.cpp:180
eProsima_user_DllExport bool operator!=(const Clock &x) const
Comparison operator.
Definition Clock.cpp:91
eProsima_user_DllExport Clock()
Default constructor.
Definition Clock.cpp:44
static eProsima_user_DllExport size_t getCdrSerializedSize(const rosgraph::msg::Clock &data, size_t current_alignment=0)
This function returns the serialized size of a data depending on the buffer alignment.
Definition Clock.cpp:106
eProsima_user_DllExport bool operator==(const Clock &x) const
Comparison operator.
Definition Clock.cpp:84
eProsima_user_DllExport void clock(const builtin_interfaces::msg::Time &_clock)
This function copies the value in member clock
Definition Clock.cpp:137