From 4f2af4fb3adf0cbc59d2bb9536c53f00afe3bf12 Mon Sep 17 00:00:00 2001 From: Irene Bandera Moreno Date: Thu, 25 Jan 2024 09:30:44 +0100 Subject: [PATCH] Add support for FastDDS versions earlier than 2.13 (#67) Signed-off-by: Irene Bandera --- .../AdvancedConfigurationPublisher.h | 7 +- .../AdvancedConfigurationSubscriber.h | 7 +- .../CMakeLists.txt | 23 +- .../types/v1/HelloWorld.cxx | 227 +++++++++++++++++ .../types/v1/HelloWorld.h | 235 ++++++++++++++++++ .../{ => types/v1}/HelloWorld.idl | 0 .../types/v1/HelloWorldPubSubTypes.cxx | 170 +++++++++++++ .../types/v1/HelloWorldPubSubTypes.h | 145 +++++++++++ .../{ => types/v2}/HelloWorld.cxx | 0 .../{ => types/v2}/HelloWorld.h | 0 .../types/v2/HelloWorld.idl | 5 + .../{ => types/v2}/HelloWorldCdrAux.hpp | 0 .../{ => types/v2}/HelloWorldCdrAux.ipp | 0 .../{ => types/v2}/HelloWorldPubSubTypes.cxx | 4 +- .../{ => types/v2}/HelloWorldPubSubTypes.h | 0 .../{ => types/v2}/HelloWorldv1.cxx | 0 .../{ => types/v2}/HelloWorldv1.h | 0 17 files changed, 815 insertions(+), 8 deletions(-) create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v1}/HelloWorld.idl (100%) create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorld.cxx (100%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorld.h (100%) create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorldCdrAux.hpp (100%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorldCdrAux.ipp (100%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorldPubSubTypes.cxx (98%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorldPubSubTypes.h (100%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorldv1.cxx (100%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/{ => types/v2}/HelloWorldv1.h (100%) diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h index 5f9c77fd..9dcd599a 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h @@ -28,7 +28,12 @@ #include #include -#include "HelloWorldPubSubTypes.h" +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "types/v1/HelloWorldPubSubTypes.h" +#else + #include "types/v2/HelloWorldPubSubTypes.h" +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "types.hpp" /** diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h index 0f6a4fc0..b3e0ccc8 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h @@ -28,7 +28,12 @@ #include #include -#include "HelloWorldPubSubTypes.h" +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "types/v1/HelloWorldPubSubTypes.h" +#else + #include "types/v2/HelloWorldPubSubTypes.h" +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "types.hpp" /** diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt index cb0f181b..1129030f 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt @@ -18,11 +18,11 @@ project(AdvancedConfigurationExample VERSION 1 LANGUAGES CXX) # Find requirements if(NOT fastcdr_FOUND) - find_package(fastcdr 2 REQUIRED) + find_package(fastcdr REQUIRED) endif() if(NOT fastrtps_FOUND) - find_package(fastrtps 2.12 REQUIRED) + find_package(fastrtps REQUIRED) endif() #Check C++11 @@ -35,9 +35,24 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") endif() endif() +# Determine Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + set(DDS_TYPES_VERSION "v1") +else() + set(DDS_TYPES_VERSION "v2") +endif() + message(STATUS "Configuring AdvancedConfiguration example...") -file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX "*.cxx") -file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP "*.cpp") +file( + GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX + "*.cxx" + "types/${DDS_TYPES_VERSION}/*.cxx" +) +file( + GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP + "*.cpp" + "types/${DDS_TYPES_VERSION}/*.cpp" +) add_executable(${PROJECT_NAME} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP}) target_compile_definitions(${PROJECT_NAME} PRIVATE diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx new file mode 100644 index 00000000..42283dee --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx @@ -0,0 +1,227 @@ +// 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 definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "HelloWorld.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +#define HelloWorld_max_cdr_typesize 24ULL; +#define HelloWorld_max_key_cdr_typesize 0ULL; + +HelloWorld::HelloWorld() +{ + // unsigned long m_index + m_index = 0; + // char m_message + memset(&m_message, 0, (20) * 1); + +} + +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 += ((20) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + return current_alignment - initial_alignment; +} + +void HelloWorld::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_index; + scdr << m_message; + + +} + +void HelloWorld::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_index; + dcdr >> m_message; + +} + +/*! + * @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::array& _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::array&& _message) +{ + m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::array& HelloWorld::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::array& HelloWorld::message() +{ + return m_message; +} + +size_t HelloWorld::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return HelloWorld_max_key_cdr_typesize; +} + +bool HelloWorld::isKeyDefined() +{ + return false; +} + +void HelloWorld::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h new file mode 100644 index 00000000..8c2988e5 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h @@ -0,0 +1,235 @@ +// 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 gen. + */ + +#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::array& _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::array&& _message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::array& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::array& 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 returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @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::array m_message; + +}; + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.idl b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.idl similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.idl rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.idl diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx new file mode 100644 index 00000000..df22dd59 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx @@ -0,0 +1,170 @@ +// 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 HelloWorldPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "HelloWorldPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +HelloWorldPubSubType::HelloWorldPubSubType() +{ + setName("HelloWorld"); + auto type_size = HelloWorld::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = HelloWorld::isKeyDefined(); + size_t keyLength = HelloWorld::getKeyMaxCdrSerializedSize() > 16 ? + HelloWorld::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +HelloWorldPubSubType::~HelloWorldPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool HelloWorldPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool HelloWorldPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function HelloWorldPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* HelloWorldPubSubType::createData() +{ + return reinterpret_cast(new HelloWorld()); +} + +void HelloWorldPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool HelloWorldPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + HelloWorld::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || HelloWorld::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h new file mode 100644 index 00000000..d7b5d31d --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h @@ -0,0 +1,145 @@ +// 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 HelloWorldPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ + +#include +#include + +#include "HelloWorld.h" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + + +#ifndef SWIG +namespace detail { + +template +struct HelloWorld_rob +{ + friend constexpr typename Tag::type get( + Tag) + { + return M; + } + +}; + +struct HelloWorld_f +{ + typedef std::array HelloWorld::* type; + friend constexpr type get( + HelloWorld_f); +}; + +template struct HelloWorld_rob; + +template +inline size_t constexpr HelloWorld_offset_of() +{ + return ((::size_t) &reinterpret_cast((((T*)0)->*get(Tag())))); +} + +} // namespace detail +#endif // ifndef SWIG + +/*! + * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef HelloWorld type; + + eProsima_user_DllExport HelloWorldPubSubType(); + + eProsima_user_DllExport virtual ~HelloWorldPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#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 is_plain_impl(); + } + +#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 + { + new (memory) HelloWorld(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; + +private: + + static constexpr bool is_plain_impl() + { + return 24ULL == + (detail::HelloWorld_offset_of() + sizeof(std::array)); + + } + +}; + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.cxx similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.cxx diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.h similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.h diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl new file mode 100644 index 00000000..9750fbe1 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl @@ -0,0 +1,5 @@ +struct HelloWorld +{ + unsigned long index; + char message[20]; +}; diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.hpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.hpp similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.hpp rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.hpp diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.ipp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.ipp similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.ipp rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.ipp diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.cxx similarity index 98% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.cxx index fb02e5c6..0e375416 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.cxx @@ -91,7 +91,7 @@ bool HelloWorldPubSubType::serialize( // Get the serialized length #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.get_serialized_data_length()); + payload->length = static_cast(ser.getSerializedDataLength()); #else payload->length = static_cast(ser.get_serialized_data_length()); #endif // FASTCDR_VERSION_MAJOR == 1 @@ -199,7 +199,7 @@ bool HelloWorldPubSubType::getKey( { m_md5.init(); #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); #else m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); #endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.h similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.h diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.cxx similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.cxx rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.cxx diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.h similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.h rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.h