diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt index d382cb4e..cb0f181b 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt @@ -12,17 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.16.3) +cmake_minimum_required(VERSION 3.22) project(AdvancedConfigurationExample VERSION 1 LANGUAGES CXX) # Find requirements if(NOT fastcdr_FOUND) - find_package(fastcdr REQUIRED) + find_package(fastcdr 2 REQUIRED) endif() if(NOT fastrtps_FOUND) - find_package(fastrtps REQUIRED) + find_package(fastrtps 2.12 REQUIRED) endif() #Check C++11 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx index 42283dee..0d9236d0 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.cxx @@ -14,9 +14,9 @@ /*! * @file HelloWorld.cpp - * This source file contains the definition of the described types in the IDL file. + * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool gen. + * This file was generated by the tool fastddsgen. */ #ifdef _WIN32 @@ -27,29 +27,26 @@ char dummy; #endif // _WIN32 #include "HelloWorld.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #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( @@ -72,7 +69,6 @@ HelloWorld& HelloWorld::operator =( m_index = x.m_index; m_message = x.m_message; - return *this; } @@ -82,15 +78,14 @@ HelloWorld& HelloWorld::operator =( 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); + return (m_index == x.m_index && + m_message == x.m_message); } bool HelloWorld::operator !=( @@ -99,49 +94,6 @@ bool HelloWorld::operator !=( 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 @@ -170,6 +122,7 @@ 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 @@ -208,20 +161,8 @@ 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; -} +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h index cc9a23d6..aaf09e4b 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorld.h @@ -16,21 +16,29 @@ * @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. + * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ +#include +#include "HelloWorldv1.h" +#if FASTCDR_VERSION_MAJOR > 1 -#include +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_H_ -#include #include +#include +#include +#include #include #include -#include -#include + +#include +#include +#include + + #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -59,10 +67,14 @@ namespace eprosima { namespace fastcdr { class Cdr; +class CdrSizeCalculator; } // namespace fastcdr } // namespace eprosima + + + /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -142,6 +154,7 @@ class HelloWorld */ 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 @@ -168,69 +181,15 @@ class HelloWorld */ 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; + uint32_t m_index{0}; + std::array m_message{0}; }; #endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.hpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.hpp new file mode 100644 index 00000000..5c8468e7 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.hpp @@ -0,0 +1,48 @@ +// 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 HelloWorldCdrAux.hpp + * This source file contains some definitions of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ + +#include "HelloWorld.h" + +constexpr uint32_t HelloWorld_max_cdr_typesize {28UL}; +constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; + + +namespace eprosima { +namespace fastcdr { + +class Cdr; +class CdrSizeCalculator; + + + +eProsima_user_DllExport void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data); + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ + diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.ipp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.ipp new file mode 100644 index 00000000..42e91f3c --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldCdrAux.ipp @@ -0,0 +1,128 @@ +// 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 HelloWorldCdrAux.ipp + * This source file contains some declarations of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ + +#include "HelloWorldCdrAux.hpp" + +#include +#include + + +#include +using namespace eprosima::fastcdr::exception; + +namespace eprosima { +namespace fastcdr { + + + +template<> +eProsima_user_DllExport size_t calculate_serialized_size( + eprosima::fastcdr::CdrSizeCalculator& calculator, + const HelloWorld& data, + size_t& current_alignment) +{ + static_cast(data); + + 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() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + current_alignment)}; + + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); + + + calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); + + return calculated_size; +} + +template<> +eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data) +{ + 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); + + scdr + << eprosima::fastcdr::MemberId(0) << data.index() + << eprosima::fastcdr::MemberId(1) << data.message() +; + scdr.end_serialize_type(current_state); +} + +template<> +eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr, + HelloWorld& data) +{ + cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool + { + bool ret_value = true; + switch (mid.id) + { + case 0: + dcdr >> data.index(); + break; + + case 1: + dcdr >> data.message(); + break; + + default: + ret_value = false; + break; + } + return ret_value; + }); +} + +void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data) +{ + static_cast(scdr); + static_cast(data); +} + + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ + diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx index df22dd59..fb02e5c6 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.cxx @@ -16,27 +16,34 @@ * @file HelloWorldPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastcdrgen. + * This file was generated by the tool fastddsgen. */ -#include -#include +#include #include "HelloWorldPubSubTypes.h" +#include "HelloWorldCdrAux.hpp" 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"); - 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; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(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; + uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; m_keyBuffer = reinterpret_cast(malloc(keyLength)); memset(m_keyBuffer, 0, keyLength); } @@ -51,22 +58,31 @@ HelloWorldPubSubType::~HelloWorldPubSubType() bool HelloWorldPubSubType::serialize( void* data, - SerializedPayload_t* payload) + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) { 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); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 try { // Serialize encapsulation ser.serialize_encapsulation(); // Serialize the object. - p_type->serialize(ser); + ser << *p_type; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -74,7 +90,11 @@ bool HelloWorldPubSubType::serialize( } // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.get_serialized_data_length()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 return true; } @@ -91,15 +111,18 @@ bool HelloWorldPubSubType::deserialize( 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); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); // 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); + deser >> *p_type; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -110,12 +133,31 @@ bool HelloWorldPubSubType::deserialize( } std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data) + void* data, + DataRepresentationId_t data_representation) { - return [data]() -> uint32_t + return [data, data_representation]() -> uint32_t { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); 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 }; } @@ -144,15 +186,23 @@ bool HelloWorldPubSubType::getKey( // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld::getKeyMaxCdrSerializedSize()); + HelloWorld_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); - if (force_md5 || HelloWorld::getKeyMaxCdrSerializedSize() > 16) +#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(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); +#if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); +#else + m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); +#endif // FASTCDR_VERSION_MAJOR == 1 m_md5.finalize(); for (uint8_t i = 0; i < 16; ++i) { diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h index 2c9a6815..ddbfbab5 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldPubSubTypes.h @@ -16,56 +16,29 @@ * @file HelloWorldPubSubTypes.h * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastcdrgen. + * This file was generated by the tool fastddsgen. */ #ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ #define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#include #include +#include +#include #include #include "HelloWorld.h" -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#if !defined(GEN_API_VER) || (GEN_API_VER != 2) #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. @@ -79,27 +52,42 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport HelloWorldPubSubType(); - eProsima_user_DllExport virtual ~HelloWorldPubSubType() override; + eProsima_user_DllExport ~HelloWorldPubSubType() override; - eProsima_user_DllExport virtual bool serialize( + eProsima_user_DllExport bool serialize( void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport virtual bool deserialize( + eProsima_user_DllExport bool serialize( + void* data, eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, void* data) override; - eProsima_user_DllExport virtual bool getKey( + 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 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 void* createData() override; - eProsima_user_DllExport virtual void deleteData( + eProsima_user_DllExport void deleteData( void* data) override; #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED @@ -113,7 +101,14 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN eProsima_user_DllExport inline bool is_plain() const override { - return is_plain_impl(); + 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 @@ -122,8 +117,8 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport inline bool construct_sample( void* memory) const override { - new (memory) HelloWorld(); - return true; + static_cast(memory); + return false; } #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE @@ -131,15 +126,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType 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/HelloWorldv1.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.cxx new file mode 100644 index 00000000..3b9a562b --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.cxx @@ -0,0 +1,288 @@ +// 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 28ULL; + + + + +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; + + +} + + +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::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; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/HelloWorldv1.h new file mode 100644 index 00000000..4d6e4158 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/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::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 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_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md index 057c44b1..d824ad75 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md @@ -75,7 +75,7 @@ QoS options: Partitions to match separated by ';'. Single or double quotes required with multiple partitions. With empty string ('') no partitions used. (Default: ''). - -x --xml-profile= + -x --xml-profile Profile name to configure DomainParticipant. Discovery options: diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h index 17d481e2..4b1ec597 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/arg_configuration.h @@ -176,7 +176,7 @@ enum optionIndex PARTITIONS, OWNERSHIP_STRENGTH, OWNERSHIP, - PROFILE + PROFILE, }; const option::Descriptor usage[] = { @@ -231,7 +231,7 @@ const option::Descriptor usage[] = { " Single or double quotes required with multiple partitions." " With empty string ('') no partitions used. (Default: '')." }, { PROFILE, 0, "x", "xml-profile", Arg::String, - " -x \t--xml-profile= \tProfile name to configure DomainParticipant."}, + " -x \t--xml-profile \tProfile name to configure DomainParticipant."}, { UNKNOWN_OPT, 0, "", "", Arg::None, "\nDiscovery options:"}, { TTL, 0, "", "ttl", Arg::NumericRange<1, 255>,