From e0647ee75c256dc81c07224cd2dce67ae062ca31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Wed, 8 Nov 2023 11:59:57 +0100 Subject: [PATCH] Refs #19760. Coexist fastcdr v1 and v2 [new approach] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../DdsRecorderCommand/CMakeLists.txt | 29 +- .../DdsRecorderCommand/DdsRecorderCommand.cxx | 31 +- .../DdsRecorderCommand/DdsRecorderCommand.h | 33 +- .../DdsRecorderCommand/DdsRecorderCommand.i | 19 + .../DdsRecorderCommandCdrAux.hpp | 2 + .../DdsRecorderCommandCdrAux.ipp | 47 +- .../DdsRecorderCommandPubSubTypes.cxx | 40 +- .../DdsRecorderCommandPubSubTypes.h | 2 + .../DdsRecorderCommandv1.cxx | 296 ++++ .../DdsRecorderCommand/DdsRecorderCommandv1.h | 250 ++++ .../ddstypes/DdsRecorderStatus/CMakeLists.txt | 29 +- .../DdsRecorderStatus/DdsRecorderStatus.cxx | 31 +- .../DdsRecorderStatus/DdsRecorderStatus.h | 33 +- .../DdsRecorderStatus/DdsRecorderStatus.i | 20 + .../DdsRecorderStatusCdrAux.hpp | 2 + .../DdsRecorderStatusCdrAux.ipp | 55 +- .../DdsRecorderStatusPubSubTypes.cxx | 40 +- .../DdsRecorderStatusPubSubTypes.h | 2 + .../DdsRecorderStatus/DdsRecorderStatusv1.cxx | 359 +++++ .../DdsRecorderStatus/DdsRecorderStatusv1.h | 278 ++++ .../DdsRecorderCommand/DdsRecorderCommand.cxx | 31 +- .../DdsRecorderCommand/DdsRecorderCommand.h | 33 +- .../DdsRecorderCommandCdrAux.hpp | 2 + .../DdsRecorderCommandCdrAux.ipp | 47 +- .../DdsRecorderCommandPubSubTypes.cxx | 40 +- .../DdsRecorderCommandPubSubTypes.h | 2 + .../DdsRecorderCommandv1.cxx | 296 ++++ .../DdsRecorderCommand/DdsRecorderCommandv1.h | 250 ++++ .../DdsRecorderStatus/DdsRecorderStatus.cxx | 31 +- .../DdsRecorderStatus/DdsRecorderStatus.h | 33 +- .../DdsRecorderStatusCdrAux.hpp | 2 + .../DdsRecorderStatusCdrAux.ipp | 55 +- .../DdsRecorderStatusPubSubTypes.cxx | 40 +- .../DdsRecorderStatusPubSubTypes.h | 2 + .../DdsRecorderStatusTypeObject.cxx | 4 +- .../DdsRecorderStatusTypeObject.h | 2 + .../DdsRecorderStatus/DdsRecorderStatusv1.cxx | 363 +++++ .../DdsRecorderStatus/DdsRecorderStatusv1.h | 278 ++++ ddsrecorder/test/blackbox/mcap/CMakeLists.txt | 1 + .../mcap/types/hello_world/HelloWorld.cxx | 31 +- .../mcap/types/hello_world/HelloWorld.h | 33 +- .../types/hello_world/HelloWorldCdrAux.hpp | 2 + .../types/hello_world/HelloWorldCdrAux.ipp | 47 +- .../hello_world/HelloWorldPubSubTypes.cxx | 40 +- .../types/hello_world/HelloWorldPubSubTypes.h | 2 + .../hello_world/HelloWorldTypeObject.cxx | 4 +- .../types/hello_world/HelloWorldTypeObject.h | 2 + .../mcap/types/hello_world/HelloWorldv1.cxx | 290 ++++ .../mcap/types/hello_world/HelloWorldv1.h | 243 +++ .../common/types/DynamicTypesCollection.hpp | 54 +- .../DynamicTypesCollectionPubSubTypes.hpp | 269 ++-- .../common/types/DynamicTypesCollectionv1.hpp | 432 ++++++ .../common/types/DynamicTypesCollection.cpp | 110 +- .../types/DynamicTypesCollectionCdrAux.hpp | 6 + .../types/DynamicTypesCollectionCdrAux.ipp | 100 +- .../DynamicTypesCollectionPubSubTypes.cpp | 73 +- .../common/types/DynamicTypesCollectionv1.cpp | 523 +++++++ ddsreplayer/test/blackbox/mcap/CMakeLists.txt | 1 + .../mcap/dds/types/hello_world/HelloWorld.cxx | 31 +- .../mcap/dds/types/hello_world/HelloWorld.h | 33 +- .../types/hello_world/HelloWorldCdrAux.hpp | 2 + .../types/hello_world/HelloWorldCdrAux.ipp | 47 +- .../hello_world/HelloWorldPubSubTypes.cxx | 40 +- .../types/hello_world/HelloWorldPubSubTypes.h | 2 + .../dds/types/hello_world/HelloWorldv1.cxx | 286 ++++ .../mcap/dds/types/hello_world/HelloWorldv1.h | 243 +++ .../types/complete/Complete.cxx | 95 +- .../types/complete/Complete.h | 109 +- .../types/complete/CompleteCdrAux.hpp | 10 + .../types/complete/CompleteCdrAux.ipp | 268 +--- .../types/complete/CompletePubSubTypes.cxx | 196 ++- .../types/complete/CompletePubSubTypes.h | 10 + .../types/complete/CompleteTypeObject.cxx | 20 +- .../types/complete/CompleteTypeObject.h | 10 + .../types/complete/Completev1.cxx | 1333 +++++++++++++++++ .../types/complete/Completev1.h | 1009 +++++++++++++ .../types/hello_world/HelloWorld.cxx | 31 +- .../types/hello_world/HelloWorld.h | 33 +- .../types/hello_world/HelloWorldCdrAux.hpp | 2 + .../types/hello_world/HelloWorldCdrAux.ipp | 47 +- .../hello_world/HelloWorldPubSubTypes.cxx | 40 +- .../types/hello_world/HelloWorldPubSubTypes.h | 2 + .../hello_world/HelloWorldTypeObject.cxx | 4 +- .../types/hello_world/HelloWorldTypeObject.h | 2 + .../types/hello_world/HelloWorldv1.cxx | 290 ++++ .../types/hello_world/HelloWorldv1.h | 243 +++ 86 files changed, 8294 insertions(+), 1516 deletions(-) create mode 100644 controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.cxx create mode 100644 controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.h create mode 100644 controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.cxx create mode 100644 controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.h create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.cxx create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.h create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.cxx create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.h create mode 100644 ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx create mode 100644 ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.h create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionv1.hpp create mode 100644 ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionv1.cpp create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.h create mode 100644 resources/dds/TypeLookupService/types/complete/Completev1.cxx create mode 100644 resources/dds/TypeLookupService/types/complete/Completev1.h create mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.cxx create mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.h diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt b/controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt index 099d6fbad..95749dc5f 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt @@ -25,22 +25,26 @@ project(DdsRecorderCommand) find_package(fastcdr REQUIRED) find_package(fastrtps REQUIRED) - -set(${PROJECT_NAME}_FILES - DdsRecorderCommand.cxx - DdsRecorderCommandPubSubTypes.cxx - ) - -include_directories() - set(CMAKE_POSITION_INDEPENDENT_CODE ON) #Create library for C++ types -add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_FILES}) +add_library(${PROJECT_NAME} SHARED + DdsRecorderCommand.cxx + DdsRecorderCommandv1.cxx + DdsRecorderCommandPubSubTypes.cxx + ) if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) endif(WIN32) -target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_include_directories(${PROJECT_NAME} PUBLIC + ${PROJECT_SOURCE_DIR} + ) +target_link_libraries(${PROJECT_NAME} + PUBLIC + fastcdr + fastrtps + ) ############################################################################### # Python bindings for type @@ -70,10 +74,6 @@ SET_SOURCE_FILES_PROPERTIES( USE_TARGET_INCLUDE_DIRECTORIES TRUE ) -include_directories( - ${PROJECT_SOURCE_DIR} - ) - set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/") SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} @@ -81,6 +81,7 @@ SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} LANGUAGE python SOURCES ${${PROJECT_NAME}_MODULE_FILES}) +set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY CXX_STANDARD 11) if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8) set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64) endif() diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.cxx b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.cxx index bb21f5f97..22960741b 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.cxx @@ -27,19 +27,22 @@ char dummy; #endif // _WIN32 #include "DdsRecorderCommand.h" -#include -#include +#if FASTCDR_VERSION_MAJOR > 1 -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderCommandCdrAux.ipp" +#include + +#include using namespace eprosima::fastcdr::exception; +#include + + + DdsRecorderCommand::DdsRecorderCommand() { - } DdsRecorderCommand::~DdsRecorderCommand() @@ -91,19 +94,6 @@ bool DdsRecorderCommand::operator !=( return !(*this == x); } -void DdsRecorderCommand::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void DdsRecorderCommand::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function copies the value in member command * @param _command New value to be copied in member command @@ -181,3 +171,8 @@ std::string& DdsRecorderCommand::args() return m_args; } + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderCommandCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.h b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.h index 150211df1..8d2a241c4 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.h +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "DdsRecorderCommandv1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ #define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand @@ -185,23 +188,6 @@ class DdsRecorderCommand */ eProsima_user_DllExport std::string& args(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: std::string m_command; @@ -211,3 +197,6 @@ class DdsRecorderCommand #endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.i b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.i index a1d65b5d7..dd02ba044 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.i +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.i @@ -45,10 +45,28 @@ #include %} +%include +#if FASTCDR_VERSION_MAJOR > 1 +%import(module="fastdds") "fastcdr/xcdr/optional.hpp" +#endif %import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp" %import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp" %import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" +%define %traits_penumn(Type...) + %fragment(SWIG_Traits_frag(Type),"header", + fragment="StdTraits") { +namespace swig { + template <> struct traits< Type > { + typedef value_category category; + static const char* type_name() { return #Type; } + }; +} +} +%enddef + + + //////////////////////////////////////////////////////// // Binding for class DdsRecorderCommand //////////////////////////////////////////////////////// @@ -68,6 +86,7 @@ %rename("%s") DdsRecorderCommand::command() const; + %ignore DdsRecorderCommand::args(std::string&&); // Overloaded getter methods shadow each other and are equivalent in python diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp index 3ef59e4b5..cafda9b13 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderCommand& data); diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp index 32ab13d20..4c42e077b 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp @@ -25,10 +25,7 @@ #include "DdsRecorderCommandCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,24 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -81,8 +62,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -90,33 +69,17 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const DdsRecorderCommand& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.command() - ; - - scdr << data.args() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.command() << eprosima::fastcdr::MemberId(1) << data.args() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -124,11 +87,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, DdsRecorderCommand& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.command(); - cdr >> data.args(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -151,7 +109,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index 6d92624f6..553fdc9ee 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "DdsRecorderCommandPubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() { setName("DdsRecorderCommand"); - uint32_t type_size = DdsRecorderCommand_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderCommand::getMaxCdrSerializedSize(); +#else + DdsRecorderCommand_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function DdsRecorderCommandPubSubType::getSerializedSizeProvide { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool DdsRecorderCommandPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DdsRecorderCommand_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h index c56ffc385..aab37a3aa 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.cxx b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.cxx new file mode 100644 index 000000000..def5ba455 --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.cxx @@ -0,0 +1,296 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderCommand.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "DdsRecorderCommand.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define DdsRecorderCommand_max_cdr_typesize 524ULL; + + + + +DdsRecorderCommand::DdsRecorderCommand() +{ + // /type_d() m_command + + // /type_d() m_args + + +} + +DdsRecorderCommand::~DdsRecorderCommand() +{ +} + +DdsRecorderCommand::DdsRecorderCommand( + const DdsRecorderCommand& x) +{ + m_command = x.m_command; + + + m_args = x.m_args; + +} + +DdsRecorderCommand::DdsRecorderCommand( + DdsRecorderCommand&& x) noexcept +{ + m_command = std::move(x.m_command); + + + m_args = std::move(x.m_args); + +} + +DdsRecorderCommand& DdsRecorderCommand::operator =( + const DdsRecorderCommand& x) +{ + m_command = x.m_command; + + + m_args = x.m_args; + + return *this; +} + +DdsRecorderCommand& DdsRecorderCommand::operator =( + DdsRecorderCommand&& x) noexcept +{ + m_command = std::move(x.m_command); + + + m_args = std::move(x.m_args); + + return *this; +} + +bool DdsRecorderCommand::operator ==( + const DdsRecorderCommand& x) const +{ + return (m_command == x.m_command && + m_args == x.m_args); +} + +bool DdsRecorderCommand::operator !=( + const DdsRecorderCommand& x) const +{ + return !(*this == x); +} + +size_t DdsRecorderCommand::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return DdsRecorderCommand_max_cdr_typesize; +} + +size_t DdsRecorderCommand::getCdrSerializedSize( + const DdsRecorderCommand& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void DdsRecorderCommand::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_command.c_str(); + + scdr << m_args.c_str(); + +} + +void DdsRecorderCommand::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_command; + + + + dcdr >> m_args; + + +} + + +bool DdsRecorderCommand::isKeyDefined() +{ + return false; +} + +void DdsRecorderCommand::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member command + * @param _command New value to be copied in member command + */ +void DdsRecorderCommand::command( + const std::string& _command) +{ + m_command = _command; +} + +/*! + * @brief This function moves the value in member command + * @param _command New value to be moved in member command + */ +void DdsRecorderCommand::command( + std::string&& _command) +{ + m_command = std::move(_command); +} + +/*! + * @brief This function returns a constant reference to member command + * @return Constant reference to member command + */ +const std::string& DdsRecorderCommand::command() const +{ + return m_command; +} + +/*! + * @brief This function returns a reference to member command + * @return Reference to member command + */ +std::string& DdsRecorderCommand::command() +{ + return m_command; +} + + +/*! + * @brief This function copies the value in member args + * @param _args New value to be copied in member args + */ +void DdsRecorderCommand::args( + const std::string& _args) +{ + m_args = _args; +} + +/*! + * @brief This function moves the value in member args + * @param _args New value to be moved in member args + */ +void DdsRecorderCommand::args( + std::string&& _args) +{ + m_args = std::move(_args); +} + +/*! + * @brief This function returns a constant reference to member args + * @return Constant reference to member args + */ +const std::string& DdsRecorderCommand::args() const +{ + return m_args; +} + +/*! + * @brief This function returns a reference to member args + * @return Reference to member args + */ +std::string& DdsRecorderCommand::args() +{ + return m_args; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.h b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.h new file mode 100644 index 000000000..785d5367f --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.h @@ -0,0 +1,250 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderCommand.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ +#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(DDSRECORDERCOMMAND_SOURCE) +#define DDSRECORDERCOMMAND_DllAPI __declspec( dllexport ) +#else +#define DDSRECORDERCOMMAND_DllAPI __declspec( dllimport ) +#endif // DDSRECORDERCOMMAND_SOURCE +#else +#define DDSRECORDERCOMMAND_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define DDSRECORDERCOMMAND_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. + * @ingroup DdsRecorderCommand + */ +class DdsRecorderCommand +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport DdsRecorderCommand(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~DdsRecorderCommand(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand( + const DdsRecorderCommand& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand( + DdsRecorderCommand&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand& operator =( + const DdsRecorderCommand& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand& operator =( + DdsRecorderCommand&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderCommand object to compare. + */ + eProsima_user_DllExport bool operator ==( + const DdsRecorderCommand& x) const; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderCommand object to compare. + */ + eProsima_user_DllExport bool operator !=( + const DdsRecorderCommand& x) const; + + /*! + * @brief This function copies the value in member command + * @param _command New value to be copied in member command + */ + eProsima_user_DllExport void command( + const std::string& _command); + + /*! + * @brief This function moves the value in member command + * @param _command New value to be moved in member command + */ + eProsima_user_DllExport void command( + std::string&& _command); + + /*! + * @brief This function returns a constant reference to member command + * @return Constant reference to member command + */ + eProsima_user_DllExport const std::string& command() const; + + /*! + * @brief This function returns a reference to member command + * @return Reference to member command + */ + eProsima_user_DllExport std::string& command(); + + + /*! + * @brief This function copies the value in member args + * @param _args New value to be copied in member args + */ + eProsima_user_DllExport void args( + const std::string& _args); + + /*! + * @brief This function moves the value in member args + * @param _args New value to be moved in member args + */ + eProsima_user_DllExport void args( + std::string&& _args); + + /*! + * @brief This function returns a constant reference to member args + * @return Constant reference to member args + */ + eProsima_user_DllExport const std::string& args() const; + + /*! + * @brief This function returns a reference to member args + * @return Reference to member args + */ + eProsima_user_DllExport std::string& args(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const DdsRecorderCommand& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + std::string m_command; + std::string m_args; + +}; + + +#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt b/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt index 140cde828..36661fb64 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt @@ -25,22 +25,26 @@ project(DdsRecorderStatus) find_package(fastcdr REQUIRED) find_package(fastrtps REQUIRED) - -set(${PROJECT_NAME}_FILES - DdsRecorderStatus.cxx - DdsRecorderStatusPubSubTypes.cxx - ) - -include_directories() - set(CMAKE_POSITION_INDEPENDENT_CODE ON) #Create library for C++ types -add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_FILES}) +add_library(${PROJECT_NAME} SHARED + DdsRecorderStatus.cxx + DdsRecorderStatusv1.cxx + DdsRecorderStatusPubSubTypes.cxx + ) if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) endif(WIN32) -target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_include_directories(${PROJECT_NAME} PUBLIC + ${PROJECT_SOURCE_DIR} + ) +target_link_libraries(${PROJECT_NAME} + PUBLIC + fastcdr + fastrtps + ) ############################################################################### # Python bindings for type @@ -70,10 +74,6 @@ SET_SOURCE_FILES_PROPERTIES( USE_TARGET_INCLUDE_DIRECTORIES TRUE ) -include_directories( - ${PROJECT_SOURCE_DIR} - ) - set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/") SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} @@ -81,6 +81,7 @@ SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} LANGUAGE python SOURCES ${${PROJECT_NAME}_MODULE_FILES}) +set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY CXX_STANDARD 11) if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8) set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64) endif() diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.cxx b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.cxx index 98e6a90af..c059390b5 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.cxx @@ -27,19 +27,22 @@ char dummy; #endif // _WIN32 #include "DdsRecorderStatus.h" -#include -#include +#if FASTCDR_VERSION_MAJOR > 1 -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderStatusCdrAux.ipp" +#include + +#include using namespace eprosima::fastcdr::exception; +#include + + + DdsRecorderStatus::DdsRecorderStatus() { - } DdsRecorderStatus::~DdsRecorderStatus() @@ -96,19 +99,6 @@ bool DdsRecorderStatus::operator !=( return !(*this == x); } -void DdsRecorderStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void DdsRecorderStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function copies the value in member previous * @param _previous New value to be copied in member previous @@ -225,3 +215,8 @@ std::string& DdsRecorderStatus::info() return m_info; } + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderStatusCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.h b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.h index 0fc66a65b..e5cc4053e 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.h +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "DdsRecorderStatusv1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ #define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus @@ -212,23 +215,6 @@ class DdsRecorderStatus */ eProsima_user_DllExport std::string& info(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: std::string m_previous; @@ -239,3 +225,6 @@ class DdsRecorderStatus #endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.i b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.i index 35c4aab8e..c724a6302 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.i +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.i @@ -45,10 +45,28 @@ #include %} +%include +#if FASTCDR_VERSION_MAJOR > 1 +%import(module="fastdds") "fastcdr/xcdr/optional.hpp" +#endif %import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp" %import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp" %import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" +%define %traits_penumn(Type...) + %fragment(SWIG_Traits_frag(Type),"header", + fragment="StdTraits") { +namespace swig { + template <> struct traits< Type > { + typedef value_category category; + static const char* type_name() { return #Type; } + }; +} +} +%enddef + + + //////////////////////////////////////////////////////// // Binding for class DdsRecorderStatus //////////////////////////////////////////////////////// @@ -68,6 +86,7 @@ %rename("%s") DdsRecorderStatus::previous() const; + %ignore DdsRecorderStatus::current(std::string&&); // Overloaded getter methods shadow each other and are equivalent in python @@ -77,6 +96,7 @@ %rename("%s") DdsRecorderStatus::current() const; + %ignore DdsRecorderStatus::info(std::string&&); // Overloaded getter methods shadow each other and are equivalent in python diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp index 679c8b6b4..cfbb11098 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderStatus& data); diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp index 669eaa281..115a5829f 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp @@ -25,10 +25,7 @@ #include "DdsRecorderStatusCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,27 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -87,8 +65,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -96,38 +72,18 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const DdsRecorderStatus& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.previous() - ; - - scdr << data.current() - ; - - - scdr << data.info() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.previous() << eprosima::fastcdr::MemberId(1) << data.current() << eprosima::fastcdr::MemberId(2) << data.info() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -135,12 +91,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, DdsRecorderStatus& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.previous(); - cdr >> data.current(); - cdr >> data.info(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -167,7 +117,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 068b76f2f..e84deafec 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "DdsRecorderStatusPubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() { setName("DdsRecorderStatus"); - uint32_t type_size = DdsRecorderStatus_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderStatus::getMaxCdrSerializedSize(); +#else + DdsRecorderStatus_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool DdsRecorderStatusPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DdsRecorderStatus_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h index 7ec57ced3..566b4857b 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.cxx b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.cxx new file mode 100644 index 000000000..869db903a --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.cxx @@ -0,0 +1,359 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderStatus.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "DdsRecorderStatus.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define DdsRecorderStatus_max_cdr_typesize 784ULL; + + + + +DdsRecorderStatus::DdsRecorderStatus() +{ + // /type_d() m_previous + + // /type_d() m_current + + // /type_d() m_info + + +} + +DdsRecorderStatus::~DdsRecorderStatus() +{ +} + +DdsRecorderStatus::DdsRecorderStatus( + const DdsRecorderStatus& x) +{ + m_previous = x.m_previous; + + + m_current = x.m_current; + + + m_info = x.m_info; + +} + +DdsRecorderStatus::DdsRecorderStatus( + DdsRecorderStatus&& x) noexcept +{ + m_previous = std::move(x.m_previous); + + + m_current = std::move(x.m_current); + + + m_info = std::move(x.m_info); + +} + +DdsRecorderStatus& DdsRecorderStatus::operator =( + const DdsRecorderStatus& x) +{ + m_previous = x.m_previous; + + + m_current = x.m_current; + + + m_info = x.m_info; + + return *this; +} + +DdsRecorderStatus& DdsRecorderStatus::operator =( + DdsRecorderStatus&& x) noexcept +{ + m_previous = std::move(x.m_previous); + + + m_current = std::move(x.m_current); + + + m_info = std::move(x.m_info); + + return *this; +} + +bool DdsRecorderStatus::operator ==( + const DdsRecorderStatus& x) const +{ + return (m_previous == x.m_previous && + m_current == x.m_current && + m_info == x.m_info); +} + +bool DdsRecorderStatus::operator !=( + const DdsRecorderStatus& x) const +{ + return !(*this == x); +} + +size_t DdsRecorderStatus::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return DdsRecorderStatus_max_cdr_typesize; +} + +size_t DdsRecorderStatus::getCdrSerializedSize( + const DdsRecorderStatus& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void DdsRecorderStatus::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_previous.c_str(); + + scdr << m_current.c_str(); + + scdr << m_info.c_str(); + +} + +void DdsRecorderStatus::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_previous; + + + + dcdr >> m_current; + + + + dcdr >> m_info; + + +} + + +bool DdsRecorderStatus::isKeyDefined() +{ + return false; +} + +void DdsRecorderStatus::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member previous + * @param _previous New value to be copied in member previous + */ +void DdsRecorderStatus::previous( + const std::string& _previous) +{ + m_previous = _previous; +} + +/*! + * @brief This function moves the value in member previous + * @param _previous New value to be moved in member previous + */ +void DdsRecorderStatus::previous( + std::string&& _previous) +{ + m_previous = std::move(_previous); +} + +/*! + * @brief This function returns a constant reference to member previous + * @return Constant reference to member previous + */ +const std::string& DdsRecorderStatus::previous() const +{ + return m_previous; +} + +/*! + * @brief This function returns a reference to member previous + * @return Reference to member previous + */ +std::string& DdsRecorderStatus::previous() +{ + return m_previous; +} + + +/*! + * @brief This function copies the value in member current + * @param _current New value to be copied in member current + */ +void DdsRecorderStatus::current( + const std::string& _current) +{ + m_current = _current; +} + +/*! + * @brief This function moves the value in member current + * @param _current New value to be moved in member current + */ +void DdsRecorderStatus::current( + std::string&& _current) +{ + m_current = std::move(_current); +} + +/*! + * @brief This function returns a constant reference to member current + * @return Constant reference to member current + */ +const std::string& DdsRecorderStatus::current() const +{ + return m_current; +} + +/*! + * @brief This function returns a reference to member current + * @return Reference to member current + */ +std::string& DdsRecorderStatus::current() +{ + return m_current; +} + + +/*! + * @brief This function copies the value in member info + * @param _info New value to be copied in member info + */ +void DdsRecorderStatus::info( + const std::string& _info) +{ + m_info = _info; +} + +/*! + * @brief This function moves the value in member info + * @param _info New value to be moved in member info + */ +void DdsRecorderStatus::info( + std::string&& _info) +{ + m_info = std::move(_info); +} + +/*! + * @brief This function returns a constant reference to member info + * @return Constant reference to member info + */ +const std::string& DdsRecorderStatus::info() const +{ + return m_info; +} + +/*! + * @brief This function returns a reference to member info + * @return Reference to member info + */ +std::string& DdsRecorderStatus::info() +{ + return m_info; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.h b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.h new file mode 100644 index 000000000..30916d33e --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.h @@ -0,0 +1,278 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderStatus.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ +#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(DDSRECORDERSTATUS_SOURCE) +#define DDSRECORDERSTATUS_DllAPI __declspec( dllexport ) +#else +#define DDSRECORDERSTATUS_DllAPI __declspec( dllimport ) +#endif // DDSRECORDERSTATUS_SOURCE +#else +#define DDSRECORDERSTATUS_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define DDSRECORDERSTATUS_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. + * @ingroup DdsRecorderStatus + */ +class DdsRecorderStatus +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport DdsRecorderStatus(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~DdsRecorderStatus(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus( + const DdsRecorderStatus& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus( + DdsRecorderStatus&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus& operator =( + const DdsRecorderStatus& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus& operator =( + DdsRecorderStatus&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderStatus object to compare. + */ + eProsima_user_DllExport bool operator ==( + const DdsRecorderStatus& x) const; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderStatus object to compare. + */ + eProsima_user_DllExport bool operator !=( + const DdsRecorderStatus& x) const; + + /*! + * @brief This function copies the value in member previous + * @param _previous New value to be copied in member previous + */ + eProsima_user_DllExport void previous( + const std::string& _previous); + + /*! + * @brief This function moves the value in member previous + * @param _previous New value to be moved in member previous + */ + eProsima_user_DllExport void previous( + std::string&& _previous); + + /*! + * @brief This function returns a constant reference to member previous + * @return Constant reference to member previous + */ + eProsima_user_DllExport const std::string& previous() const; + + /*! + * @brief This function returns a reference to member previous + * @return Reference to member previous + */ + eProsima_user_DllExport std::string& previous(); + + + /*! + * @brief This function copies the value in member current + * @param _current New value to be copied in member current + */ + eProsima_user_DllExport void current( + const std::string& _current); + + /*! + * @brief This function moves the value in member current + * @param _current New value to be moved in member current + */ + eProsima_user_DllExport void current( + std::string&& _current); + + /*! + * @brief This function returns a constant reference to member current + * @return Constant reference to member current + */ + eProsima_user_DllExport const std::string& current() const; + + /*! + * @brief This function returns a reference to member current + * @return Reference to member current + */ + eProsima_user_DllExport std::string& current(); + + + /*! + * @brief This function copies the value in member info + * @param _info New value to be copied in member info + */ + eProsima_user_DllExport void info( + const std::string& _info); + + /*! + * @brief This function moves the value in member info + * @param _info New value to be moved in member info + */ + eProsima_user_DllExport void info( + std::string&& _info); + + /*! + * @brief This function returns a constant reference to member info + * @return Constant reference to member info + */ + eProsima_user_DllExport const std::string& info() const; + + /*! + * @brief This function returns a reference to member info + * @return Reference to member info + */ + eProsima_user_DllExport std::string& info(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const DdsRecorderStatus& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + std::string m_previous; + std::string m_current; + std::string m_info; + +}; + + +#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.cxx index bb21f5f97..22960741b 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.cxx @@ -27,19 +27,22 @@ char dummy; #endif // _WIN32 #include "DdsRecorderCommand.h" -#include -#include +#if FASTCDR_VERSION_MAJOR > 1 -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderCommandCdrAux.ipp" +#include + +#include using namespace eprosima::fastcdr::exception; +#include + + + DdsRecorderCommand::DdsRecorderCommand() { - } DdsRecorderCommand::~DdsRecorderCommand() @@ -91,19 +94,6 @@ bool DdsRecorderCommand::operator !=( return !(*this == x); } -void DdsRecorderCommand::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void DdsRecorderCommand::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function copies the value in member command * @param _command New value to be copied in member command @@ -181,3 +171,8 @@ std::string& DdsRecorderCommand::args() return m_args; } + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderCommandCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.h index 150211df1..8d2a241c4 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "DdsRecorderCommandv1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ #define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand @@ -185,23 +188,6 @@ class DdsRecorderCommand */ eProsima_user_DllExport std::string& args(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: std::string m_command; @@ -211,3 +197,6 @@ class DdsRecorderCommand #endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp index 3ef59e4b5..cafda9b13 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderCommand& data); diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp index 32ab13d20..4c42e077b 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp @@ -25,10 +25,7 @@ #include "DdsRecorderCommandCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,24 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -81,8 +62,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -90,33 +69,17 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const DdsRecorderCommand& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.command() - ; - - scdr << data.args() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.command() << eprosima::fastcdr::MemberId(1) << data.args() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -124,11 +87,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, DdsRecorderCommand& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.command(); - cdr >> data.args(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -151,7 +109,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index 6d92624f6..553fdc9ee 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "DdsRecorderCommandPubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() { setName("DdsRecorderCommand"); - uint32_t type_size = DdsRecorderCommand_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderCommand::getMaxCdrSerializedSize(); +#else + DdsRecorderCommand_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function DdsRecorderCommandPubSubType::getSerializedSizeProvide { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool DdsRecorderCommandPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DdsRecorderCommand_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h index c56ffc385..aab37a3aa 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.cxx new file mode 100644 index 000000000..def5ba455 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.cxx @@ -0,0 +1,296 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderCommand.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "DdsRecorderCommand.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define DdsRecorderCommand_max_cdr_typesize 524ULL; + + + + +DdsRecorderCommand::DdsRecorderCommand() +{ + // /type_d() m_command + + // /type_d() m_args + + +} + +DdsRecorderCommand::~DdsRecorderCommand() +{ +} + +DdsRecorderCommand::DdsRecorderCommand( + const DdsRecorderCommand& x) +{ + m_command = x.m_command; + + + m_args = x.m_args; + +} + +DdsRecorderCommand::DdsRecorderCommand( + DdsRecorderCommand&& x) noexcept +{ + m_command = std::move(x.m_command); + + + m_args = std::move(x.m_args); + +} + +DdsRecorderCommand& DdsRecorderCommand::operator =( + const DdsRecorderCommand& x) +{ + m_command = x.m_command; + + + m_args = x.m_args; + + return *this; +} + +DdsRecorderCommand& DdsRecorderCommand::operator =( + DdsRecorderCommand&& x) noexcept +{ + m_command = std::move(x.m_command); + + + m_args = std::move(x.m_args); + + return *this; +} + +bool DdsRecorderCommand::operator ==( + const DdsRecorderCommand& x) const +{ + return (m_command == x.m_command && + m_args == x.m_args); +} + +bool DdsRecorderCommand::operator !=( + const DdsRecorderCommand& x) const +{ + return !(*this == x); +} + +size_t DdsRecorderCommand::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return DdsRecorderCommand_max_cdr_typesize; +} + +size_t DdsRecorderCommand::getCdrSerializedSize( + const DdsRecorderCommand& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void DdsRecorderCommand::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_command.c_str(); + + scdr << m_args.c_str(); + +} + +void DdsRecorderCommand::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_command; + + + + dcdr >> m_args; + + +} + + +bool DdsRecorderCommand::isKeyDefined() +{ + return false; +} + +void DdsRecorderCommand::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member command + * @param _command New value to be copied in member command + */ +void DdsRecorderCommand::command( + const std::string& _command) +{ + m_command = _command; +} + +/*! + * @brief This function moves the value in member command + * @param _command New value to be moved in member command + */ +void DdsRecorderCommand::command( + std::string&& _command) +{ + m_command = std::move(_command); +} + +/*! + * @brief This function returns a constant reference to member command + * @return Constant reference to member command + */ +const std::string& DdsRecorderCommand::command() const +{ + return m_command; +} + +/*! + * @brief This function returns a reference to member command + * @return Reference to member command + */ +std::string& DdsRecorderCommand::command() +{ + return m_command; +} + + +/*! + * @brief This function copies the value in member args + * @param _args New value to be copied in member args + */ +void DdsRecorderCommand::args( + const std::string& _args) +{ + m_args = _args; +} + +/*! + * @brief This function moves the value in member args + * @param _args New value to be moved in member args + */ +void DdsRecorderCommand::args( + std::string&& _args) +{ + m_args = std::move(_args); +} + +/*! + * @brief This function returns a constant reference to member args + * @return Constant reference to member args + */ +const std::string& DdsRecorderCommand::args() const +{ + return m_args; +} + +/*! + * @brief This function returns a reference to member args + * @return Reference to member args + */ +std::string& DdsRecorderCommand::args() +{ + return m_args; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.h new file mode 100644 index 000000000..785d5367f --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.h @@ -0,0 +1,250 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderCommand.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ +#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(DDSRECORDERCOMMAND_SOURCE) +#define DDSRECORDERCOMMAND_DllAPI __declspec( dllexport ) +#else +#define DDSRECORDERCOMMAND_DllAPI __declspec( dllimport ) +#endif // DDSRECORDERCOMMAND_SOURCE +#else +#define DDSRECORDERCOMMAND_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define DDSRECORDERCOMMAND_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. + * @ingroup DdsRecorderCommand + */ +class DdsRecorderCommand +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport DdsRecorderCommand(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~DdsRecorderCommand(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand( + const DdsRecorderCommand& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand( + DdsRecorderCommand&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand& operator =( + const DdsRecorderCommand& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object DdsRecorderCommand that will be copied. + */ + eProsima_user_DllExport DdsRecorderCommand& operator =( + DdsRecorderCommand&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderCommand object to compare. + */ + eProsima_user_DllExport bool operator ==( + const DdsRecorderCommand& x) const; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderCommand object to compare. + */ + eProsima_user_DllExport bool operator !=( + const DdsRecorderCommand& x) const; + + /*! + * @brief This function copies the value in member command + * @param _command New value to be copied in member command + */ + eProsima_user_DllExport void command( + const std::string& _command); + + /*! + * @brief This function moves the value in member command + * @param _command New value to be moved in member command + */ + eProsima_user_DllExport void command( + std::string&& _command); + + /*! + * @brief This function returns a constant reference to member command + * @return Constant reference to member command + */ + eProsima_user_DllExport const std::string& command() const; + + /*! + * @brief This function returns a reference to member command + * @return Reference to member command + */ + eProsima_user_DllExport std::string& command(); + + + /*! + * @brief This function copies the value in member args + * @param _args New value to be copied in member args + */ + eProsima_user_DllExport void args( + const std::string& _args); + + /*! + * @brief This function moves the value in member args + * @param _args New value to be moved in member args + */ + eProsima_user_DllExport void args( + std::string&& _args); + + /*! + * @brief This function returns a constant reference to member args + * @return Constant reference to member args + */ + eProsima_user_DllExport const std::string& args() const; + + /*! + * @brief This function returns a reference to member args + * @return Reference to member args + */ + eProsima_user_DllExport std::string& args(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const DdsRecorderCommand& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + std::string m_command; + std::string m_args; + +}; + + +#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.cxx index 6c3acd6ed..bffc3f5db 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.cxx @@ -27,21 +27,24 @@ char dummy; #endif // _WIN32 #include "DdsRecorderStatus.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #include "DdsRecorderStatusTypeObject.h" -#include +#include + + +#include +using namespace eprosima::fastcdr::exception; #include -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderStatusCdrAux.ipp" -using namespace eprosima::fastcdr::exception; DdsRecorderStatus::DdsRecorderStatus() { - // Just to register all known types registerDdsRecorderStatusTypes(); } @@ -100,19 +103,6 @@ bool DdsRecorderStatus::operator !=( return !(*this == x); } -void DdsRecorderStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void DdsRecorderStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function copies the value in member previous * @param _previous New value to be copied in member previous @@ -229,3 +219,8 @@ std::string& DdsRecorderStatus::info() return m_info; } + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderStatusCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.h index 0fc66a65b..e5cc4053e 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "DdsRecorderStatusv1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ #define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus @@ -212,23 +215,6 @@ class DdsRecorderStatus */ eProsima_user_DllExport std::string& info(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: std::string m_previous; @@ -239,3 +225,6 @@ class DdsRecorderStatus #endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp index 679c8b6b4..cfbb11098 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderStatus& data); diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp index 669eaa281..115a5829f 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp @@ -25,10 +25,7 @@ #include "DdsRecorderStatusCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,27 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -87,8 +65,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -96,38 +72,18 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const DdsRecorderStatus& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.previous() - ; - - scdr << data.current() - ; - - - scdr << data.info() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.previous() << eprosima::fastcdr::MemberId(1) << data.current() << eprosima::fastcdr::MemberId(2) << data.info() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -135,12 +91,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, DdsRecorderStatus& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.previous(); - cdr >> data.current(); - cdr >> data.info(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -167,7 +117,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 068b76f2f..e84deafec 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "DdsRecorderStatusPubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() { setName("DdsRecorderStatus"); - uint32_t type_size = DdsRecorderStatus_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderStatus::getMaxCdrSerializedSize(); +#else + DdsRecorderStatus_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool DdsRecorderStatusPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || DdsRecorderStatus_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h index 7ec57ced3..566b4857b 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx index 1c969cad8..eff333992 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx @@ -52,6 +52,8 @@ void registerDdsRecorderStatusTypes() }); } + + const TypeIdentifier* GetDdsRecorderStatusIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderStatus", complete); @@ -157,7 +159,6 @@ const TypeObject* GetMinimalDdsRecorderStatusObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -259,7 +260,6 @@ const TypeObject* GetCompleteDdsRecorderStatusObject() // Header type_object->complete().struct_type().header().detail().type_name("DdsRecorderStatus"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.h index 5b2094c99..b7cfcf1d5 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.h @@ -54,6 +54,8 @@ using namespace eprosima::fastrtps::types; eProsima_user_DllExport void registerDdsRecorderStatusTypes(); + + eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderStatusIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetDdsRecorderStatusObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderStatusObject(); diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.cxx new file mode 100644 index 000000000..f1f5eb8a8 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.cxx @@ -0,0 +1,363 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderStatus.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "DdsRecorderStatus.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include "DdsRecorderStatusTypeObject.h" + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define DdsRecorderStatus_max_cdr_typesize 784ULL; + + + + +DdsRecorderStatus::DdsRecorderStatus() +{ + // /type_d() m_previous + + // /type_d() m_current + + // /type_d() m_info + + + // Just to register all known types + registerDdsRecorderStatusTypes(); +} + +DdsRecorderStatus::~DdsRecorderStatus() +{ +} + +DdsRecorderStatus::DdsRecorderStatus( + const DdsRecorderStatus& x) +{ + m_previous = x.m_previous; + + + m_current = x.m_current; + + + m_info = x.m_info; + +} + +DdsRecorderStatus::DdsRecorderStatus( + DdsRecorderStatus&& x) noexcept +{ + m_previous = std::move(x.m_previous); + + + m_current = std::move(x.m_current); + + + m_info = std::move(x.m_info); + +} + +DdsRecorderStatus& DdsRecorderStatus::operator =( + const DdsRecorderStatus& x) +{ + m_previous = x.m_previous; + + + m_current = x.m_current; + + + m_info = x.m_info; + + return *this; +} + +DdsRecorderStatus& DdsRecorderStatus::operator =( + DdsRecorderStatus&& x) noexcept +{ + m_previous = std::move(x.m_previous); + + + m_current = std::move(x.m_current); + + + m_info = std::move(x.m_info); + + return *this; +} + +bool DdsRecorderStatus::operator ==( + const DdsRecorderStatus& x) const +{ + return (m_previous == x.m_previous && + m_current == x.m_current && + m_info == x.m_info); +} + +bool DdsRecorderStatus::operator !=( + const DdsRecorderStatus& x) const +{ + return !(*this == x); +} + +size_t DdsRecorderStatus::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return DdsRecorderStatus_max_cdr_typesize; +} + +size_t DdsRecorderStatus::getCdrSerializedSize( + const DdsRecorderStatus& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void DdsRecorderStatus::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_previous.c_str(); + + scdr << m_current.c_str(); + + scdr << m_info.c_str(); + +} + +void DdsRecorderStatus::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_previous; + + + + dcdr >> m_current; + + + + dcdr >> m_info; + + +} + + +bool DdsRecorderStatus::isKeyDefined() +{ + return false; +} + +void DdsRecorderStatus::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member previous + * @param _previous New value to be copied in member previous + */ +void DdsRecorderStatus::previous( + const std::string& _previous) +{ + m_previous = _previous; +} + +/*! + * @brief This function moves the value in member previous + * @param _previous New value to be moved in member previous + */ +void DdsRecorderStatus::previous( + std::string&& _previous) +{ + m_previous = std::move(_previous); +} + +/*! + * @brief This function returns a constant reference to member previous + * @return Constant reference to member previous + */ +const std::string& DdsRecorderStatus::previous() const +{ + return m_previous; +} + +/*! + * @brief This function returns a reference to member previous + * @return Reference to member previous + */ +std::string& DdsRecorderStatus::previous() +{ + return m_previous; +} + + +/*! + * @brief This function copies the value in member current + * @param _current New value to be copied in member current + */ +void DdsRecorderStatus::current( + const std::string& _current) +{ + m_current = _current; +} + +/*! + * @brief This function moves the value in member current + * @param _current New value to be moved in member current + */ +void DdsRecorderStatus::current( + std::string&& _current) +{ + m_current = std::move(_current); +} + +/*! + * @brief This function returns a constant reference to member current + * @return Constant reference to member current + */ +const std::string& DdsRecorderStatus::current() const +{ + return m_current; +} + +/*! + * @brief This function returns a reference to member current + * @return Reference to member current + */ +std::string& DdsRecorderStatus::current() +{ + return m_current; +} + + +/*! + * @brief This function copies the value in member info + * @param _info New value to be copied in member info + */ +void DdsRecorderStatus::info( + const std::string& _info) +{ + m_info = _info; +} + +/*! + * @brief This function moves the value in member info + * @param _info New value to be moved in member info + */ +void DdsRecorderStatus::info( + std::string&& _info) +{ + m_info = std::move(_info); +} + +/*! + * @brief This function returns a constant reference to member info + * @return Constant reference to member info + */ +const std::string& DdsRecorderStatus::info() const +{ + return m_info; +} + +/*! + * @brief This function returns a reference to member info + * @return Reference to member info + */ +std::string& DdsRecorderStatus::info() +{ + return m_info; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.h new file mode 100644 index 000000000..30916d33e --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.h @@ -0,0 +1,278 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DdsRecorderStatus.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ +#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(DDSRECORDERSTATUS_SOURCE) +#define DDSRECORDERSTATUS_DllAPI __declspec( dllexport ) +#else +#define DDSRECORDERSTATUS_DllAPI __declspec( dllimport ) +#endif // DDSRECORDERSTATUS_SOURCE +#else +#define DDSRECORDERSTATUS_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define DDSRECORDERSTATUS_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. + * @ingroup DdsRecorderStatus + */ +class DdsRecorderStatus +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport DdsRecorderStatus(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~DdsRecorderStatus(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus( + const DdsRecorderStatus& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus( + DdsRecorderStatus&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus& operator =( + const DdsRecorderStatus& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object DdsRecorderStatus that will be copied. + */ + eProsima_user_DllExport DdsRecorderStatus& operator =( + DdsRecorderStatus&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderStatus object to compare. + */ + eProsima_user_DllExport bool operator ==( + const DdsRecorderStatus& x) const; + + /*! + * @brief Comparison operator. + * @param x DdsRecorderStatus object to compare. + */ + eProsima_user_DllExport bool operator !=( + const DdsRecorderStatus& x) const; + + /*! + * @brief This function copies the value in member previous + * @param _previous New value to be copied in member previous + */ + eProsima_user_DllExport void previous( + const std::string& _previous); + + /*! + * @brief This function moves the value in member previous + * @param _previous New value to be moved in member previous + */ + eProsima_user_DllExport void previous( + std::string&& _previous); + + /*! + * @brief This function returns a constant reference to member previous + * @return Constant reference to member previous + */ + eProsima_user_DllExport const std::string& previous() const; + + /*! + * @brief This function returns a reference to member previous + * @return Reference to member previous + */ + eProsima_user_DllExport std::string& previous(); + + + /*! + * @brief This function copies the value in member current + * @param _current New value to be copied in member current + */ + eProsima_user_DllExport void current( + const std::string& _current); + + /*! + * @brief This function moves the value in member current + * @param _current New value to be moved in member current + */ + eProsima_user_DllExport void current( + std::string&& _current); + + /*! + * @brief This function returns a constant reference to member current + * @return Constant reference to member current + */ + eProsima_user_DllExport const std::string& current() const; + + /*! + * @brief This function returns a reference to member current + * @return Reference to member current + */ + eProsima_user_DllExport std::string& current(); + + + /*! + * @brief This function copies the value in member info + * @param _info New value to be copied in member info + */ + eProsima_user_DllExport void info( + const std::string& _info); + + /*! + * @brief This function moves the value in member info + * @param _info New value to be moved in member info + */ + eProsima_user_DllExport void info( + std::string&& _info); + + /*! + * @brief This function returns a constant reference to member info + * @return Constant reference to member info + */ + eProsima_user_DllExport const std::string& info() const; + + /*! + * @brief This function returns a reference to member info + * @return Reference to member info + */ + eProsima_user_DllExport std::string& info(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const DdsRecorderStatus& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + std::string m_previous; + std::string m_current; + std::string m_info; + +}; + + +#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt index 26fea97a6..02d56416c 100644 --- a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt @@ -21,6 +21,7 @@ set(TEST_NAME McapFileCreationTest) set(TEST_SOURCES McapFileCreationTest.cpp ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorld.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx ) diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.cxx b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.cxx index 2678a873d..502f3953b 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.cxx +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.cxx @@ -27,21 +27,24 @@ char dummy; #endif // _WIN32 #include "HelloWorld.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #include "HelloWorldTypeObject.h" -#include +#include + + +#include +using namespace eprosima::fastcdr::exception; #include -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" -using namespace eprosima::fastcdr::exception; HelloWorld::HelloWorld() { - // Just to register all known types registerHelloWorldTypes(); } @@ -95,19 +98,6 @@ bool HelloWorld::operator !=( return !(*this == x); } -void HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function sets a value in member index * @param _index New value for member index @@ -175,3 +165,8 @@ std::string& HelloWorld::message() return m_message; } + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.h b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.h index 69057d262..5cd0ddba5 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.h +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "HelloWorldv1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ #define _FAST_DDS_GENERATED_HELLOWORLD_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -178,23 +181,6 @@ class HelloWorld */ eProsima_user_DllExport std::string& message(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: uint32_t m_index{0}; @@ -204,3 +190,6 @@ class HelloWorld #endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.hpp b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.hpp index 713dba562..9f346d306 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.hpp +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.ipp b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.ipp index 55034e024..42e91f3cc 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.ipp +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.ipp @@ -25,10 +25,7 @@ #include "HelloWorldCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,24 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -81,8 +62,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -90,33 +69,17 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.index() - ; - - scdr << data.message() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.index() << eprosima::fastcdr::MemberId(1) << data.message() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -124,11 +87,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, HelloWorld& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.index(); - cdr >> data.message(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -151,7 +109,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx index 7efd377ec..eae5d4a75 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "HelloWorldPubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); - uint32_t type_size = HelloWorld_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + HelloWorld::getMaxCdrSerializedSize(); +#else + HelloWorld_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool HelloWorldPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.h b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.h index f6c88d5c1..cb61cd6ba 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.h +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx index 0ff0768d6..69e829c28 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx @@ -52,6 +52,8 @@ void registerHelloWorldTypes() }); } + + const TypeIdentifier* GetHelloWorldIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); @@ -140,7 +142,6 @@ const TypeObject* GetMinimalHelloWorldObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -228,7 +229,6 @@ const TypeObject* GetCompleteHelloWorldObject() // Header type_object->complete().struct_type().header().detail().type_name("HelloWorld"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.h b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.h index c28779dbe..76b2a621e 100644 --- a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.h +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.h @@ -54,6 +54,8 @@ using namespace eprosima::fastrtps::types; eProsima_user_DllExport void registerHelloWorldTypes(); + + eProsima_user_DllExport const TypeIdentifier* GetHelloWorldIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetHelloWorldObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalHelloWorldObject(); diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx new file mode 100644 index 000000000..bb049241e --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx @@ -0,0 +1,290 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "HelloWorld.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include "HelloWorldTypeObject.h" + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define HelloWorld_max_cdr_typesize 268ULL; + + + + +HelloWorld::HelloWorld() +{ + // unsigned long m_index + m_index = 0; + // /type_d() m_message + + + // Just to register all known types + registerHelloWorldTypes(); +} + +HelloWorld::~HelloWorld() +{ +} + +HelloWorld::HelloWorld( + const HelloWorld& x) +{ + m_index = x.m_index; + + + m_message = x.m_message; + +} + +HelloWorld::HelloWorld( + HelloWorld&& x) noexcept +{ + m_index = x.m_index; + + + m_message = std::move(x.m_message); + +} + +HelloWorld& HelloWorld::operator =( + const HelloWorld& x) +{ + m_index = x.m_index; + + + m_message = x.m_message; + + return *this; +} + +HelloWorld& HelloWorld::operator =( + HelloWorld&& x) noexcept +{ + m_index = x.m_index; + + + m_message = std::move(x.m_message); + + return *this; +} + +bool HelloWorld::operator ==( + const HelloWorld& x) const +{ + return (m_index == x.m_index && + m_message == x.m_message); +} + +bool HelloWorld::operator !=( + const HelloWorld& x) const +{ + return !(*this == x); +} + +size_t HelloWorld::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return HelloWorld_max_cdr_typesize; +} + +size_t HelloWorld::getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void HelloWorld::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_index; + + scdr << m_message.c_str(); + +} + +void HelloWorld::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_index; + + + + dcdr >> m_message; + + +} + + +bool HelloWorld::isKeyDefined() +{ + return false; +} + +void HelloWorld::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void HelloWorld::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t HelloWorld::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& HelloWorld::index() +{ + return m_index; +} + + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void HelloWorld::message( + const std::string& _message) +{ + m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void HelloWorld::message( + std::string&& _message) +{ + m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::string& HelloWorld::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::string& HelloWorld::message() +{ + return m_message; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.h b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.h new file mode 100644 index 000000000..7758cd793 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.h @@ -0,0 +1,243 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(HELLOWORLD_SOURCE) +#define HELLOWORLD_DllAPI __declspec( dllexport ) +#else +#define HELLOWORLD_DllAPI __declspec( dllimport ) +#endif // HELLOWORLD_SOURCE +#else +#define HELLOWORLD_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define HELLOWORLD_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorld +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport HelloWorld(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~HelloWorld(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + const HelloWorld& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + HelloWorld&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + const HelloWorld& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + HelloWorld&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator ==( + const HelloWorld& x) const; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator !=( + const HelloWorld& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message( + const std::string& _message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message( + std::string&& _message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + uint32_t m_index; + std::string m_message; + +}; + + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollection.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollection.hpp index 54513668f..21ded9b4a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollection.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollection.hpp @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "DynamicTypesCollectionv1.hpp" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ #define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -78,6 +79,8 @@ namespace ddsrecorder { namespace participants { + + /*! * @brief This class represents the structure DynamicType defined by the user in the IDL file. * @ingroup DynamicTypesCollection @@ -218,23 +221,6 @@ class DynamicType */ eProsima_user_DllExport std::string& type_object(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: std::string m_type_name; @@ -242,6 +228,10 @@ class DynamicType std::string m_type_object; }; + + + + /*! * @brief This class represents the structure DynamicTypesCollection defined by the user in the IDL file. * @ingroup DynamicTypesCollection @@ -328,23 +318,6 @@ class DynamicTypesCollection */ eProsima_user_DllExport std::vector& dynamic_types(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: std::vector m_dynamic_types; @@ -359,3 +332,6 @@ class DynamicTypesCollection #endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionPubSubTypes.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionPubSubTypes.hpp index 15bd7da5d..22f077c7d 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionPubSubTypes.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionPubSubTypes.hpp @@ -37,188 +37,197 @@ Generated DynamicTypesCollection is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. #endif // GEN_API_VER -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -/*! - * @brief This class represents the TopicDataType of the type DynamicType defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypePubSubType : public eprosima::fastdds::dds::TopicDataType +namespace eprosima { -public: + namespace ddsrecorder + { + namespace participants + { - typedef DynamicType type; - eProsima_user_DllExport DynamicTypePubSubType(); - eProsima_user_DllExport ~DynamicTypePubSubType() override; + /*! + * @brief This class represents the TopicDataType of the type DynamicType defined by the user in the IDL file. + * @ingroup DynamicTypesCollection + */ + class DynamicTypePubSubType : public eprosima::fastdds::dds::TopicDataType + { + public: - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + typedef DynamicType type; - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport DynamicTypePubSubType(); - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; + eProsima_user_DllExport ~DynamicTypePubSubType() override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* createData() override; - eProsima_user_DllExport void deleteData( - void* data) override; + eProsima_user_DllExport void deleteData( + void* data) override; #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + return false; + } #endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN #ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + static_cast(memory); + return false; + } #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; + MD5 m_md5; + unsigned char* m_keyBuffer; -}; + }; -/*! - * @brief This class represents the TopicDataType of the type DynamicTypesCollection defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypesCollectionPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - typedef DynamicTypesCollection type; - eProsima_user_DllExport DynamicTypesCollectionPubSubType(); - eProsima_user_DllExport ~DynamicTypesCollectionPubSubType() override; - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + /*! + * @brief This class represents the TopicDataType of the type DynamicTypesCollection defined by the user in the IDL file. + * @ingroup DynamicTypesCollection + */ + class DynamicTypesCollectionPubSubType : public eprosima::fastdds::dds::TopicDataType + { + public: - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + typedef DynamicTypesCollection type; - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; + eProsima_user_DllExport DynamicTypesCollectionPubSubType(); - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport ~DynamicTypesCollectionPubSubType() override; + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* createData() override; - eProsima_user_DllExport void deleteData( - void* data) override; + eProsima_user_DllExport void deleteData( + void* data) override; #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + return false; + } #endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN #ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + static_cast(memory); + return false; + } #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; + MD5 m_md5; + unsigned char* m_keyBuffer; -}; -} // namespace participants -} // namespace ddsrecorder -} // namespace eprosima + }; + } + } +} #endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionv1.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionv1.hpp new file mode 100644 index 000000000..9220658e7 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionv1.hpp @@ -0,0 +1,432 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DynamicTypesCollection.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ +#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(DYNAMICTYPESCOLLECTION_SOURCE) +#define DYNAMICTYPESCOLLECTION_DllAPI __declspec( dllexport ) +#else +#define DYNAMICTYPESCOLLECTION_DllAPI __declspec( dllimport ) +#endif // DYNAMICTYPESCOLLECTION_SOURCE +#else +#define DYNAMICTYPESCOLLECTION_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define DYNAMICTYPESCOLLECTION_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + +namespace eprosima { + namespace ddsrecorder { + namespace participants { + + + /*! + * @brief This class represents the structure DynamicType defined by the user in the IDL file. + * @ingroup DynamicTypesCollection + */ + class DynamicType + { + public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport DynamicType(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~DynamicType(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + */ + eProsima_user_DllExport DynamicType( + const DynamicType& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + */ + eProsima_user_DllExport DynamicType( + DynamicType&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + */ + eProsima_user_DllExport DynamicType& operator =( + const DynamicType& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + */ + eProsima_user_DllExport DynamicType& operator =( + DynamicType&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x eprosima::ddsrecorder::participants::DynamicType object to compare. + */ + eProsima_user_DllExport bool operator ==( + const DynamicType& x) const; + + /*! + * @brief Comparison operator. + * @param x eprosima::ddsrecorder::participants::DynamicType object to compare. + */ + eProsima_user_DllExport bool operator !=( + const DynamicType& x) const; + + /*! + * @brief This function copies the value in member type_name + * @param _type_name New value to be copied in member type_name + */ + eProsima_user_DllExport void type_name( + const std::string& _type_name); + + /*! + * @brief This function moves the value in member type_name + * @param _type_name New value to be moved in member type_name + */ + eProsima_user_DllExport void type_name( + std::string&& _type_name); + + /*! + * @brief This function returns a constant reference to member type_name + * @return Constant reference to member type_name + */ + eProsima_user_DllExport const std::string& type_name() const; + + /*! + * @brief This function returns a reference to member type_name + * @return Reference to member type_name + */ + eProsima_user_DllExport std::string& type_name(); + + + /*! + * @brief This function copies the value in member type_information + * @param _type_information New value to be copied in member type_information + */ + eProsima_user_DllExport void type_information( + const std::string& _type_information); + + /*! + * @brief This function moves the value in member type_information + * @param _type_information New value to be moved in member type_information + */ + eProsima_user_DllExport void type_information( + std::string&& _type_information); + + /*! + * @brief This function returns a constant reference to member type_information + * @return Constant reference to member type_information + */ + eProsima_user_DllExport const std::string& type_information() const; + + /*! + * @brief This function returns a reference to member type_information + * @return Reference to member type_information + */ + eProsima_user_DllExport std::string& type_information(); + + + /*! + * @brief This function copies the value in member type_object + * @param _type_object New value to be copied in member type_object + */ + eProsima_user_DllExport void type_object( + const std::string& _type_object); + + /*! + * @brief This function moves the value in member type_object + * @param _type_object New value to be moved in member type_object + */ + eProsima_user_DllExport void type_object( + std::string&& _type_object); + + /*! + * @brief This function returns a constant reference to member type_object + * @return Constant reference to member type_object + */ + eProsima_user_DllExport const std::string& type_object() const; + + /*! + * @brief This function returns a reference to member type_object + * @return Reference to member type_object + */ + eProsima_user_DllExport std::string& type_object(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const eprosima::ddsrecorder::participants::DynamicType& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + + private: + + std::string m_type_name; + std::string m_type_information; + std::string m_type_object; + + }; + + + + + + /*! + * @brief This class represents the structure DynamicTypesCollection defined by the user in the IDL file. + * @ingroup DynamicTypesCollection + */ + class DynamicTypesCollection + { + public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport DynamicTypesCollection(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~DynamicTypesCollection(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + */ + eProsima_user_DllExport DynamicTypesCollection( + const DynamicTypesCollection& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + */ + eProsima_user_DllExport DynamicTypesCollection( + DynamicTypesCollection&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + */ + eProsima_user_DllExport DynamicTypesCollection& operator =( + const DynamicTypesCollection& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + */ + eProsima_user_DllExport DynamicTypesCollection& operator =( + DynamicTypesCollection&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x eprosima::ddsrecorder::participants::DynamicTypesCollection object to compare. + */ + eProsima_user_DllExport bool operator ==( + const DynamicTypesCollection& x) const; + + /*! + * @brief Comparison operator. + * @param x eprosima::ddsrecorder::participants::DynamicTypesCollection object to compare. + */ + eProsima_user_DllExport bool operator !=( + const DynamicTypesCollection& x) const; + + /*! + * @brief This function copies the value in member dynamic_types + * @param _dynamic_types New value to be copied in member dynamic_types + */ + eProsima_user_DllExport void dynamic_types( + const std::vector& _dynamic_types); + + /*! + * @brief This function moves the value in member dynamic_types + * @param _dynamic_types New value to be moved in member dynamic_types + */ + eProsima_user_DllExport void dynamic_types( + std::vector&& _dynamic_types); + + /*! + * @brief This function returns a constant reference to member dynamic_types + * @return Constant reference to member dynamic_types + */ + eProsima_user_DllExport const std::vector& dynamic_types() const; + + /*! + * @brief This function returns a reference to member dynamic_types + * @return Reference to member dynamic_types + */ + eProsima_user_DllExport std::vector& dynamic_types(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const eprosima::ddsrecorder::participants::DynamicTypesCollection& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + + private: + + std::vector m_dynamic_types; + + }; + + } // namespace participants + } // namespace ddsrecorder +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.cpp b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.cpp index e5437f4aa..0ccdb83b5 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.cpp +++ b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.cpp @@ -27,15 +27,17 @@ char dummy; #endif // _WIN32 #include -#include -#include +#if FASTCDR_VERSION_MAJOR > 1 + +#include -// Include auxiliary functions like for serializing/deserializing. -#include "DynamicTypesCollectionCdrAux.ipp" +#include using namespace eprosima::fastcdr::exception; +#include + namespace eprosima { @@ -43,16 +45,17 @@ namespace ddsrecorder { namespace participants { -eprosima::ddsrecorder::participants::DynamicType::DynamicType() -{ + +DynamicType::DynamicType() +{ } -eprosima::ddsrecorder::participants::DynamicType::~DynamicType() +DynamicType::~DynamicType() { } -eprosima::ddsrecorder::participants::DynamicType::DynamicType( +DynamicType::DynamicType( const DynamicType& x) { m_type_name = x.m_type_name; @@ -60,7 +63,7 @@ eprosima::ddsrecorder::participants::DynamicType::DynamicType( m_type_object = x.m_type_object; } -eprosima::ddsrecorder::participants::DynamicType::DynamicType( +DynamicType::DynamicType( DynamicType&& x) noexcept { m_type_name = std::move(x.m_type_name); @@ -68,7 +71,7 @@ eprosima::ddsrecorder::participants::DynamicType::DynamicType( m_type_object = std::move(x.m_type_object); } -eprosima::ddsrecorder::participants::DynamicType& eprosima::ddsrecorder::participants::DynamicType::operator =( +DynamicType& DynamicType::operator =( const DynamicType& x) { @@ -78,7 +81,7 @@ eprosima::ddsrecorder::participants::DynamicType& eprosima::ddsrecorder::partici return *this; } -eprosima::ddsrecorder::participants::DynamicType& eprosima::ddsrecorder::participants::DynamicType::operator =( +DynamicType& DynamicType::operator =( DynamicType&& x) noexcept { @@ -88,7 +91,7 @@ eprosima::ddsrecorder::participants::DynamicType& eprosima::ddsrecorder::partici return *this; } -bool eprosima::ddsrecorder::participants::DynamicType::operator ==( +bool DynamicType::operator ==( const DynamicType& x) const { return (m_type_name == x.m_type_name && @@ -96,29 +99,17 @@ bool eprosima::ddsrecorder::participants::DynamicType::operator ==( m_type_object == x.m_type_object); } -bool eprosima::ddsrecorder::participants::DynamicType::operator !=( +bool DynamicType::operator !=( const DynamicType& x) const { return !(*this == x); } -void eprosima::ddsrecorder::participants::DynamicType::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void eprosima::ddsrecorder::participants::DynamicType::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - /*! * @brief This function copies the value in member type_name * @param _type_name New value to be copied in member type_name */ -void eprosima::ddsrecorder::participants::DynamicType::type_name( +void DynamicType::type_name( const std::string& _type_name) { m_type_name = _type_name; @@ -128,7 +119,7 @@ void eprosima::ddsrecorder::participants::DynamicType::type_name( * @brief This function moves the value in member type_name * @param _type_name New value to be moved in member type_name */ -void eprosima::ddsrecorder::participants::DynamicType::type_name( +void DynamicType::type_name( std::string&& _type_name) { m_type_name = std::move(_type_name); @@ -138,7 +129,7 @@ void eprosima::ddsrecorder::participants::DynamicType::type_name( * @brief This function returns a constant reference to member type_name * @return Constant reference to member type_name */ -const std::string& eprosima::ddsrecorder::participants::DynamicType::type_name() const +const std::string& DynamicType::type_name() const { return m_type_name; } @@ -147,7 +138,7 @@ const std::string& eprosima::ddsrecorder::participants::DynamicType::type_name() * @brief This function returns a reference to member type_name * @return Reference to member type_name */ -std::string& eprosima::ddsrecorder::participants::DynamicType::type_name() +std::string& DynamicType::type_name() { return m_type_name; } @@ -156,7 +147,7 @@ std::string& eprosima::ddsrecorder::participants::DynamicType::type_name() * @brief This function copies the value in member type_information * @param _type_information New value to be copied in member type_information */ -void eprosima::ddsrecorder::participants::DynamicType::type_information( +void DynamicType::type_information( const std::string& _type_information) { m_type_information = _type_information; @@ -166,7 +157,7 @@ void eprosima::ddsrecorder::participants::DynamicType::type_information( * @brief This function moves the value in member type_information * @param _type_information New value to be moved in member type_information */ -void eprosima::ddsrecorder::participants::DynamicType::type_information( +void DynamicType::type_information( std::string&& _type_information) { m_type_information = std::move(_type_information); @@ -176,7 +167,7 @@ void eprosima::ddsrecorder::participants::DynamicType::type_information( * @brief This function returns a constant reference to member type_information * @return Constant reference to member type_information */ -const std::string& eprosima::ddsrecorder::participants::DynamicType::type_information() const +const std::string& DynamicType::type_information() const { return m_type_information; } @@ -185,7 +176,7 @@ const std::string& eprosima::ddsrecorder::participants::DynamicType::type_inform * @brief This function returns a reference to member type_information * @return Reference to member type_information */ -std::string& eprosima::ddsrecorder::participants::DynamicType::type_information() +std::string& DynamicType::type_information() { return m_type_information; } @@ -194,7 +185,7 @@ std::string& eprosima::ddsrecorder::participants::DynamicType::type_information( * @brief This function copies the value in member type_object * @param _type_object New value to be copied in member type_object */ -void eprosima::ddsrecorder::participants::DynamicType::type_object( +void DynamicType::type_object( const std::string& _type_object) { m_type_object = _type_object; @@ -204,7 +195,7 @@ void eprosima::ddsrecorder::participants::DynamicType::type_object( * @brief This function moves the value in member type_object * @param _type_object New value to be moved in member type_object */ -void eprosima::ddsrecorder::participants::DynamicType::type_object( +void DynamicType::type_object( std::string&& _type_object) { m_type_object = std::move(_type_object); @@ -214,7 +205,7 @@ void eprosima::ddsrecorder::participants::DynamicType::type_object( * @brief This function returns a constant reference to member type_object * @return Constant reference to member type_object */ -const std::string& eprosima::ddsrecorder::participants::DynamicType::type_object() const +const std::string& DynamicType::type_object() const { return m_type_object; } @@ -223,34 +214,32 @@ const std::string& eprosima::ddsrecorder::participants::DynamicType::type_object * @brief This function returns a reference to member type_object * @return Reference to member type_object */ -std::string& eprosima::ddsrecorder::participants::DynamicType::type_object() +std::string& DynamicType::type_object() { return m_type_object; } -eprosima::ddsrecorder::participants::DynamicTypesCollection::DynamicTypesCollection() +DynamicTypesCollection::DynamicTypesCollection() { - } -eprosima::ddsrecorder::participants::DynamicTypesCollection::~DynamicTypesCollection() +DynamicTypesCollection::~DynamicTypesCollection() { } -eprosima::ddsrecorder::participants::DynamicTypesCollection::DynamicTypesCollection( +DynamicTypesCollection::DynamicTypesCollection( const DynamicTypesCollection& x) { m_dynamic_types = x.m_dynamic_types; } -eprosima::ddsrecorder::participants::DynamicTypesCollection::DynamicTypesCollection( +DynamicTypesCollection::DynamicTypesCollection( DynamicTypesCollection&& x) noexcept { m_dynamic_types = std::move(x.m_dynamic_types); } -eprosima::ddsrecorder::participants::DynamicTypesCollection& eprosima::ddsrecorder::participants::DynamicTypesCollection - ::operator =( +DynamicTypesCollection& DynamicTypesCollection::operator =( const DynamicTypesCollection& x) { @@ -258,8 +247,7 @@ eprosima::ddsrecorder::participants::DynamicTypesCollection& eprosima::ddsrecord return *this; } -eprosima::ddsrecorder::participants::DynamicTypesCollection& eprosima::ddsrecorder::participants::DynamicTypesCollection - ::operator =( +DynamicTypesCollection& DynamicTypesCollection::operator =( DynamicTypesCollection&& x) noexcept { @@ -267,35 +255,23 @@ eprosima::ddsrecorder::participants::DynamicTypesCollection& eprosima::ddsrecord return *this; } -bool eprosima::ddsrecorder::participants::DynamicTypesCollection::operator ==( +bool DynamicTypesCollection::operator ==( const DynamicTypesCollection& x) const { return (m_dynamic_types == x.m_dynamic_types); } -bool eprosima::ddsrecorder::participants::DynamicTypesCollection::operator !=( +bool DynamicTypesCollection::operator !=( const DynamicTypesCollection& x) const { return !(*this == x); } -void eprosima::ddsrecorder::participants::DynamicTypesCollection::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void eprosima::ddsrecorder::participants::DynamicTypesCollection::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - /*! * @brief This function copies the value in member dynamic_types * @param _dynamic_types New value to be copied in member dynamic_types */ -void eprosima::ddsrecorder::participants::DynamicTypesCollection::dynamic_types( +void DynamicTypesCollection::dynamic_types( const std::vector& _dynamic_types) { m_dynamic_types = _dynamic_types; @@ -305,7 +281,7 @@ void eprosima::ddsrecorder::participants::DynamicTypesCollection::dynamic_types( * @brief This function moves the value in member dynamic_types * @param _dynamic_types New value to be moved in member dynamic_types */ -void eprosima::ddsrecorder::participants::DynamicTypesCollection::dynamic_types( +void DynamicTypesCollection::dynamic_types( std::vector&& _dynamic_types) { m_dynamic_types = std::move(_dynamic_types); @@ -315,8 +291,7 @@ void eprosima::ddsrecorder::participants::DynamicTypesCollection::dynamic_types( * @brief This function returns a constant reference to member dynamic_types * @return Constant reference to member dynamic_types */ -const std::vector& eprosima::ddsrecorder::participants:: - DynamicTypesCollection::dynamic_types() const +const std::vector& DynamicTypesCollection::dynamic_types() const { return m_dynamic_types; } @@ -325,8 +300,7 @@ const std::vector& eprosima::d * @brief This function returns a reference to member dynamic_types * @return Reference to member dynamic_types */ -std::vector& eprosima::ddsrecorder::participants:: - DynamicTypesCollection::dynamic_types() +std::vector& DynamicTypesCollection::dynamic_types() { return m_dynamic_types; } @@ -338,3 +312,7 @@ std::vector& eprosima::ddsreco } // namespace eprosima +// Include auxiliary functions like for serializing/deserializing. +#include "DynamicTypesCollectionCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.hpp b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.hpp index 4236f6c29..94e976e6a 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.hpp +++ b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.hpp @@ -37,10 +37,16 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const eprosima::ddsrecorder::participants::DynamicType& data); + + + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const eprosima::ddsrecorder::participants::DynamicTypesCollection& data); diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.ipp b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.ipp index b4596c4c6..c5aa7abc1 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.ipp +++ b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.ipp @@ -25,10 +25,7 @@ #include "DynamicTypesCollectionCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -47,27 +46,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_name().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_information().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_object().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -89,8 +67,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -100,38 +76,18 @@ eProsima_user_DllExport void serialize( { using namespace eprosima::ddsrecorder::participants; -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.type_name() - ; - - scdr << data.type_information() - ; - - - scdr << data.type_object() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.type_name() << eprosima::fastcdr::MemberId(1) << data.type_information() << eprosima::fastcdr::MemberId(2) << data.type_object() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -141,12 +97,6 @@ eProsima_user_DllExport void deserialize( { using namespace eprosima::ddsrecorder::participants; -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.type_name(); - cdr >> data.type_information(); - cdr >> data.type_object(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -173,7 +123,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( @@ -187,6 +136,10 @@ void serialize_key( } + + + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -197,28 +150,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.dynamic_types().size(); ++a) - { - current_alignment += calculate_serialized_size(calculator, data.dynamic_types().at(a), current_alignment); - } - - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -234,8 +165,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -245,28 +174,16 @@ eProsima_user_DllExport void serialize( { using namespace eprosima::ddsrecorder::participants; -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.dynamic_types() - ; - -#else scdr << eprosima::fastcdr::MemberId(0) << data.dynamic_types() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -276,10 +193,6 @@ eProsima_user_DllExport void deserialize( { using namespace eprosima::ddsrecorder::participants; -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.dynamic_types(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -298,7 +211,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionPubSubTypes.cpp b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionPubSubTypes.cpp index c9b15f030..c56adf3c7 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionPubSubTypes.cpp +++ b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionPubSubTypes.cpp @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include @@ -31,10 +32,17 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace eprosima { namespace ddsrecorder { namespace participants { + + DynamicTypePubSubType::DynamicTypePubSubType() { setName("eprosima::ddsrecorder::participants::DynamicType"); - uint32_t type_size = eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize; + uint32_t type_size = + #if FASTCDR_VERSION_MAJOR == 1 + DynamicType::getMaxCdrSerializedSize(); + #else + eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize; + #endif // if FASTCDR_VERSION_MAJOR == 1 type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -134,13 +142,25 @@ std::function DynamicTypePubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + #if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; + #else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } + #endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -174,7 +194,11 @@ bool DynamicTypePubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + #if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); + #else eprosima::fastcdr::serialize_key(ser, *p_type); + #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize > 16) { m_md5.init(); @@ -202,7 +226,12 @@ bool DynamicTypePubSubType::getKey( DynamicTypesCollectionPubSubType::DynamicTypesCollectionPubSubType() { setName("eprosima::ddsrecorder::participants::DynamicTypesCollection"); - uint32_t type_size = eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize; + uint32_t type_size = + #if FASTCDR_VERSION_MAJOR == 1 + DynamicTypesCollection::getMaxCdrSerializedSize(); + #else + eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize; + #endif // if FASTCDR_VERSION_MAJOR == 1 type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -302,13 +331,25 @@ std::function DynamicTypesCollectionPubSubType::getSerializedSizePro { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + #if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; + #else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } + #endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -342,7 +383,11 @@ bool DynamicTypesCollectionPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + #if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); + #else eprosima::fastcdr::serialize_key(ser, *p_type); + #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionv1.cpp b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionv1.cpp new file mode 100644 index 000000000..6f8559a41 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionv1.cpp @@ -0,0 +1,523 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file DynamicTypesCollection.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { +namespace internal { + +enum class Size +{ + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size( + int s) +{ + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH +{ + using type = std::uint8_t; +}; + +template<> +struct FindTypeH +{ + using type = std::uint16_t; +}; + +template<> +struct FindTypeH +{ + using type = std::uint32_t; +}; + +template<> +struct FindTypeH +{ + using type = std::uint64_t; +}; +} // namespace internal + +template +struct FindType +{ + using type = typename internal::FindTypeH::type; +}; +} // namespace helper + +#define eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize 78412ULL; +#define eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize 784ULL; + + +namespace eprosima { + +namespace ddsrecorder { + +namespace participants { + + + +DynamicType::DynamicType() +{ + // /type_d() m_type_name + + // /type_d() m_type_information + + // /type_d() m_type_object + + +} + +DynamicType::~DynamicType() +{ +} + +DynamicType::DynamicType( + const DynamicType& x) +{ + m_type_name = x.m_type_name; + + + m_type_information = x.m_type_information; + + + m_type_object = x.m_type_object; + +} + +DynamicType::DynamicType( + DynamicType&& x) noexcept +{ + m_type_name = std::move(x.m_type_name); + + + m_type_information = std::move(x.m_type_information); + + + m_type_object = std::move(x.m_type_object); + +} + +DynamicType& DynamicType::operator =( + const DynamicType& x) +{ + m_type_name = x.m_type_name; + + + m_type_information = x.m_type_information; + + + m_type_object = x.m_type_object; + + return *this; +} + +DynamicType& DynamicType::operator =( + DynamicType&& x) noexcept +{ + m_type_name = std::move(x.m_type_name); + + + m_type_information = std::move(x.m_type_information); + + + m_type_object = std::move(x.m_type_object); + + return *this; +} + +bool DynamicType::operator ==( + const DynamicType& x) const +{ + return (m_type_name == x.m_type_name && + m_type_information == x.m_type_information && + m_type_object == x.m_type_object); +} + +bool DynamicType::operator !=( + const DynamicType& x) const +{ + return !(*this == x); +} + +size_t DynamicType::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize; +} + +size_t DynamicType::getCdrSerializedSize( + const DynamicType& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_name().size() + 1; + + + current_alignment += 4 + + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_information().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_object().size() + 1; + + + return current_alignment - initial_alignment; +} + +void DynamicType::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_type_name.c_str(); + + scdr << m_type_information.c_str(); + + scdr << m_type_object.c_str(); + +} + +void DynamicType::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_type_name; + + + + dcdr >> m_type_information; + + + + dcdr >> m_type_object; + + +} + +bool DynamicType::isKeyDefined() +{ + return false; +} + +void DynamicType::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member type_name + * @param _type_name New value to be copied in member type_name + */ +void DynamicType::type_name( + const std::string& _type_name) +{ + m_type_name = _type_name; +} + +/*! + * @brief This function moves the value in member type_name + * @param _type_name New value to be moved in member type_name + */ +void DynamicType::type_name( + std::string&& _type_name) +{ + m_type_name = std::move(_type_name); +} + +/*! + * @brief This function returns a constant reference to member type_name + * @return Constant reference to member type_name + */ +const std::string& DynamicType::type_name() const +{ + return m_type_name; +} + +/*! + * @brief This function returns a reference to member type_name + * @return Reference to member type_name + */ +std::string& DynamicType::type_name() +{ + return m_type_name; +} + +/*! + * @brief This function copies the value in member type_information + * @param _type_information New value to be copied in member type_information + */ +void DynamicType::type_information( + const std::string& _type_information) +{ + m_type_information = _type_information; +} + +/*! + * @brief This function moves the value in member type_information + * @param _type_information New value to be moved in member type_information + */ +void DynamicType::type_information( + std::string&& _type_information) +{ + m_type_information = std::move(_type_information); +} + +/*! + * @brief This function returns a constant reference to member type_information + * @return Constant reference to member type_information + */ +const std::string& DynamicType::type_information() const +{ + return m_type_information; +} + +/*! + * @brief This function returns a reference to member type_information + * @return Reference to member type_information + */ +std::string& DynamicType::type_information() +{ + return m_type_information; +} + +/*! + * @brief This function copies the value in member type_object + * @param _type_object New value to be copied in member type_object + */ +void DynamicType::type_object( + const std::string& _type_object) +{ + m_type_object = _type_object; +} + +/*! + * @brief This function moves the value in member type_object + * @param _type_object New value to be moved in member type_object + */ +void DynamicType::type_object( + std::string&& _type_object) +{ + m_type_object = std::move(_type_object); +} + +/*! + * @brief This function returns a constant reference to member type_object + * @return Constant reference to member type_object + */ +const std::string& DynamicType::type_object() const +{ + return m_type_object; +} + +/*! + * @brief This function returns a reference to member type_object + * @return Reference to member type_object + */ +std::string& DynamicType::type_object() +{ + return m_type_object; +} + +DynamicTypesCollection::DynamicTypesCollection() +{ + // sequence m_dynamic_types + + +} + +DynamicTypesCollection::~DynamicTypesCollection() +{ +} + +DynamicTypesCollection::DynamicTypesCollection( + const DynamicTypesCollection& x) +{ + m_dynamic_types = x.m_dynamic_types; + +} + +DynamicTypesCollection::DynamicTypesCollection( + DynamicTypesCollection&& x) noexcept +{ + m_dynamic_types = std::move(x.m_dynamic_types); + +} + +DynamicTypesCollection& DynamicTypesCollection::operator =( + const DynamicTypesCollection& x) +{ + m_dynamic_types = x.m_dynamic_types; + + return *this; +} + +DynamicTypesCollection& DynamicTypesCollection::operator =( + DynamicTypesCollection&& x) noexcept +{ + m_dynamic_types = std::move(x.m_dynamic_types); + + return *this; +} + +bool DynamicTypesCollection::operator ==( + const DynamicTypesCollection& x) const +{ + return (m_dynamic_types == x.m_dynamic_types); +} + +bool DynamicTypesCollection::operator !=( + const DynamicTypesCollection& x) const +{ + return !(*this == x); +} + +size_t DynamicTypesCollection::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize; +} + +size_t DynamicTypesCollection::getCdrSerializedSize( + const DynamicTypesCollection& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for (size_t a = 0; a < data.dynamic_types().size(); ++a) + { + current_alignment += eprosima::ddsrecorder::participants::DynamicType::getCdrSerializedSize( + data.dynamic_types().at(a), current_alignment); + } + + + + return current_alignment - initial_alignment; +} + +void DynamicTypesCollection::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_dynamic_types; + + +} + +void DynamicTypesCollection::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_dynamic_types; + + +} + +bool DynamicTypesCollection::isKeyDefined() +{ + return false; +} + +void DynamicTypesCollection::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member dynamic_types + * @param _dynamic_types New value to be copied in member dynamic_types + */ +void DynamicTypesCollection::dynamic_types( + const std::vector& _dynamic_types) +{ + m_dynamic_types = _dynamic_types; +} + +/*! + * @brief This function moves the value in member dynamic_types + * @param _dynamic_types New value to be moved in member dynamic_types + */ +void DynamicTypesCollection::dynamic_types( + std::vector&& _dynamic_types) +{ + m_dynamic_types = std::move(_dynamic_types); +} + +/*! + * @brief This function returns a constant reference to member dynamic_types + * @return Constant reference to member dynamic_types + */ +const std::vector& DynamicTypesCollection::dynamic_types() const +{ + return m_dynamic_types; +} + +/*! + * @brief This function returns a reference to member dynamic_types + * @return Reference to member dynamic_types + */ +std::vector& DynamicTypesCollection::dynamic_types() +{ + return m_dynamic_types; +} + +} // namespace participants + + +} // namespace ddsrecorder + + +} // namespace eprosima + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt index 2434c03ea..d741acce7 100644 --- a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt @@ -21,6 +21,7 @@ set(TEST_NAME McapFileReadTest) set(TEST_SOURCES McapFileReadTest.cpp ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorld.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp ) diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.cxx index ad8c21796..4b415d677 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.cxx +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.cxx @@ -27,19 +27,22 @@ char dummy; #endif // _WIN32 #include "HelloWorld.h" -#include -#include +#if FASTCDR_VERSION_MAJOR > 1 -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" +#include + +#include using namespace eprosima::fastcdr::exception; +#include + + + HelloWorld::HelloWorld() { - } HelloWorld::~HelloWorld() @@ -91,19 +94,6 @@ bool HelloWorld::operator !=( return !(*this == x); } -void HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function sets a value in member index * @param _index New value for member index @@ -171,3 +161,8 @@ std::string& HelloWorld::message() return m_message; } + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.h index 69057d262..5cd0ddba5 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "HelloWorldv1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ #define _FAST_DDS_GENERATED_HELLOWORLD_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -178,23 +181,6 @@ class HelloWorld */ eProsima_user_DllExport std::string& message(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: uint32_t m_index{0}; @@ -204,3 +190,6 @@ class HelloWorld #endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp index 713dba562..9f346d306 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp index 55034e024..42e91f3cc 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp @@ -25,10 +25,7 @@ #include "HelloWorldCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,24 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -81,8 +62,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -90,33 +69,17 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.index() - ; - - scdr << data.message() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.index() << eprosima::fastcdr::MemberId(1) << data.message() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -124,11 +87,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, HelloWorld& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.index(); - cdr >> data.message(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -151,7 +109,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx index 7efd377ec..eae5d4a75 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "HelloWorldPubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); - uint32_t type_size = HelloWorld_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + HelloWorld::getMaxCdrSerializedSize(); +#else + HelloWorld_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool HelloWorldPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h index f6c88d5c1..cb61cd6ba 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx new file mode 100644 index 000000000..90e82ea88 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx @@ -0,0 +1,286 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "HelloWorld.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define HelloWorld_max_cdr_typesize 268ULL; + + + + +HelloWorld::HelloWorld() +{ + // unsigned long m_index + m_index = 0; + // /type_d() m_message + + +} + +HelloWorld::~HelloWorld() +{ +} + +HelloWorld::HelloWorld( + const HelloWorld& x) +{ + m_index = x.m_index; + + + m_message = x.m_message; + +} + +HelloWorld::HelloWorld( + HelloWorld&& x) noexcept +{ + m_index = x.m_index; + + + m_message = std::move(x.m_message); + +} + +HelloWorld& HelloWorld::operator =( + const HelloWorld& x) +{ + m_index = x.m_index; + + + m_message = x.m_message; + + return *this; +} + +HelloWorld& HelloWorld::operator =( + HelloWorld&& x) noexcept +{ + m_index = x.m_index; + + + m_message = std::move(x.m_message); + + return *this; +} + +bool HelloWorld::operator ==( + const HelloWorld& x) const +{ + return (m_index == x.m_index && + m_message == x.m_message); +} + +bool HelloWorld::operator !=( + const HelloWorld& x) const +{ + return !(*this == x); +} + +size_t HelloWorld::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return HelloWorld_max_cdr_typesize; +} + +size_t HelloWorld::getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void HelloWorld::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_index; + + scdr << m_message.c_str(); + +} + +void HelloWorld::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_index; + + + + dcdr >> m_message; + + +} + + +bool HelloWorld::isKeyDefined() +{ + return false; +} + +void HelloWorld::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void HelloWorld::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t HelloWorld::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& HelloWorld::index() +{ + return m_index; +} + + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void HelloWorld::message( + const std::string& _message) +{ + m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void HelloWorld::message( + std::string&& _message) +{ + m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::string& HelloWorld::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::string& HelloWorld::message() +{ + return m_message; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.h new file mode 100644 index 000000000..7758cd793 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.h @@ -0,0 +1,243 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(HELLOWORLD_SOURCE) +#define HELLOWORLD_DllAPI __declspec( dllexport ) +#else +#define HELLOWORLD_DllAPI __declspec( dllimport ) +#endif // HELLOWORLD_SOURCE +#else +#define HELLOWORLD_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define HELLOWORLD_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorld +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport HelloWorld(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~HelloWorld(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + const HelloWorld& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + HelloWorld&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + const HelloWorld& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + HelloWorld&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator ==( + const HelloWorld& x) const; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator !=( + const HelloWorld& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message( + const std::string& _message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message( + std::string&& _message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + uint32_t m_index; + std::string m_message; + +}; + + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/resources/dds/TypeLookupService/types/complete/Complete.cxx b/resources/dds/TypeLookupService/types/complete/Complete.cxx index 893a4e0c4..6c5ec8bce 100644 --- a/resources/dds/TypeLookupService/types/complete/Complete.cxx +++ b/resources/dds/TypeLookupService/types/complete/Complete.cxx @@ -27,21 +27,24 @@ char dummy; #endif // _WIN32 #include "Complete.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #include "CompleteTypeObject.h" -#include +#include + + +#include +using namespace eprosima::fastcdr::exception; #include -// Include auxiliary functions like for serializing/deserializing. -#include "CompleteCdrAux.ipp" -using namespace eprosima::fastcdr::exception; Timestamp::Timestamp() { - // Just to register all known types registerCompleteTypes(); } @@ -95,19 +98,6 @@ bool Timestamp::operator !=( return !(*this == x); } -void Timestamp::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void Timestamp::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function sets a value in member seconds * @param _seconds New value for member seconds @@ -166,9 +156,10 @@ int32_t& Timestamp::milliseconds() } + + Point::Point() { - // Just to register all known types registerCompleteTypes(); } @@ -227,19 +218,6 @@ bool Point::operator !=( return !(*this == x); } -void Point::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void Point::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function sets a value in member x * @param _x New value for member x @@ -327,9 +305,10 @@ int32_t& Point::z() } + + MessageDescriptor::MessageDescriptor() { - // Just to register all known types registerCompleteTypes(); } @@ -388,19 +367,6 @@ bool MessageDescriptor::operator !=( return !(*this == x); } -void MessageDescriptor::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void MessageDescriptor::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function sets a value in member id * @param _id New value for member id @@ -508,9 +474,10 @@ Timestamp& MessageDescriptor::time() } + + Message::Message() { - // Just to register all known types registerCompleteTypes(); } @@ -564,19 +531,6 @@ bool Message::operator !=( return !(*this == x); } -void Message::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void Message::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function copies the value in member descriptor * @param _descriptor New value to be copied in member descriptor @@ -655,9 +609,10 @@ std::string& Message::message() } + + CompleteData::CompleteData() { - // Just to register all known types registerCompleteTypes(); } @@ -721,19 +676,6 @@ bool CompleteData::operator !=( return !(*this == x); } -void CompleteData::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void CompleteData::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function sets a value in member index * @param _index New value for member index @@ -879,3 +821,8 @@ std::array& CompleteData::messages() return m_messages; } + +// Include auxiliary functions like for serializing/deserializing. +#include "CompleteCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/complete/Complete.h b/resources/dds/TypeLookupService/types/complete/Complete.h index 46a36f244..066c14641 100644 --- a/resources/dds/TypeLookupService/types/complete/Complete.h +++ b/resources/dds/TypeLookupService/types/complete/Complete.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "Completev1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_COMPLETE_H_ #define _FAST_DDS_GENERATED_COMPLETE_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure Timestamp defined by the user in the IDL file. * @ingroup Complete @@ -171,29 +174,14 @@ class Timestamp */ eProsima_user_DllExport int32_t& milliseconds(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: int32_t m_seconds{0}; int32_t m_milliseconds{0}; }; + + /*! * @brief This class represents the structure Point defined by the user in the IDL file. * @ingroup Complete @@ -313,23 +301,6 @@ class Point */ eProsima_user_DllExport int32_t& z(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: int32_t m_x{0}; @@ -337,6 +308,8 @@ class Point int32_t m_z{0}; }; + + /*! * @brief This class represents the structure MessageDescriptor defined by the user in the IDL file. * @ingroup Complete @@ -470,23 +443,6 @@ class MessageDescriptor */ eProsima_user_DllExport Timestamp& time(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: uint32_t m_id{0}; @@ -494,6 +450,8 @@ class MessageDescriptor Timestamp m_time; }; + + /*! * @brief This class represents the structure Message defined by the user in the IDL file. * @ingroup Complete @@ -607,29 +565,14 @@ class Message */ eProsima_user_DllExport std::string& message(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: MessageDescriptor m_descriptor; std::string m_message; }; + + /*! * @brief This class represents the structure CompleteData defined by the user in the IDL file. * @ingroup Complete @@ -790,23 +733,6 @@ class CompleteData */ eProsima_user_DllExport std::array& messages(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: uint32_t m_index{0}; @@ -818,3 +744,6 @@ class CompleteData #endif // _FAST_DDS_GENERATED_COMPLETE_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp index 74df1cafe..0c2aedb11 100644 --- a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp +++ b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp @@ -46,22 +46,32 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const Timestamp& data); + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const Point& data); + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const MessageDescriptor& data); + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const Message& data); + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const CompleteData& data); diff --git a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp index f15f53608..ade74eaac 100644 --- a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp +++ b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp @@ -25,10 +25,7 @@ #include "CompleteCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,24 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -81,8 +62,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -90,33 +69,17 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const Timestamp& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.seconds() - ; - - scdr << data.milliseconds() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.seconds() << eprosima::fastcdr::MemberId(1) << data.milliseconds() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -124,11 +87,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, Timestamp& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.seconds(); - cdr >> data.milliseconds(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -151,7 +109,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( @@ -163,6 +120,8 @@ void serialize_key( } + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -171,27 +130,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -213,8 +151,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -222,38 +158,18 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const Point& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.x() - ; - - - scdr << data.y() - ; - - scdr << data.z() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.x() << eprosima::fastcdr::MemberId(1) << data.y() << eprosima::fastcdr::MemberId(2) << data.z() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -261,12 +177,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, Point& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.x(); - cdr >> data.y(); - cdr >> data.z(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -293,7 +203,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( @@ -305,6 +214,8 @@ void serialize_key( } + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -313,27 +224,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.topic().size() + 1; - - - current_alignment += calculate_serialized_size(calculator, data.time(), current_alignment); - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -355,8 +245,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -364,38 +252,18 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const MessageDescriptor& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.id() - ; - - scdr << data.topic() - ; - - - scdr << data.time() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.id() << eprosima::fastcdr::MemberId(1) << data.topic() << eprosima::fastcdr::MemberId(2) << data.time() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -403,12 +271,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, MessageDescriptor& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.id(); - cdr >> data.topic(); - cdr >> data.time(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -435,7 +297,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( @@ -447,6 +308,8 @@ void serialize_key( } + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -455,24 +318,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += calculate_serialized_size(calculator, data.descriptor(), current_alignment); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -491,8 +336,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -500,33 +343,17 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const Message& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.descriptor() - ; - - - scdr << data.message() - ; - -#else scdr << eprosima::fastcdr::MemberId(0) << data.descriptor() << eprosima::fastcdr::MemberId(1) << data.message() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -534,11 +361,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, Message& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.descriptor(); - cdr >> data.message(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -561,7 +383,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( @@ -573,6 +394,8 @@ void serialize_key( } + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -581,43 +404,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += calculate_serialized_size(calculator, data.main_point(), current_alignment); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for(size_t a = 0; a < data.internal_data().size(); ++a) - { - current_alignment += calculate_serialized_size(calculator, data.internal_data().at(a), current_alignment); - } - - - - - for(size_t a = 0; a < data.messages().size(); ++a) - { - current_alignment += calculate_serialized_size(calculator, data.messages().at(a), current_alignment); - - } - - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -642,8 +428,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -651,43 +435,19 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const CompleteData& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.index() - ; - - - scdr << data.main_point() - ; - - scdr << data.internal_data() - ; - - - scdr << data.messages() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.index() << eprosima::fastcdr::MemberId(1) << data.main_point() << eprosima::fastcdr::MemberId(2) << data.internal_data() << eprosima::fastcdr::MemberId(3) << data.messages() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -695,13 +455,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, CompleteData& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.index(); - cdr >> data.main_point(); - cdr >> data.internal_data(); - cdr >> data.messages(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -732,7 +485,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx index efa01f93d..19f0dea05 100644 --- a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "CompletePubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + TimestampPubSubType::TimestampPubSubType() { setName("Timestamp"); - uint32_t type_size = Timestamp_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + Timestamp::getMaxCdrSerializedSize(); +#else + Timestamp_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function TimestampPubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool TimestampPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Timestamp_max_key_cdr_typesize > 16) { m_md5.init(); @@ -194,10 +218,17 @@ bool TimestampPubSubType::getKey( return true; } + + PointPubSubType::PointPubSubType() { setName("Point"); - uint32_t type_size = Point_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + Point::getMaxCdrSerializedSize(); +#else + Point_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -296,13 +327,25 @@ std::function PointPubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -335,7 +378,11 @@ bool PointPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Point_max_key_cdr_typesize > 16) { m_md5.init(); @@ -360,10 +407,17 @@ bool PointPubSubType::getKey( return true; } + + MessageDescriptorPubSubType::MessageDescriptorPubSubType() { setName("MessageDescriptor"); - uint32_t type_size = MessageDescriptor_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + MessageDescriptor::getMaxCdrSerializedSize(); +#else + MessageDescriptor_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -462,13 +516,25 @@ std::function MessageDescriptorPubSubType::getSerializedSizeProvider { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -501,7 +567,11 @@ bool MessageDescriptorPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || MessageDescriptor_max_key_cdr_typesize > 16) { m_md5.init(); @@ -526,10 +596,17 @@ bool MessageDescriptorPubSubType::getKey( return true; } + + MessagePubSubType::MessagePubSubType() { setName("Message"); - uint32_t type_size = Message_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + Message::getMaxCdrSerializedSize(); +#else + Message_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -628,13 +705,25 @@ std::function MessagePubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -667,7 +756,11 @@ bool MessagePubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || Message_max_key_cdr_typesize > 16) { m_md5.init(); @@ -692,10 +785,17 @@ bool MessagePubSubType::getKey( return true; } + + CompleteDataPubSubType::CompleteDataPubSubType() { setName("CompleteData"); - uint32_t type_size = CompleteData_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + CompleteData::getMaxCdrSerializedSize(); +#else + CompleteData_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -794,13 +894,25 @@ std::function CompleteDataPubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -833,7 +945,11 @@ bool CompleteDataPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || CompleteData_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h index 7cc680b9d..0dc43bf1d 100644 --- a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type Timestamp defined by the user in the IDL file. * @ingroup Complete @@ -126,6 +128,8 @@ class TimestampPubSubType : public eprosima::fastdds::dds::TopicDataType }; + + /*! * @brief This class represents the TopicDataType of the type Point defined by the user in the IDL file. * @ingroup Complete @@ -214,6 +218,8 @@ class PointPubSubType : public eprosima::fastdds::dds::TopicDataType }; + + /*! * @brief This class represents the TopicDataType of the type MessageDescriptor defined by the user in the IDL file. * @ingroup Complete @@ -302,6 +308,8 @@ class MessageDescriptorPubSubType : public eprosima::fastdds::dds::TopicDataType }; + + /*! * @brief This class represents the TopicDataType of the type Message defined by the user in the IDL file. * @ingroup Complete @@ -390,6 +398,8 @@ class MessagePubSubType : public eprosima::fastdds::dds::TopicDataType }; + + /*! * @brief This class represents the TopicDataType of the type CompleteData defined by the user in the IDL file. * @ingroup Complete diff --git a/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.cxx b/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.cxx index 4b6a3607f..e64f75806 100644 --- a/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.cxx +++ b/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.cxx @@ -76,6 +76,8 @@ void registerCompleteTypes() }); } + + const TypeIdentifier* GetTimestampIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Timestamp", complete); @@ -165,7 +167,6 @@ const TypeObject* GetMinimalTimestampObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -254,7 +255,6 @@ const TypeObject* GetCompleteTimestampObject() // Header type_object->complete().struct_type().header().detail().type_name("Timestamp"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); @@ -288,6 +288,8 @@ const TypeObject* GetCompleteTimestampObject() return TypeObjectFactory::get_instance()->get_type_object("Timestamp", true); } + + const TypeIdentifier* GetPointIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Point", complete); @@ -396,7 +398,6 @@ const TypeObject* GetMinimalPointObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -501,7 +502,6 @@ const TypeObject* GetCompletePointObject() // Header type_object->complete().struct_type().header().detail().type_name("Point"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); @@ -535,6 +535,8 @@ const TypeObject* GetCompletePointObject() return TypeObjectFactory::get_instance()->get_type_object("Point", true); } + + const TypeIdentifier* GetMessageDescriptorIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MessageDescriptor", complete); @@ -641,7 +643,6 @@ const TypeObject* GetMinimalMessageDescriptorObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -744,7 +745,6 @@ const TypeObject* GetCompleteMessageDescriptorObject() // Header type_object->complete().struct_type().header().detail().type_name("MessageDescriptor"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); @@ -778,6 +778,8 @@ const TypeObject* GetCompleteMessageDescriptorObject() return TypeObjectFactory::get_instance()->get_type_object("MessageDescriptor", true); } + + const TypeIdentifier* GetMessageIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Message", complete); @@ -865,7 +867,6 @@ const TypeObject* GetMinimalMessageObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -952,7 +953,6 @@ const TypeObject* GetCompleteMessageObject() // Header type_object->complete().struct_type().header().detail().type_name("Message"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); @@ -986,6 +986,8 @@ const TypeObject* GetCompleteMessageObject() return TypeObjectFactory::get_instance()->get_type_object("Message", true); } + + const TypeIdentifier* GetCompleteDataIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("CompleteData", complete); @@ -1110,7 +1112,6 @@ const TypeObject* GetMinimalCompleteDataObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -1228,7 +1229,6 @@ const TypeObject* GetCompleteCompleteDataObject() // Header type_object->complete().struct_type().header().detail().type_name("CompleteData"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); diff --git a/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.h b/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.h index cf847b4de..d6c58379e 100644 --- a/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.h +++ b/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.h @@ -54,26 +54,36 @@ using namespace eprosima::fastrtps::types; eProsima_user_DllExport void registerCompleteTypes(); + + eProsima_user_DllExport const TypeIdentifier* GetTimestampIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetTimestampObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalTimestampObject(); eProsima_user_DllExport const TypeObject* GetCompleteTimestampObject(); + + eProsima_user_DllExport const TypeIdentifier* GetPointIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetPointObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalPointObject(); eProsima_user_DllExport const TypeObject* GetCompletePointObject(); + + eProsima_user_DllExport const TypeIdentifier* GetMessageDescriptorIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetMessageDescriptorObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalMessageDescriptorObject(); eProsima_user_DllExport const TypeObject* GetCompleteMessageDescriptorObject(); + + eProsima_user_DllExport const TypeIdentifier* GetMessageIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetMessageObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalMessageObject(); eProsima_user_DllExport const TypeObject* GetCompleteMessageObject(); + + eProsima_user_DllExport const TypeIdentifier* GetCompleteDataIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetCompleteDataObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalCompleteDataObject(); diff --git a/resources/dds/TypeLookupService/types/complete/Completev1.cxx b/resources/dds/TypeLookupService/types/complete/Completev1.cxx new file mode 100644 index 000000000..2feae3c9f --- /dev/null +++ b/resources/dds/TypeLookupService/types/complete/Completev1.cxx @@ -0,0 +1,1333 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file Complete.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "Complete.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include "CompleteTypeObject.h" + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define MessageDescriptor_max_cdr_typesize 280ULL; +#define CompleteData_max_cdr_typesize 2724ULL; +#define Message_max_cdr_typesize 544ULL; +#define Point_max_cdr_typesize 16ULL; +#define Timestamp_max_cdr_typesize 12ULL; + + + + +Timestamp::Timestamp() +{ + // long m_seconds + m_seconds = 0; + // long m_milliseconds + m_milliseconds = 0; + + // Just to register all known types + registerCompleteTypes(); +} + +Timestamp::~Timestamp() +{ +} + +Timestamp::Timestamp( + const Timestamp& x) +{ + m_seconds = x.m_seconds; + + + m_milliseconds = x.m_milliseconds; + +} + +Timestamp::Timestamp( + Timestamp&& x) noexcept +{ + m_seconds = x.m_seconds; + + + m_milliseconds = x.m_milliseconds; + +} + +Timestamp& Timestamp::operator =( + const Timestamp& x) +{ + m_seconds = x.m_seconds; + + + m_milliseconds = x.m_milliseconds; + + return *this; +} + +Timestamp& Timestamp::operator =( + Timestamp&& x) noexcept +{ + m_seconds = x.m_seconds; + + + m_milliseconds = x.m_milliseconds; + + return *this; +} + +bool Timestamp::operator ==( + const Timestamp& x) const +{ + return (m_seconds == x.m_seconds && + m_milliseconds == x.m_milliseconds); +} + +bool Timestamp::operator !=( + const Timestamp& x) const +{ + return !(*this == x); +} + +size_t Timestamp::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return Timestamp_max_cdr_typesize; +} + +size_t Timestamp::getCdrSerializedSize( + const Timestamp& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + return current_alignment - initial_alignment; +} + + +void Timestamp::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_seconds; + + scdr << m_milliseconds; + +} + +void Timestamp::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_seconds; + + + + dcdr >> m_milliseconds; + + +} + + +bool Timestamp::isKeyDefined() +{ + return false; +} + +void Timestamp::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function sets a value in member seconds + * @param _seconds New value for member seconds + */ +void Timestamp::seconds( + int32_t _seconds) +{ + m_seconds = _seconds; +} + +/*! + * @brief This function returns the value of member seconds + * @return Value of member seconds + */ +int32_t Timestamp::seconds() const +{ + return m_seconds; +} + +/*! + * @brief This function returns a reference to member seconds + * @return Reference to member seconds + */ +int32_t& Timestamp::seconds() +{ + return m_seconds; +} + + +/*! + * @brief This function sets a value in member milliseconds + * @param _milliseconds New value for member milliseconds + */ +void Timestamp::milliseconds( + int32_t _milliseconds) +{ + m_milliseconds = _milliseconds; +} + +/*! + * @brief This function returns the value of member milliseconds + * @return Value of member milliseconds + */ +int32_t Timestamp::milliseconds() const +{ + return m_milliseconds; +} + +/*! + * @brief This function returns a reference to member milliseconds + * @return Reference to member milliseconds + */ +int32_t& Timestamp::milliseconds() +{ + return m_milliseconds; +} + + + + + +Point::Point() +{ + // long m_x + m_x = 0; + // long m_y + m_y = 0; + // long m_z + m_z = 0; + + // Just to register all known types + registerCompleteTypes(); +} + +Point::~Point() +{ +} + +Point::Point( + const Point& x) +{ + m_x = x.m_x; + + + m_y = x.m_y; + + + m_z = x.m_z; + +} + +Point::Point( + Point&& x) noexcept +{ + m_x = x.m_x; + + + m_y = x.m_y; + + + m_z = x.m_z; + +} + +Point& Point::operator =( + const Point& x) +{ + m_x = x.m_x; + + + m_y = x.m_y; + + + m_z = x.m_z; + + return *this; +} + +Point& Point::operator =( + Point&& x) noexcept +{ + m_x = x.m_x; + + + m_y = x.m_y; + + + m_z = x.m_z; + + return *this; +} + +bool Point::operator ==( + const Point& x) const +{ + return (m_x == x.m_x && + m_y == x.m_y && + m_z == x.m_z); +} + +bool Point::operator !=( + const Point& x) const +{ + return !(*this == x); +} + +size_t Point::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return Point_max_cdr_typesize; +} + +size_t Point::getCdrSerializedSize( + const Point& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + return current_alignment - initial_alignment; +} + + +void Point::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_x; + + scdr << m_y; + + scdr << m_z; + +} + +void Point::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_x; + + + + dcdr >> m_y; + + + + dcdr >> m_z; + + +} + + +bool Point::isKeyDefined() +{ + return false; +} + +void Point::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ +void Point::x( + int32_t _x) +{ + m_x = _x; +} + +/*! + * @brief This function returns the value of member x + * @return Value of member x + */ +int32_t Point::x() const +{ + return m_x; +} + +/*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ +int32_t& Point::x() +{ + return m_x; +} + + +/*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ +void Point::y( + int32_t _y) +{ + m_y = _y; +} + +/*! + * @brief This function returns the value of member y + * @return Value of member y + */ +int32_t Point::y() const +{ + return m_y; +} + +/*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ +int32_t& Point::y() +{ + return m_y; +} + + +/*! + * @brief This function sets a value in member z + * @param _z New value for member z + */ +void Point::z( + int32_t _z) +{ + m_z = _z; +} + +/*! + * @brief This function returns the value of member z + * @return Value of member z + */ +int32_t Point::z() const +{ + return m_z; +} + +/*! + * @brief This function returns a reference to member z + * @return Reference to member z + */ +int32_t& Point::z() +{ + return m_z; +} + + + + + +MessageDescriptor::MessageDescriptor() +{ + // unsigned long m_id + m_id = 0; + // /type_d() m_topic + + // Timestamp m_time + + + // Just to register all known types + registerCompleteTypes(); +} + +MessageDescriptor::~MessageDescriptor() +{ +} + +MessageDescriptor::MessageDescriptor( + const MessageDescriptor& x) +{ + m_id = x.m_id; + + + m_topic = x.m_topic; + + + m_time = x.m_time; + +} + +MessageDescriptor::MessageDescriptor( + MessageDescriptor&& x) noexcept +{ + m_id = x.m_id; + + + m_topic = std::move(x.m_topic); + + + m_time = std::move(x.m_time); + +} + +MessageDescriptor& MessageDescriptor::operator =( + const MessageDescriptor& x) +{ + m_id = x.m_id; + + + m_topic = x.m_topic; + + + m_time = x.m_time; + + return *this; +} + +MessageDescriptor& MessageDescriptor::operator =( + MessageDescriptor&& x) noexcept +{ + m_id = x.m_id; + + + m_topic = std::move(x.m_topic); + + + m_time = std::move(x.m_time); + + return *this; +} + +bool MessageDescriptor::operator ==( + const MessageDescriptor& x) const +{ + return (m_id == x.m_id && + m_topic == x.m_topic && + m_time == x.m_time); +} + +bool MessageDescriptor::operator !=( + const MessageDescriptor& x) const +{ + return !(*this == x); +} + +size_t MessageDescriptor::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return MessageDescriptor_max_cdr_typesize; +} + +size_t MessageDescriptor::getCdrSerializedSize( + const MessageDescriptor& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.topic().size() + 1; + + + current_alignment += Timestamp::getCdrSerializedSize(data.time(), current_alignment); + + + return current_alignment - initial_alignment; +} + + +void MessageDescriptor::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_id; + + scdr << m_topic.c_str(); + + scdr << m_time; + +} + +void MessageDescriptor::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_id; + + + + dcdr >> m_topic; + + + + dcdr >> m_time; + + +} + + +bool MessageDescriptor::isKeyDefined() +{ + return false; +} + +void MessageDescriptor::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function sets a value in member id + * @param _id New value for member id + */ +void MessageDescriptor::id( + uint32_t _id) +{ + m_id = _id; +} + +/*! + * @brief This function returns the value of member id + * @return Value of member id + */ +uint32_t MessageDescriptor::id() const +{ + return m_id; +} + +/*! + * @brief This function returns a reference to member id + * @return Reference to member id + */ +uint32_t& MessageDescriptor::id() +{ + return m_id; +} + + +/*! + * @brief This function copies the value in member topic + * @param _topic New value to be copied in member topic + */ +void MessageDescriptor::topic( + const std::string& _topic) +{ + m_topic = _topic; +} + +/*! + * @brief This function moves the value in member topic + * @param _topic New value to be moved in member topic + */ +void MessageDescriptor::topic( + std::string&& _topic) +{ + m_topic = std::move(_topic); +} + +/*! + * @brief This function returns a constant reference to member topic + * @return Constant reference to member topic + */ +const std::string& MessageDescriptor::topic() const +{ + return m_topic; +} + +/*! + * @brief This function returns a reference to member topic + * @return Reference to member topic + */ +std::string& MessageDescriptor::topic() +{ + return m_topic; +} + + +/*! + * @brief This function copies the value in member time + * @param _time New value to be copied in member time + */ +void MessageDescriptor::time( + const Timestamp& _time) +{ + m_time = _time; +} + +/*! + * @brief This function moves the value in member time + * @param _time New value to be moved in member time + */ +void MessageDescriptor::time( + Timestamp&& _time) +{ + m_time = std::move(_time); +} + +/*! + * @brief This function returns a constant reference to member time + * @return Constant reference to member time + */ +const Timestamp& MessageDescriptor::time() const +{ + return m_time; +} + +/*! + * @brief This function returns a reference to member time + * @return Reference to member time + */ +Timestamp& MessageDescriptor::time() +{ + return m_time; +} + + + + + +Message::Message() +{ + // MessageDescriptor m_descriptor + + // /type_d() m_message + + + // Just to register all known types + registerCompleteTypes(); +} + +Message::~Message() +{ +} + +Message::Message( + const Message& x) +{ + m_descriptor = x.m_descriptor; + + + m_message = x.m_message; + +} + +Message::Message( + Message&& x) noexcept +{ + m_descriptor = std::move(x.m_descriptor); + + + m_message = std::move(x.m_message); + +} + +Message& Message::operator =( + const Message& x) +{ + m_descriptor = x.m_descriptor; + + + m_message = x.m_message; + + return *this; +} + +Message& Message::operator =( + Message&& x) noexcept +{ + m_descriptor = std::move(x.m_descriptor); + + + m_message = std::move(x.m_message); + + return *this; +} + +bool Message::operator ==( + const Message& x) const +{ + return (m_descriptor == x.m_descriptor && + m_message == x.m_message); +} + +bool Message::operator !=( + const Message& x) const +{ + return !(*this == x); +} + +size_t Message::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return Message_max_cdr_typesize; +} + +size_t Message::getCdrSerializedSize( + const Message& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += MessageDescriptor::getCdrSerializedSize(data.descriptor(), current_alignment); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void Message::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_descriptor; + + scdr << m_message.c_str(); + +} + +void Message::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_descriptor; + + + + dcdr >> m_message; + + +} + + +bool Message::isKeyDefined() +{ + return false; +} + +void Message::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member descriptor + * @param _descriptor New value to be copied in member descriptor + */ +void Message::descriptor( + const MessageDescriptor& _descriptor) +{ + m_descriptor = _descriptor; +} + +/*! + * @brief This function moves the value in member descriptor + * @param _descriptor New value to be moved in member descriptor + */ +void Message::descriptor( + MessageDescriptor&& _descriptor) +{ + m_descriptor = std::move(_descriptor); +} + +/*! + * @brief This function returns a constant reference to member descriptor + * @return Constant reference to member descriptor + */ +const MessageDescriptor& Message::descriptor() const +{ + return m_descriptor; +} + +/*! + * @brief This function returns a reference to member descriptor + * @return Reference to member descriptor + */ +MessageDescriptor& Message::descriptor() +{ + return m_descriptor; +} + + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void Message::message( + const std::string& _message) +{ + m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void Message::message( + std::string&& _message) +{ + m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::string& Message::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::string& Message::message() +{ + return m_message; +} + + + + + +CompleteData::CompleteData() +{ + // unsigned long m_index + m_index = 0; + // Point m_main_point + + // sequence m_internal_data + + // Message m_messages + + + // Just to register all known types + registerCompleteTypes(); +} + +CompleteData::~CompleteData() +{ +} + +CompleteData::CompleteData( + const CompleteData& x) +{ + m_index = x.m_index; + + + m_main_point = x.m_main_point; + + + m_internal_data = x.m_internal_data; + + + m_messages = x.m_messages; + +} + +CompleteData::CompleteData( + CompleteData&& x) noexcept +{ + m_index = x.m_index; + + + m_main_point = std::move(x.m_main_point); + + + m_internal_data = std::move(x.m_internal_data); + + + m_messages = std::move(x.m_messages); + +} + +CompleteData& CompleteData::operator =( + const CompleteData& x) +{ + m_index = x.m_index; + + + m_main_point = x.m_main_point; + + + m_internal_data = x.m_internal_data; + + + m_messages = x.m_messages; + + return *this; +} + +CompleteData& CompleteData::operator =( + CompleteData&& x) noexcept +{ + m_index = x.m_index; + + + m_main_point = std::move(x.m_main_point); + + + m_internal_data = std::move(x.m_internal_data); + + + m_messages = std::move(x.m_messages); + + return *this; +} + +bool CompleteData::operator ==( + const CompleteData& x) const +{ + return (m_index == x.m_index && + m_main_point == x.m_main_point && + m_internal_data == x.m_internal_data && + m_messages == x.m_messages); +} + +bool CompleteData::operator !=( + const CompleteData& x) const +{ + return !(*this == x); +} + +size_t CompleteData::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return CompleteData_max_cdr_typesize; +} + +size_t CompleteData::getCdrSerializedSize( + const CompleteData& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += Point::getCdrSerializedSize(data.main_point(), current_alignment); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < data.internal_data().size(); ++a) + { + current_alignment += Point::getCdrSerializedSize(data.internal_data().at(a), current_alignment); + } + + + + + for(size_t a = 0; a < data.messages().size(); ++a) + { + current_alignment += Message::getCdrSerializedSize(data.messages().at(a), current_alignment); + + } + + + + return current_alignment - initial_alignment; +} + + +void CompleteData::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_index; + + scdr << m_main_point; + + scdr << m_internal_data; + + + scdr << m_messages; + + +} + +void CompleteData::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_index; + + + + dcdr >> m_main_point; + + + + dcdr >> m_internal_data; + + + + dcdr >> m_messages; + + +} + + +bool CompleteData::isKeyDefined() +{ + return false; +} + +void CompleteData::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void CompleteData::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t CompleteData::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& CompleteData::index() +{ + return m_index; +} + + +/*! + * @brief This function copies the value in member main_point + * @param _main_point New value to be copied in member main_point + */ +void CompleteData::main_point( + const Point& _main_point) +{ + m_main_point = _main_point; +} + +/*! + * @brief This function moves the value in member main_point + * @param _main_point New value to be moved in member main_point + */ +void CompleteData::main_point( + Point&& _main_point) +{ + m_main_point = std::move(_main_point); +} + +/*! + * @brief This function returns a constant reference to member main_point + * @return Constant reference to member main_point + */ +const Point& CompleteData::main_point() const +{ + return m_main_point; +} + +/*! + * @brief This function returns a reference to member main_point + * @return Reference to member main_point + */ +Point& CompleteData::main_point() +{ + return m_main_point; +} + + +/*! + * @brief This function copies the value in member internal_data + * @param _internal_data New value to be copied in member internal_data + */ +void CompleteData::internal_data( + const std::vector& _internal_data) +{ + m_internal_data = _internal_data; +} + +/*! + * @brief This function moves the value in member internal_data + * @param _internal_data New value to be moved in member internal_data + */ +void CompleteData::internal_data( + std::vector&& _internal_data) +{ + m_internal_data = std::move(_internal_data); +} + +/*! + * @brief This function returns a constant reference to member internal_data + * @return Constant reference to member internal_data + */ +const std::vector& CompleteData::internal_data() const +{ + return m_internal_data; +} + +/*! + * @brief This function returns a reference to member internal_data + * @return Reference to member internal_data + */ +std::vector& CompleteData::internal_data() +{ + return m_internal_data; +} + + +/*! + * @brief This function copies the value in member messages + * @param _messages New value to be copied in member messages + */ +void CompleteData::messages( + const std::array& _messages) +{ + m_messages = _messages; +} + +/*! + * @brief This function moves the value in member messages + * @param _messages New value to be moved in member messages + */ +void CompleteData::messages( + std::array&& _messages) +{ + m_messages = std::move(_messages); +} + +/*! + * @brief This function returns a constant reference to member messages + * @return Constant reference to member messages + */ +const std::array& CompleteData::messages() const +{ + return m_messages; +} + +/*! + * @brief This function returns a reference to member messages + * @return Reference to member messages + */ +std::array& CompleteData::messages() +{ + return m_messages; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/resources/dds/TypeLookupService/types/complete/Completev1.h b/resources/dds/TypeLookupService/types/complete/Completev1.h new file mode 100644 index 000000000..e45485ee0 --- /dev/null +++ b/resources/dds/TypeLookupService/types/complete/Completev1.h @@ -0,0 +1,1009 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file Complete.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_COMPLETE_H_ +#define _FAST_DDS_GENERATED_COMPLETE_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(COMPLETE_SOURCE) +#define COMPLETE_DllAPI __declspec( dllexport ) +#else +#define COMPLETE_DllAPI __declspec( dllimport ) +#endif // COMPLETE_SOURCE +#else +#define COMPLETE_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define COMPLETE_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure Timestamp defined by the user in the IDL file. + * @ingroup Complete + */ +class Timestamp +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport Timestamp(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~Timestamp(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object Timestamp that will be copied. + */ + eProsima_user_DllExport Timestamp( + const Timestamp& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object Timestamp that will be copied. + */ + eProsima_user_DllExport Timestamp( + Timestamp&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object Timestamp that will be copied. + */ + eProsima_user_DllExport Timestamp& operator =( + const Timestamp& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object Timestamp that will be copied. + */ + eProsima_user_DllExport Timestamp& operator =( + Timestamp&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x Timestamp object to compare. + */ + eProsima_user_DllExport bool operator ==( + const Timestamp& x) const; + + /*! + * @brief Comparison operator. + * @param x Timestamp object to compare. + */ + eProsima_user_DllExport bool operator !=( + const Timestamp& x) const; + + /*! + * @brief This function sets a value in member seconds + * @param _seconds New value for member seconds + */ + eProsima_user_DllExport void seconds( + int32_t _seconds); + + /*! + * @brief This function returns the value of member seconds + * @return Value of member seconds + */ + eProsima_user_DllExport int32_t seconds() const; + + /*! + * @brief This function returns a reference to member seconds + * @return Reference to member seconds + */ + eProsima_user_DllExport int32_t& seconds(); + + + /*! + * @brief This function sets a value in member milliseconds + * @param _milliseconds New value for member milliseconds + */ + eProsima_user_DllExport void milliseconds( + int32_t _milliseconds); + + /*! + * @brief This function returns the value of member milliseconds + * @return Value of member milliseconds + */ + eProsima_user_DllExport int32_t milliseconds() const; + + /*! + * @brief This function returns a reference to member milliseconds + * @return Reference to member milliseconds + */ + eProsima_user_DllExport int32_t& milliseconds(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const Timestamp& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + int32_t m_seconds; + int32_t m_milliseconds; + +}; + + + +/*! + * @brief This class represents the structure Point defined by the user in the IDL file. + * @ingroup Complete + */ +class Point +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport Point(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~Point(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object Point that will be copied. + */ + eProsima_user_DllExport Point( + const Point& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object Point that will be copied. + */ + eProsima_user_DllExport Point( + Point&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object Point that will be copied. + */ + eProsima_user_DllExport Point& operator =( + const Point& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object Point that will be copied. + */ + eProsima_user_DllExport Point& operator =( + Point&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x Point object to compare. + */ + eProsima_user_DllExport bool operator ==( + const Point& x) const; + + /*! + * @brief Comparison operator. + * @param x Point object to compare. + */ + eProsima_user_DllExport bool operator !=( + const Point& x) const; + + /*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ + eProsima_user_DllExport void x( + int32_t _x); + + /*! + * @brief This function returns the value of member x + * @return Value of member x + */ + eProsima_user_DllExport int32_t x() const; + + /*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ + eProsima_user_DllExport int32_t& x(); + + + /*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ + eProsima_user_DllExport void y( + int32_t _y); + + /*! + * @brief This function returns the value of member y + * @return Value of member y + */ + eProsima_user_DllExport int32_t y() const; + + /*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ + eProsima_user_DllExport int32_t& y(); + + + /*! + * @brief This function sets a value in member z + * @param _z New value for member z + */ + eProsima_user_DllExport void z( + int32_t _z); + + /*! + * @brief This function returns the value of member z + * @return Value of member z + */ + eProsima_user_DllExport int32_t z() const; + + /*! + * @brief This function returns a reference to member z + * @return Reference to member z + */ + eProsima_user_DllExport int32_t& z(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const Point& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + int32_t m_x; + int32_t m_y; + int32_t m_z; + +}; + + + +/*! + * @brief This class represents the structure MessageDescriptor defined by the user in the IDL file. + * @ingroup Complete + */ +class MessageDescriptor +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport MessageDescriptor(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~MessageDescriptor(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object MessageDescriptor that will be copied. + */ + eProsima_user_DllExport MessageDescriptor( + const MessageDescriptor& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object MessageDescriptor that will be copied. + */ + eProsima_user_DllExport MessageDescriptor( + MessageDescriptor&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object MessageDescriptor that will be copied. + */ + eProsima_user_DllExport MessageDescriptor& operator =( + const MessageDescriptor& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object MessageDescriptor that will be copied. + */ + eProsima_user_DllExport MessageDescriptor& operator =( + MessageDescriptor&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x MessageDescriptor object to compare. + */ + eProsima_user_DllExport bool operator ==( + const MessageDescriptor& x) const; + + /*! + * @brief Comparison operator. + * @param x MessageDescriptor object to compare. + */ + eProsima_user_DllExport bool operator !=( + const MessageDescriptor& x) const; + + /*! + * @brief This function sets a value in member id + * @param _id New value for member id + */ + eProsima_user_DllExport void id( + uint32_t _id); + + /*! + * @brief This function returns the value of member id + * @return Value of member id + */ + eProsima_user_DllExport uint32_t id() const; + + /*! + * @brief This function returns a reference to member id + * @return Reference to member id + */ + eProsima_user_DllExport uint32_t& id(); + + + /*! + * @brief This function copies the value in member topic + * @param _topic New value to be copied in member topic + */ + eProsima_user_DllExport void topic( + const std::string& _topic); + + /*! + * @brief This function moves the value in member topic + * @param _topic New value to be moved in member topic + */ + eProsima_user_DllExport void topic( + std::string&& _topic); + + /*! + * @brief This function returns a constant reference to member topic + * @return Constant reference to member topic + */ + eProsima_user_DllExport const std::string& topic() const; + + /*! + * @brief This function returns a reference to member topic + * @return Reference to member topic + */ + eProsima_user_DllExport std::string& topic(); + + + /*! + * @brief This function copies the value in member time + * @param _time New value to be copied in member time + */ + eProsima_user_DllExport void time( + const Timestamp& _time); + + /*! + * @brief This function moves the value in member time + * @param _time New value to be moved in member time + */ + eProsima_user_DllExport void time( + Timestamp&& _time); + + /*! + * @brief This function returns a constant reference to member time + * @return Constant reference to member time + */ + eProsima_user_DllExport const Timestamp& time() const; + + /*! + * @brief This function returns a reference to member time + * @return Reference to member time + */ + eProsima_user_DllExport Timestamp& time(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const MessageDescriptor& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + uint32_t m_id; + std::string m_topic; + Timestamp m_time; + +}; + + + +/*! + * @brief This class represents the structure Message defined by the user in the IDL file. + * @ingroup Complete + */ +class Message +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport Message(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~Message(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object Message that will be copied. + */ + eProsima_user_DllExport Message( + const Message& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object Message that will be copied. + */ + eProsima_user_DllExport Message( + Message&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object Message that will be copied. + */ + eProsima_user_DllExport Message& operator =( + const Message& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object Message that will be copied. + */ + eProsima_user_DllExport Message& operator =( + Message&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x Message object to compare. + */ + eProsima_user_DllExport bool operator ==( + const Message& x) const; + + /*! + * @brief Comparison operator. + * @param x Message object to compare. + */ + eProsima_user_DllExport bool operator !=( + const Message& x) const; + + /*! + * @brief This function copies the value in member descriptor + * @param _descriptor New value to be copied in member descriptor + */ + eProsima_user_DllExport void descriptor( + const MessageDescriptor& _descriptor); + + /*! + * @brief This function moves the value in member descriptor + * @param _descriptor New value to be moved in member descriptor + */ + eProsima_user_DllExport void descriptor( + MessageDescriptor&& _descriptor); + + /*! + * @brief This function returns a constant reference to member descriptor + * @return Constant reference to member descriptor + */ + eProsima_user_DllExport const MessageDescriptor& descriptor() const; + + /*! + * @brief This function returns a reference to member descriptor + * @return Reference to member descriptor + */ + eProsima_user_DllExport MessageDescriptor& descriptor(); + + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message( + const std::string& _message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message( + std::string&& _message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const Message& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + MessageDescriptor m_descriptor; + std::string m_message; + +}; + + + +/*! + * @brief This class represents the structure CompleteData defined by the user in the IDL file. + * @ingroup Complete + */ +class CompleteData +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport CompleteData(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~CompleteData(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object CompleteData that will be copied. + */ + eProsima_user_DllExport CompleteData( + const CompleteData& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object CompleteData that will be copied. + */ + eProsima_user_DllExport CompleteData( + CompleteData&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object CompleteData that will be copied. + */ + eProsima_user_DllExport CompleteData& operator =( + const CompleteData& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object CompleteData that will be copied. + */ + eProsima_user_DllExport CompleteData& operator =( + CompleteData&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x CompleteData object to compare. + */ + eProsima_user_DllExport bool operator ==( + const CompleteData& x) const; + + /*! + * @brief Comparison operator. + * @param x CompleteData object to compare. + */ + eProsima_user_DllExport bool operator !=( + const CompleteData& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + + /*! + * @brief This function copies the value in member main_point + * @param _main_point New value to be copied in member main_point + */ + eProsima_user_DllExport void main_point( + const Point& _main_point); + + /*! + * @brief This function moves the value in member main_point + * @param _main_point New value to be moved in member main_point + */ + eProsima_user_DllExport void main_point( + Point&& _main_point); + + /*! + * @brief This function returns a constant reference to member main_point + * @return Constant reference to member main_point + */ + eProsima_user_DllExport const Point& main_point() const; + + /*! + * @brief This function returns a reference to member main_point + * @return Reference to member main_point + */ + eProsima_user_DllExport Point& main_point(); + + + /*! + * @brief This function copies the value in member internal_data + * @param _internal_data New value to be copied in member internal_data + */ + eProsima_user_DllExport void internal_data( + const std::vector& _internal_data); + + /*! + * @brief This function moves the value in member internal_data + * @param _internal_data New value to be moved in member internal_data + */ + eProsima_user_DllExport void internal_data( + std::vector&& _internal_data); + + /*! + * @brief This function returns a constant reference to member internal_data + * @return Constant reference to member internal_data + */ + eProsima_user_DllExport const std::vector& internal_data() const; + + /*! + * @brief This function returns a reference to member internal_data + * @return Reference to member internal_data + */ + eProsima_user_DllExport std::vector& internal_data(); + + + /*! + * @brief This function copies the value in member messages + * @param _messages New value to be copied in member messages + */ + eProsima_user_DllExport void messages( + const std::array& _messages); + + /*! + * @brief This function moves the value in member messages + * @param _messages New value to be moved in member messages + */ + eProsima_user_DllExport void messages( + std::array&& _messages); + + /*! + * @brief This function returns a constant reference to member messages + * @return Constant reference to member messages + */ + eProsima_user_DllExport const std::array& messages() const; + + /*! + * @brief This function returns a reference to member messages + * @return Reference to member messages + */ + eProsima_user_DllExport std::array& messages(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const CompleteData& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + uint32_t m_index; + Point m_main_point; + std::vector m_internal_data; + std::array m_messages; + +}; + + +#endif // _FAST_DDS_GENERATED_COMPLETE_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.cxx index 2678a873d..502f3953b 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.cxx +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.cxx @@ -27,21 +27,24 @@ char dummy; #endif // _WIN32 #include "HelloWorld.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #include "HelloWorldTypeObject.h" -#include +#include + + +#include +using namespace eprosima::fastcdr::exception; #include -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" -using namespace eprosima::fastcdr::exception; HelloWorld::HelloWorld() { - // Just to register all known types registerHelloWorldTypes(); } @@ -95,19 +98,6 @@ bool HelloWorld::operator !=( return !(*this == x); } -void HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - eprosima::fastcdr::serialize(scdr, *this); -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - eprosima::fastcdr::deserialize(dcdr, *this); -} - - /*! * @brief This function sets a value in member index * @param _index New value for member index @@ -175,3 +165,8 @@ std::string& HelloWorld::message() return m_message; } + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.h index 69057d262..5cd0ddba5 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.h +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include +#include "HelloWorldv1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ #define _FAST_DDS_GENERATED_HELLOWORLD_H_ @@ -29,13 +34,9 @@ #include #include -#include -#if FASTCDR_VERSION_MAJOR == 1 -#include -#else #include +#include #include -#endif // FASTCDR_VERSION_MAJOR == 1 @@ -72,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -178,23 +181,6 @@ class HelloWorld */ eProsima_user_DllExport std::string& message(); - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - private: uint32_t m_index{0}; @@ -204,3 +190,6 @@ class HelloWorld #endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp index 713dba562..9f346d306 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp index 55034e024..42e91f3cc 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp @@ -25,10 +25,7 @@ #include "HelloWorldCdrAux.hpp" #include -#if FASTCDR_VERSION_MAJOR > 1 #include -#endif // FASTCDR_VERSION_MAJOR > 1 - #include @@ -37,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -45,24 +44,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( { static_cast(data); -#if FASTCDR_VERSION_MAJOR == 1 - - static_cast(calculator); - static_cast(current_alignment); - - size_t initial_alignment {current_alignment}; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - - return current_alignment - initial_alignment; - -#else - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); size_t calculated_size {calculator.begin_calculate_type_serialized_size( eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? @@ -81,8 +62,6 @@ eProsima_user_DllExport size_t calculate_serialized_size( calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); return calculated_size; - -#endif // FASTCDR_VERSION_MAJOR == 1 } template<> @@ -90,33 +69,17 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data) { -#if FASTCDR_VERSION_MAJOR > 1 eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); -#endif // FASTCDR_VERSION_MAJOR > 1 - -#if FASTCDR_VERSION_MAJOR == 1 - scdr << data.index() - ; - - scdr << data.message() - ; - - -#else scdr << eprosima::fastcdr::MemberId(0) << data.index() << eprosima::fastcdr::MemberId(1) << data.message() ; -#endif // FASTCDR_VERSION_MAJOR == 1 - -#if FASTCDR_VERSION_MAJOR > 1 scdr.end_serialize_type(current_state); -#endif // FASTCDR_VERSION_MAJOR > 1 } template<> @@ -124,11 +87,6 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, HelloWorld& data) { -#if FASTCDR_VERSION_MAJOR == 1 - cdr >> data.index(); - cdr >> data.message(); -; -#else cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -151,7 +109,6 @@ eProsima_user_DllExport void deserialize( } return ret_value; }); -#endif // FASTCDR_VERSION_MAJOR == 1 } void serialize_key( diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx index 7efd377ec..eae5d4a75 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx @@ -19,6 +19,7 @@ * This file was generated by the tool fastddsgen. */ + #include #include "HelloWorldPubSubTypes.h" @@ -28,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); - uint32_t type_size = HelloWorld_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + HelloWorld::getMaxCdrSerializedSize(); +#else + HelloWorld_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -130,13 +138,25 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -169,7 +189,11 @@ bool HelloWorldPubSubType::getKey( // Object that serializes the data. eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) { m_md5.init(); diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h index f6c88d5c1..cb61cd6ba 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.cxx index 0ff0768d6..69e829c28 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.cxx +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.cxx @@ -52,6 +52,8 @@ void registerHelloWorldTypes() }); } + + const TypeIdentifier* GetHelloWorldIdentifier(bool complete) { const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); @@ -140,7 +142,6 @@ const TypeObject* GetMinimalHelloWorldObject() // TODO Inheritance //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - TypeIdentifier identifier; identifier._d(EK_MINIMAL); @@ -228,7 +229,6 @@ const TypeObject* GetCompleteHelloWorldObject() // Header type_object->complete().struct_type().header().detail().type_name("HelloWorld"); // TODO inheritance - TypeIdentifier identifier; identifier._d(EK_COMPLETE); diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.h index c28779dbe..76b2a621e 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.h +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.h @@ -54,6 +54,8 @@ using namespace eprosima::fastrtps::types; eProsima_user_DllExport void registerHelloWorldTypes(); + + eProsima_user_DllExport const TypeIdentifier* GetHelloWorldIdentifier(bool complete = false); eProsima_user_DllExport const TypeObject* GetHelloWorldObject(bool complete = false); eProsima_user_DllExport const TypeObject* GetMinimalHelloWorldObject(); diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.cxx new file mode 100644 index 000000000..bb049241e --- /dev/null +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.cxx @@ -0,0 +1,290 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "HelloWorld.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include "HelloWorldTypeObject.h" + +#include + + +#include +using namespace eprosima::fastcdr::exception; + +#include + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template +struct FindTypeH; + +template<> +struct FindTypeH { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH { + using type = std::uint64_t; +}; +} + +template +struct FindType { + using type = typename internal::FindTypeH::type; +}; +} + +#define HelloWorld_max_cdr_typesize 268ULL; + + + + +HelloWorld::HelloWorld() +{ + // unsigned long m_index + m_index = 0; + // /type_d() m_message + + + // Just to register all known types + registerHelloWorldTypes(); +} + +HelloWorld::~HelloWorld() +{ +} + +HelloWorld::HelloWorld( + const HelloWorld& x) +{ + m_index = x.m_index; + + + m_message = x.m_message; + +} + +HelloWorld::HelloWorld( + HelloWorld&& x) noexcept +{ + m_index = x.m_index; + + + m_message = std::move(x.m_message); + +} + +HelloWorld& HelloWorld::operator =( + const HelloWorld& x) +{ + m_index = x.m_index; + + + m_message = x.m_message; + + return *this; +} + +HelloWorld& HelloWorld::operator =( + HelloWorld&& x) noexcept +{ + m_index = x.m_index; + + + m_message = std::move(x.m_message); + + return *this; +} + +bool HelloWorld::operator ==( + const HelloWorld& x) const +{ + return (m_index == x.m_index && + m_message == x.m_message); +} + +bool HelloWorld::operator !=( + const HelloWorld& x) const +{ + return !(*this == x); +} + +size_t HelloWorld::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return HelloWorld_max_cdr_typesize; +} + +size_t HelloWorld::getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; + + + return current_alignment - initial_alignment; +} + + +void HelloWorld::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_index; + + scdr << m_message.c_str(); + +} + +void HelloWorld::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_index; + + + + dcdr >> m_message; + + +} + + +bool HelloWorld::isKeyDefined() +{ + return false; +} + +void HelloWorld::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void HelloWorld::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t HelloWorld::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& HelloWorld::index() +{ + return m_index; +} + + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void HelloWorld::message( + const std::string& _message) +{ + m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void HelloWorld::message( + std::string&& _message) +{ + m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::string& HelloWorld::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::string& HelloWorld::message() +{ + return m_message; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.h new file mode 100644 index 000000000..7758cd793 --- /dev/null +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.h @@ -0,0 +1,243 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorld.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(HELLOWORLD_SOURCE) +#define HELLOWORLD_DllAPI __declspec( dllexport ) +#else +#define HELLOWORLD_DllAPI __declspec( dllimport ) +#endif // HELLOWORLD_SOURCE +#else +#define HELLOWORLD_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define HELLOWORLD_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorld +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport HelloWorld(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~HelloWorld(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + const HelloWorld& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld( + HelloWorld&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + const HelloWorld& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object HelloWorld that will be copied. + */ + eProsima_user_DllExport HelloWorld& operator =( + HelloWorld&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator ==( + const HelloWorld& x) const; + + /*! + * @brief Comparison operator. + * @param x HelloWorld object to compare. + */ + eProsima_user_DllExport bool operator !=( + const HelloWorld& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message( + const std::string& _message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message( + std::string&& _message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const HelloWorld& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + uint32_t m_index; + std::string m_message; + +}; + + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1