CARLA
Time.cpp
Go to the documentation of this file.
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 Time.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
24 namespace {
25 char dummy;
26 } // namespace
27 #endif // _WIN32
28 
29 #include "Time.h"
30 #include <fastcdr/Cdr.h>
31 
32 #include <fastcdr/exceptions/BadParamException.h>
33 using namespace eprosima::fastcdr::exception;
34 
35 #include <utility>
36 
37 #define builtin_interfaces_msg_Time_max_cdr_typesize 8ULL;
38 #define builtin_interfaces_msg_Time_max_key_cdr_typesize 0ULL;
39 
41 {
42  // long m_sec
43  m_sec = 0;
44  // unsigned long m_nanosec
45  m_nanosec = 0;
46 }
47 
49 {
50 }
51 
53  const Time& x)
54 {
55  m_sec = x.m_sec;
56  m_nanosec = x.m_nanosec;
57 }
58 
60  Time&& x) noexcept
61 {
62  m_sec = x.m_sec;
63  m_nanosec = x.m_nanosec;
64 }
65 
67  const Time& x)
68 {
69  m_sec = x.m_sec;
70  m_nanosec = x.m_nanosec;
71 
72  return *this;
73 }
74 
76  Time&& x) noexcept
77 {
78  m_sec = x.m_sec;
79  m_nanosec = x.m_nanosec;
80 
81  return *this;
82 }
83 
85  const Time& x) const
86 {
87  return (m_sec == x.m_sec && m_nanosec == x.m_nanosec);
88 }
89 
91  const Time& x) const
92 {
93  return !(*this == x);
94 }
95 
97  size_t current_alignment)
98 {
99  static_cast<void>(current_alignment);
101 }
102 
104  const builtin_interfaces::msg::Time& data,
105  size_t current_alignment)
106 {
107  (void)data;
108  size_t initial_alignment = current_alignment;
109  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
110  current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
111 
112  return current_alignment - initial_alignment;
113 }
114 
116  eprosima::fastcdr::Cdr& scdr) const
117 {
118  scdr << m_sec;
119  scdr << m_nanosec;
120 }
121 
123  eprosima::fastcdr::Cdr& dcdr)
124 {
125  dcdr >> m_sec;
126  dcdr >> m_nanosec;
127 }
128 
129 /*!
130  * @brief This function sets a value in member sec
131  * @param _sec New value for member sec
132  */
134  int32_t _sec)
135 {
136  m_sec = _sec;
137 }
138 
139 /*!
140  * @brief This function returns the value of member sec
141  * @return Value of member sec
142  */
144 {
145  return m_sec;
146 }
147 
148 /*!
149  * @brief This function returns a reference to member sec
150  * @return Reference to member sec
151  */
153 {
154  return m_sec;
155 }
156 
157 /*!
158  * @brief This function sets a value in member nanosec
159  * @param _nanosec New value for member nanosec
160  */
162  uint32_t _nanosec)
163 {
164  m_nanosec = _nanosec;
165 }
166 
167 /*!
168  * @brief This function returns the value of member nanosec
169  * @return Value of member nanosec
170  */
172 {
173  return m_nanosec;
174 }
175 
176 /*!
177  * @brief This function returns a reference to member nanosec
178  * @return Reference to member nanosec
179  */
181 {
182  return m_nanosec;
183 }
184 
186  size_t current_alignment)
187 {
188  static_cast<void>(current_alignment);
190 }
191 
193 {
194  return false;
195 }
196 
198  eprosima::fastcdr::Cdr& scdr) const
199 {
200  (void) scdr;
201 }
eProsima_user_DllExport uint32_t nanosec() const
This function returns the value of member nanosec.
Definition: Time.cpp:171
#define builtin_interfaces_msg_Time_max_key_cdr_typesize
Definition: Time.cpp:38
eProsima_user_DllExport void deserialize(eprosima::fastcdr::Cdr &cdr)
This function deserializes an object using CDR serialization.
Definition: Time.cpp:122
eProsima_user_DllExport Time()
Default constructor.
Definition: Time.cpp:40
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: Time.cpp:185
eProsima_user_DllExport bool operator==(const Time &x) const
Comparison operator.
Definition: Time.cpp:84
eProsima_user_DllExport ~Time()
Default destructor.
Definition: Time.cpp:48
eProsima_user_DllExport int32_t sec() const
This function returns the value of member sec.
Definition: Time.cpp:143
static eProsima_user_DllExport bool isKeyDefined()
This function tells you if the Key has been defined for this type.
Definition: Time.cpp:192
static eProsima_user_DllExport size_t getCdrSerializedSize(const builtin_interfaces::msg::Time &data, size_t current_alignment=0)
This function returns the serialized size of a data depending on the buffer alignment.
Definition: Time.cpp:103
#define builtin_interfaces_msg_Time_max_cdr_typesize
Definition: Time.cpp:37
eProsima_user_DllExport void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
Definition: Time.cpp:115
This class represents the structure Time defined by the user in the IDL file.
eProsima_user_DllExport Time & operator=(const Time &x)
Copy assignment.
Definition: Time.cpp:66
eProsima_user_DllExport bool operator!=(const Time &x) const
Comparison operator.
Definition: Time.cpp:90
eProsima_user_DllExport void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
Definition: Time.cpp:197
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: Time.cpp:96