|
| 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 HelloWorld.cpp |
| 17 | + * This source file contains the implementation of the described types in the IDL file. |
| 18 | + * |
| 19 | + * This file was generated by the tool fastddsgen. |
| 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 "HelloWorld.h" |
| 30 | + |
| 31 | +#if FASTCDR_VERSION_MAJOR == 1 |
| 32 | + |
| 33 | +#include <fastcdr/Cdr.h> |
| 34 | + |
| 35 | + |
| 36 | +#include <fastcdr/exceptions/BadParamException.h> |
| 37 | +using namespace eprosima::fastcdr::exception; |
| 38 | + |
| 39 | +#include <utility> |
| 40 | + |
| 41 | +namespace helper { namespace internal { |
| 42 | + |
| 43 | +enum class Size { |
| 44 | + UInt8, |
| 45 | + UInt16, |
| 46 | + UInt32, |
| 47 | + UInt64, |
| 48 | +}; |
| 49 | + |
| 50 | +constexpr Size get_size(int s) { |
| 51 | + return (s <= 8 ) ? Size::UInt8: |
| 52 | + (s <= 16) ? Size::UInt16: |
| 53 | + (s <= 32) ? Size::UInt32: Size::UInt64; |
| 54 | +} |
| 55 | + |
| 56 | +template<Size s> |
| 57 | +struct FindTypeH; |
| 58 | + |
| 59 | +template<> |
| 60 | +struct FindTypeH<Size::UInt8> { |
| 61 | + using type = std::uint8_t; |
| 62 | +}; |
| 63 | + |
| 64 | +template<> |
| 65 | +struct FindTypeH<Size::UInt16> { |
| 66 | + using type = std::uint16_t; |
| 67 | +}; |
| 68 | + |
| 69 | +template<> |
| 70 | +struct FindTypeH<Size::UInt32> { |
| 71 | + using type = std::uint32_t; |
| 72 | +}; |
| 73 | + |
| 74 | +template<> |
| 75 | +struct FindTypeH<Size::UInt64> { |
| 76 | + using type = std::uint64_t; |
| 77 | +}; |
| 78 | +} |
| 79 | + |
| 80 | +template<int S> |
| 81 | +struct FindType { |
| 82 | + using type = typename internal::FindTypeH<internal::get_size(S)>::type; |
| 83 | +}; |
| 84 | +} |
| 85 | + |
| 86 | +#define HelloWorld_max_cdr_typesize 268ULL; |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +HelloWorld::HelloWorld() |
| 92 | +{ |
| 93 | + // unsigned long m_index |
| 94 | + m_index = 0; |
| 95 | + // /type_d() m_message |
| 96 | + |
| 97 | + |
| 98 | +} |
| 99 | + |
| 100 | +HelloWorld::~HelloWorld() |
| 101 | +{ |
| 102 | +} |
| 103 | + |
| 104 | +HelloWorld::HelloWorld( |
| 105 | + const HelloWorld& x) |
| 106 | +{ |
| 107 | + m_index = x.m_index; |
| 108 | + |
| 109 | + |
| 110 | + m_message = x.m_message; |
| 111 | + |
| 112 | +} |
| 113 | + |
| 114 | +HelloWorld::HelloWorld( |
| 115 | + HelloWorld&& x) noexcept |
| 116 | +{ |
| 117 | + m_index = x.m_index; |
| 118 | + |
| 119 | + |
| 120 | + m_message = std::move(x.m_message); |
| 121 | + |
| 122 | +} |
| 123 | + |
| 124 | +HelloWorld& HelloWorld::operator =( |
| 125 | + const HelloWorld& x) |
| 126 | +{ |
| 127 | + m_index = x.m_index; |
| 128 | + |
| 129 | + |
| 130 | + m_message = x.m_message; |
| 131 | + |
| 132 | + return *this; |
| 133 | +} |
| 134 | + |
| 135 | +HelloWorld& HelloWorld::operator =( |
| 136 | + HelloWorld&& x) noexcept |
| 137 | +{ |
| 138 | + m_index = x.m_index; |
| 139 | + |
| 140 | + |
| 141 | + m_message = std::move(x.m_message); |
| 142 | + |
| 143 | + return *this; |
| 144 | +} |
| 145 | + |
| 146 | +bool HelloWorld::operator ==( |
| 147 | + const HelloWorld& x) const |
| 148 | +{ |
| 149 | + return (m_index == x.m_index && |
| 150 | + m_message == x.m_message); |
| 151 | +} |
| 152 | + |
| 153 | +bool HelloWorld::operator !=( |
| 154 | + const HelloWorld& x) const |
| 155 | +{ |
| 156 | + return !(*this == x); |
| 157 | +} |
| 158 | + |
| 159 | +size_t HelloWorld::getMaxCdrSerializedSize( |
| 160 | + size_t current_alignment) |
| 161 | +{ |
| 162 | + static_cast<void>(current_alignment); |
| 163 | + return HelloWorld_max_cdr_typesize; |
| 164 | +} |
| 165 | + |
| 166 | +size_t HelloWorld::getCdrSerializedSize( |
| 167 | + const HelloWorld& data, |
| 168 | + size_t current_alignment) |
| 169 | +{ |
| 170 | + (void)data; |
| 171 | + size_t initial_alignment = current_alignment; |
| 172 | + |
| 173 | + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); |
| 174 | + |
| 175 | + |
| 176 | + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; |
| 177 | + |
| 178 | + |
| 179 | + return current_alignment - initial_alignment; |
| 180 | +} |
| 181 | + |
| 182 | + |
| 183 | +void HelloWorld::serialize( |
| 184 | + eprosima::fastcdr::Cdr& scdr) const |
| 185 | +{ |
| 186 | + scdr << m_index; |
| 187 | + |
| 188 | + scdr << m_message.c_str(); |
| 189 | + |
| 190 | +} |
| 191 | + |
| 192 | +void HelloWorld::deserialize( |
| 193 | + eprosima::fastcdr::Cdr& dcdr) |
| 194 | +{ |
| 195 | + dcdr >> m_index; |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + dcdr >> m_message; |
| 200 | + |
| 201 | + |
| 202 | +} |
| 203 | + |
| 204 | + |
| 205 | +bool HelloWorld::isKeyDefined() |
| 206 | +{ |
| 207 | + return false; |
| 208 | +} |
| 209 | + |
| 210 | +void HelloWorld::serializeKey( |
| 211 | + eprosima::fastcdr::Cdr& scdr) const |
| 212 | +{ |
| 213 | + (void) scdr; |
| 214 | +} |
| 215 | + |
| 216 | +/*! |
| 217 | + * @brief This function sets a value in member index |
| 218 | + * @param _index New value for member index |
| 219 | + */ |
| 220 | +void HelloWorld::index( |
| 221 | + uint32_t _index) |
| 222 | +{ |
| 223 | + m_index = _index; |
| 224 | +} |
| 225 | + |
| 226 | +/*! |
| 227 | + * @brief This function returns the value of member index |
| 228 | + * @return Value of member index |
| 229 | + */ |
| 230 | +uint32_t HelloWorld::index() const |
| 231 | +{ |
| 232 | + return m_index; |
| 233 | +} |
| 234 | + |
| 235 | +/*! |
| 236 | + * @brief This function returns a reference to member index |
| 237 | + * @return Reference to member index |
| 238 | + */ |
| 239 | +uint32_t& HelloWorld::index() |
| 240 | +{ |
| 241 | + return m_index; |
| 242 | +} |
| 243 | + |
| 244 | + |
| 245 | +/*! |
| 246 | + * @brief This function copies the value in member message |
| 247 | + * @param _message New value to be copied in member message |
| 248 | + */ |
| 249 | +void HelloWorld::message( |
| 250 | + const std::string& _message) |
| 251 | +{ |
| 252 | + m_message = _message; |
| 253 | +} |
| 254 | + |
| 255 | +/*! |
| 256 | + * @brief This function moves the value in member message |
| 257 | + * @param _message New value to be moved in member message |
| 258 | + */ |
| 259 | +void HelloWorld::message( |
| 260 | + std::string&& _message) |
| 261 | +{ |
| 262 | + m_message = std::move(_message); |
| 263 | +} |
| 264 | + |
| 265 | +/*! |
| 266 | + * @brief This function returns a constant reference to member message |
| 267 | + * @return Constant reference to member message |
| 268 | + */ |
| 269 | +const std::string& HelloWorld::message() const |
| 270 | +{ |
| 271 | + return m_message; |
| 272 | +} |
| 273 | + |
| 274 | +/*! |
| 275 | + * @brief This function returns a reference to member message |
| 276 | + * @return Reference to member message |
| 277 | + */ |
| 278 | +std::string& HelloWorld::message() |
| 279 | +{ |
| 280 | + return m_message; |
| 281 | +} |
| 282 | + |
| 283 | + |
| 284 | + |
| 285 | + |
| 286 | +#endif // FASTCDR_VERSION_MAJOR == 1 |
0 commit comments