From dfcb11c59ca8d8130da6c49f382e768308d916bc Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 22 Jan 2024 09:33:43 +0100 Subject: [PATCH] Compile test libraries in ddspipe_core Signed-off-by: Irene Bandera --- ddspipe_core/CMakeLists.txt | 15 +- .../arrays_and_sequencesTypeObject.h | 521 ++--------------- .../v1/type_objects/union_structPubSubTypes.h | 181 ++---- .../v1/type_objects/union_structTypeObject.h | 522 ++---------------- .../type_objects/union_structPubSubTypes.cxx | 1 - .../v2/type_objects/union_structPubSubTypes.h | 1 - 6 files changed, 151 insertions(+), 1090 deletions(-) diff --git a/ddspipe_core/CMakeLists.txt b/ddspipe_core/CMakeLists.txt index 4f759260..3b819f42 100644 --- a/ddspipe_core/CMakeLists.txt +++ b/ddspipe_core/CMakeLists.txt @@ -70,20 +70,7 @@ compile_library( # Test ############################################################################### # Compile tests if CMake options requires it - -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "/v2/") -else() - set(DDS_TYPES_VERSION "/v1/") -endif() - -file(GLOB_RECURSE TEST_FILES "${PROJECT_SOURCE_DIR}/test/") -foreach(TEST_FILE ${TEST_FILES}) - if(NOT TEST_FILE MATCHES ${DDS_TYPES_VERSION}) - compile_test_library(${TEST_FILE}) - endif() -endforeach() +compile_test_library("${PROJECT_SOURCE_DIR}/test/") ############################################################################### # Packaging diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h index b6e19eaf..4ad8329f 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h @@ -13,475 +13,60 @@ // limitations under the License. /*! - * @file arrays_and_sequencesTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. + * @file arrays_and_sequencesTypeObject.h + * This header file contains the declaration 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; } -#endif - -#include "arrays_and_sequences.h" -#include "arrays_and_sequencesTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerarrays_and_sequencesTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(true), - GetAnInternalObjectObject(true)); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(false), - GetAnInternalObjectObject(false)); - - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(true), - Getarrays_and_sequencesObject(true)); - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(false), - Getarrays_and_sequencesObject(false)); - -} - -const TypeIdentifier* GetAnInternalObjectIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetAnInternalObjectObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); -} - -const TypeObject* GetAnInternalObjectObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteAnInternalObjectObject(); - } - //else - return GetMinimalAnInternalObjectObject(); -} - -const TypeObject* GetMinimalAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_x; - mst_x.common().member_id(memberId++); - mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_x.common().member_flags().IS_OPTIONAL(false); - mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_x.common().member_flags().IS_KEY(false); - mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - MD5 x_hash("x"); - for(int i = 0; i < 4; ++i) - { - mst_x.detail().name_hash()[i] = x_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_x); - - MinimalStructMember mst_positive; - mst_positive.common().member_id(memberId++); - mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_positive.common().member_flags().IS_OPTIONAL(false); - mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_positive.common().member_flags().IS_KEY(false); - mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - MD5 positive_hash("positive"); - for(int i = 0; i < 4; ++i) - { - mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); - - - // Header - // 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); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); -} - -const TypeObject* GetCompleteAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_x; - cst_x.common().member_id(memberId++); - cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_x.common().member_flags().IS_OPTIONAL(false); - cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_x.common().member_flags().IS_KEY(false); - cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - cst_x.detail().name("x"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_x); - - CompleteStructMember cst_positive; - cst_positive.common().member_id(memberId++); - cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_positive.common().member_flags().IS_OPTIONAL(false); - cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_positive.common().member_flags().IS_KEY(false); - cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - cst_positive.detail().name("positive"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_positive); - - - // Header - type_object->complete().struct_type().header().detail().type_name("AnInternalObject"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); -} - -const TypeIdentifier* Getarrays_and_sequencesIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getarrays_and_sequencesObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); -} - -const TypeObject* Getarrays_and_sequencesObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletearrays_and_sequencesObject(); - } - //else - return GetMinimalarrays_and_sequencesObject(); -} - -const TypeObject* GetMinimalarrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_unlimited_vector; - mst_unlimited_vector.common().member_id(memberId++); - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - mst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_unlimited_vector.common().member_flags().IS_KEY(false); - mst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, false)); - - - MD5 unlimited_vector_hash("unlimited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_unlimited_vector.detail().name_hash()[i] = unlimited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_unlimited_vector); - - MinimalStructMember mst_limited_vector; - mst_limited_vector.common().member_id(memberId++); - mst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_vector.common().member_flags().IS_OPTIONAL(false); - mst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_vector.common().member_flags().IS_KEY(false); - mst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, false)); - - - MD5 limited_vector_hash("limited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_limited_vector.detail().name_hash()[i] = limited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_vector); - - MinimalStructMember mst_limited_array; - mst_limited_array.common().member_id(memberId++); - mst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_array.common().member_flags().IS_OPTIONAL(false); - mst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_array.common().member_flags().IS_KEY(false); - mst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, false)); - - - MD5 limited_array_hash("limited_array"); - for(int i = 0; i < 4; ++i) - { - mst_limited_array.detail().name_hash()[i] = limited_array_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_array); - - - // Header - // 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); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); -} - -const TypeObject* GetCompletearrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_unlimited_vector; - cst_unlimited_vector.common().member_id(memberId++); - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - cst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_unlimited_vector.common().member_flags().IS_KEY(false); - cst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, true)); - - - cst_unlimited_vector.detail().name("unlimited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_unlimited_vector); - - CompleteStructMember cst_limited_vector; - cst_limited_vector.common().member_id(memberId++); - cst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_vector.common().member_flags().IS_OPTIONAL(false); - cst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_vector.common().member_flags().IS_KEY(false); - cst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, true)); - - - cst_limited_vector.detail().name("limited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_vector); - - CompleteStructMember cst_limited_array; - cst_limited_array.common().member_id(memberId++); - cst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_array.common().member_flags().IS_OPTIONAL(false); - cst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_array.common().member_flags().IS_KEY(false); - cst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, true)); - - - cst_limited_array.detail().name("limited_array"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_array); - - - // Header - type_object->complete().struct_type().header().detail().type_name("arrays_and_sequences"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); -} +#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(arrays_and_sequences_SOURCE) +#define arrays_and_sequences_DllAPI __declspec( dllexport ) +#else +#define arrays_and_sequences_DllAPI __declspec( dllimport ) +#endif // arrays_and_sequences_SOURCE +#else +#define arrays_and_sequences_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define arrays_and_sequences_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerarrays_and_sequencesTypes(); + +eProsima_user_DllExport const TypeIdentifier* GetAnInternalObjectIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetAnInternalObjectObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalAnInternalObjectObject(); +eProsima_user_DllExport const TypeObject* GetCompleteAnInternalObjectObject(); + +eProsima_user_DllExport const TypeIdentifier* Getarrays_and_sequencesIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getarrays_and_sequencesObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalarrays_and_sequencesObject(); +eProsima_user_DllExport const TypeObject* GetCompletearrays_and_sequencesObject(); + + +#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h index c1812023..4e92f498 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h @@ -13,158 +13,93 @@ // limitations under the License. /*! - * @file union_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. + * @file union_structPubSubTypes.h + * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastcdrgen. */ -#include -#include +#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ -#include "union_structPubSubTypes.h" +#include +#include -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +#include "union_struct.h" -union_structPubSubType::union_structPubSubType() -{ - setName("union_struct"); - auto type_size = union_struct::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = union_struct::isKeyDefined(); - size_t keyLength = union_struct::getKeyMaxCdrSerializedSize() > 16 ? - union_struct::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -union_structPubSubType::~union_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated union_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER -bool union_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload) + + +/*! + * @brief This class represents the TopicDataType of the type union_struct defined by the user in the IDL file. + * @ingroup union_struct + */ +class union_structPubSubType : public eprosima::fastdds::dds::TopicDataType { - union_struct* p_type = static_cast(data); +public: - // 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; + typedef union_struct type; - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } + eProsima_user_DllExport union_structPubSubType(); - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} + eProsima_user_DllExport virtual ~union_structPubSubType() override; -bool union_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - union_struct* p_type = static_cast(data); + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + 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 false; } - return true; -} +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED -std::function union_structPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* union_structPubSubType::createData() -{ - return reinterpret_cast(new union_struct()); -} +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } -void union_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN -bool union_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override { + (void)memory; return false; } - union_struct* p_type = static_cast(data); +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - union_struct::getKeyMaxCdrSerializedSize()); + MD5 m_md5; + unsigned char* m_keyBuffer; - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || union_struct::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; -} +}; + +#endif // _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h index 8796c646..f341bb35 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h @@ -13,500 +13,56 @@ // limitations under the License. /*! - * @file union_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. + * @file union_structTypeObject.h + * This header file contains the declaration 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; } -#endif - -#include "union_struct.h" -#include "union_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerunion_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(true), - GetMyUnionObject(true)); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(false), - GetMyUnionObject(false)); - - factory->add_type_object("union_struct", Getunion_structIdentifier(true), - Getunion_structObject(true)); - factory->add_type_object("union_struct", Getunion_structIdentifier(false), - Getunion_structObject(false)); - - }); -} - -const TypeIdentifier* GetMyUnionIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMyUnionObject(complete); - return TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); -} - -const TypeObject* GetMyUnionObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMyUnionObject(); - } - // else - return GetMinimalMyUnionObject(); -} - -const TypeObject* GetMinimalMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_UNION); - - type_object->minimal().union_type().union_flags().IS_FINAL(false); - type_object->minimal().union_type().union_flags().IS_APPENDABLE(false); - type_object->minimal().union_type().union_flags().IS_MUTABLE(false); - type_object->minimal().union_type().union_flags().IS_NESTED(false); - type_object->minimal().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->minimal().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - MemberId memberId = 0; - MinimalUnionMember mst_octet_value; - mst_octet_value.common().member_id(memberId++); - mst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_DEFAULT(false); - mst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - - mst_octet_value.common().label_seq().emplace_back(1); - MD5 octet_value_hash("octet_value"); - for(int i = 0; i < 4; ++i) - { - mst_octet_value.detail().name_hash()[i] = octet_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_octet_value); - - MinimalUnionMember mst_long_value; - mst_long_value.common().member_id(memberId++); - mst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_long_value.common().member_flags().IS_DEFAULT(false); - mst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - mst_long_value.common().label_seq().emplace_back(2); - MD5 long_value_hash("long_value"); - for(int i = 0; i < 4; ++i) - { - mst_long_value.detail().name_hash()[i] = long_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_long_value); - - MinimalUnionMember mst_string_value; - mst_string_value.common().member_id(memberId++); - mst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_string_value.common().member_flags().IS_DEFAULT(false); - mst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - mst_string_value.common().label_seq().emplace_back(3); - MD5 string_value_hash("string_value"); - for(int i = 0; i < 4; ++i) - { - mst_string_value.detail().name_hash()[i] = string_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_string_value); - - - // Header - //type_object->minimal().union_type().header().detail()... // Empty - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalUnionType::getCdrSerializedSize(type_object->minimal().union_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); -} - -const TypeObject* GetCompleteMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_UNION); - - type_object->complete().union_type().union_flags().IS_FINAL(false); - type_object->complete().union_type().union_flags().IS_APPENDABLE(false); - type_object->complete().union_type().union_flags().IS_MUTABLE(false); - type_object->complete().union_type().union_flags().IS_NESTED(false); - type_object->complete().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->complete().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MemberId memberId = 0; - CompleteUnionMember cst_octet_value; - cst_octet_value.common().member_id(memberId++); - cst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_DEFAULT(false); - cst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - cst_octet_value.common().label_seq().emplace_back(1); - - cst_octet_value.detail().name("octet_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_octet_value); - - CompleteUnionMember cst_long_value; - cst_long_value.common().member_id(memberId++); - cst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_long_value.common().member_flags().IS_DEFAULT(false); - cst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - cst_long_value.common().label_seq().emplace_back(2); +#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ - cst_long_value.detail().name("long_value"); - type_object->complete().union_type().member_seq().emplace_back(cst_long_value); +#include +#include - CompleteUnionMember cst_string_value; - cst_string_value.common().member_id(memberId++); - cst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_string_value.common().member_flags().IS_DEFAULT(false); - cst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_string_value.common().label_seq().emplace_back(3); - - cst_string_value.detail().name("string_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_string_value); - - - // Header - type_object->complete().union_type().header().detail().type_name("MyUnion"); - - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteUnionType::getCdrSerializedSize(type_object->complete().union_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); -} - -const TypeIdentifier* Getunion_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getunion_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); -} - -const TypeObject* Getunion_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteunion_structObject(); - } - //else - return GetMinimalunion_structObject(); -} - -const TypeObject* GetMinimalunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_union_value; - mst_union_value.common().member_id(memberId++); - mst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_union_value.common().member_flags().IS_OPTIONAL(false); - mst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_union_value.common().member_flags().IS_KEY(false); - mst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_union_value.common().member_type_id(*GetMyUnionIdentifier(false)); - MD5 union_value_hash("union_value"); - for(int i = 0; i < 4; ++i) - { - mst_union_value.detail().name_hash()[i] = union_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_union_value); - - - // Header - // 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); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", false); -} - -const TypeObject* GetCompleteunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_union_value; - cst_union_value.common().member_id(memberId++); - cst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_union_value.common().member_flags().IS_OPTIONAL(false); - cst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_union_value.common().member_flags().IS_KEY(false); - cst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_union_value.common().member_type_id(*GetMyUnionIdentifier(true)); - cst_union_value.detail().name("union_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_union_value); +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif +#else +#define eProsima_user_DllExport +#endif +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(union_struct_SOURCE) +#define union_struct_DllAPI __declspec( dllexport ) +#else +#define union_struct_DllAPI __declspec( dllimport ) +#endif // union_struct_SOURCE +#else +#define union_struct_DllAPI +#endif +#else +#define union_struct_DllAPI +#endif // _WIN32 - // Header - type_object->complete().struct_type().header().detail().type_name("union_struct"); - // TODO inheritance +using namespace eprosima::fastrtps::types; +eProsima_user_DllExport void registerunion_structTypes(); - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); +eProsima_user_DllExport const TypeIdentifier* GetMyUnionIdentifier(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMyUnionObject(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalMyUnionObject(); +eProsima_user_DllExport const TypeObject* GetCompleteMyUnionObject(); - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; +eProsima_user_DllExport const TypeIdentifier* Getunion_structIdentifier(bool complete = false); +eProsima_user_DllExport const TypeObject* Getunion_structObject(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalunion_structObject(); +eProsima_user_DllExport const TypeObject* GetCompleteunion_structObject(); - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", true); -} +#endif // _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx index 6920b659..35732fdd 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx @@ -222,4 +222,3 @@ bool union_structPubSubType::getKey( } return true; } - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h index c688a939..ca9f95d0 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h @@ -133,4 +133,3 @@ class union_structPubSubType : public eprosima::fastdds::dds::TopicDataType }; #endif // _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ -