diff --git a/src/cpp/fastdds/topic/DDSSQLFilter/DDSFilterExpressionParserImpl/identifiers.hpp b/src/cpp/fastdds/topic/DDSSQLFilter/DDSFilterExpressionParserImpl/identifiers.hpp index fd179809cb4..98412f3191c 100644 --- a/src/cpp/fastdds/topic/DDSSQLFilter/DDSFilterExpressionParserImpl/identifiers.hpp +++ b/src/cpp/fastdds/topic/DDSSQLFilter/DDSFilterExpressionParserImpl/identifiers.hpp @@ -180,6 +180,12 @@ struct identifier_processor { return DDSFilterValue::ValueKind::ENUM; } + if (TK_ALIAS == type_object->complete()._d()) + { + const TypeIdentifier& aliasedId = + type_object->complete().alias_type().body().common().related_type(); + return get_value_kind(aliasedId, pos); + } break; } diff --git a/test/blackbox/CMakeLists.txt b/test/blackbox/CMakeLists.txt index 8009a741fe2..45b66542629 100644 --- a/test/blackbox/CMakeLists.txt +++ b/test/blackbox/CMakeLists.txt @@ -292,6 +292,11 @@ set(BLACKBOXTESTS_SOURCE ${BLACKBOXTESTS_TEST_SOURCE} types/KeyedData1mbPubSubTypes.cxx types/FixedSized.cxx types/FixedSizedPubSubTypes.cxx + types/TestIncludeRegression3361.cxx + types/TestIncludeRegression3361TypeObject.cxx + types/TestRegression3361.cxx + types/TestRegression3361PubSubTypes.cxx + types/TestRegression3361TypeObject.cxx utils/data_generators.cpp utils/lambda_functions.cpp diff --git a/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp b/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp index fbdec3aa5f6..77cc5813631 100644 --- a/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp +++ b/test/blackbox/common/DDSBlackboxTestsContentFilter.cpp @@ -31,6 +31,8 @@ #include "PubSubWriter.hpp" #include "../types/HelloWorldTypeObject.h" +#include "../types/TestRegression3361PubSubTypes.h" +#include "../types/TestRegression3361TypeObject.h" namespace eprosima { namespace fastdds { @@ -576,6 +578,46 @@ TEST_P(DDSContentFilter, WithLimitsDynamicReaders) state.send_data(reader_4, filter_counter, 3u, { 2, 3, 4 }, true, 2u); } +//! Regression test for https://github.com/eProsima/Fast-DDS/issues/3361 +//! Correctly resolve an alias defined in another header +TEST(DDSContentFilter, CorrectlyHandleAliasOtherHeader) +{ + registerTestRegression3361Types(); + + auto dpf = DomainParticipantFactory::get_instance(); + + auto participant = dpf->create_participant(0, PARTICIPANT_QOS_DEFAULT); + + TypeSupport type( new TestRegression3361PubSubType()); + + auto ret = type.register_type(participant); + + if (ret != ReturnCode_t::RETCODE_OK) + { + throw std::runtime_error("Failed to register type"); + } + + auto sub = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, nullptr); + if (sub == nullptr) + { + throw std::runtime_error("Failed to create subscriber"); + } + + auto topic = participant->create_topic("TestTopic", type->getName(), TOPIC_QOS_DEFAULT); + if (topic == nullptr) + { + throw std::runtime_error("Failed to create topic"); + } + + std::string expression = "uuid <> %0"; + std::vector parameters = {"'1235'"}; + + auto filtered_topic = participant->create_contentfilteredtopic( + "FilteredTestTopic", topic, expression, parameters); + + EXPECT_NE(nullptr, filtered_topic); +} + #ifdef INSTANTIATE_TEST_SUITE_P #define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_SUITE_P(x, y, z, w) #else diff --git a/test/blackbox/types/TestIncludeRegression3361.cxx b/test/blackbox/types/TestIncludeRegression3361.cxx new file mode 100644 index 00000000000..8e1641dd1e1 --- /dev/null +++ b/test/blackbox/types/TestIncludeRegression3361.cxx @@ -0,0 +1,36 @@ +// 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 TestIncludeRegression3361.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "TestIncludeRegression3361.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + diff --git a/test/blackbox/types/TestIncludeRegression3361.h b/test/blackbox/types/TestIncludeRegression3361.h new file mode 100644 index 00000000000..a227f3f6d33 --- /dev/null +++ b/test/blackbox/types/TestIncludeRegression3361.h @@ -0,0 +1,70 @@ +// 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 TestIncludeRegression3361.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_H_ +#define _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_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(TestIncludeRegression3361_SOURCE) +#define TestIncludeRegression3361_DllAPI __declspec( dllexport ) +#else +#define TestIncludeRegression3361_DllAPI __declspec( dllimport ) +#endif // TestIncludeRegression3361_SOURCE +#else +#define TestIncludeRegression3361_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define TestIncludeRegression3361_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +namespace TestModule { +typedef std::string MACHINEID; +} // namespace TestModule + +#endif // _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_H_ \ No newline at end of file diff --git a/test/blackbox/types/TestIncludeRegression3361.idl b/test/blackbox/types/TestIncludeRegression3361.idl new file mode 100644 index 00000000000..2ad3b719d25 --- /dev/null +++ b/test/blackbox/types/TestIncludeRegression3361.idl @@ -0,0 +1,10 @@ +#ifndef TESTINCLUDE_REGRESSION_3361 +#define TESTINCLUDE_REGRESSION_3361 + +module TestModule { + +typedef string MACHINEID; + +}; + +#endif // TESTINCLUDE_REGRESSION_3361 diff --git a/test/blackbox/types/TestIncludeRegression3361TypeObject.cxx b/test/blackbox/types/TestIncludeRegression3361TypeObject.cxx new file mode 100644 index 00000000000..87f46596e5d --- /dev/null +++ b/test/blackbox/types/TestIncludeRegression3361TypeObject.cxx @@ -0,0 +1,239 @@ +// 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 TestIncludeRegression3361TypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "TestIncludeRegression3361.h" +#include "TestIncludeRegression3361TypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerTestIncludeRegression3361Types() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("TestModule::MACHINEID", TestModule::GetMACHINEIDIdentifier(true), + TestModule::GetMACHINEIDObject(true)); + factory->add_type_object("TestModule::MACHINEID", TestModule::GetMACHINEIDIdentifier(false), + TestModule::GetMACHINEIDObject(false)); + + +} + +namespace TestModule { + const TypeIdentifier* GetMACHINEIDIdentifier(bool complete) + { + const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MACHINEID", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetMACHINEIDObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("MACHINEID", complete); + } + + const TypeObject* GetMACHINEIDObject(bool complete) + { + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MACHINEID", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteMACHINEIDObject(); + } + else + { + return GetMinimalMACHINEIDObject(); + } + } + + const TypeObject* GetMinimalMACHINEIDObject() + { + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MACHINEID", 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_ALIAS); + + // No flags apply + //type_object->minimal().alias_type().alias_flags().IS_FINAL(false); + //type_object->minimal().alias_type().alias_flags().IS_APPENDABLE(false); + //type_object->minimal().alias_type().alias_flags().IS_MUTABLE(false); + //type_object->minimal().alias_type().alias_flags().IS_NESTED(false); + //type_object->minimal().alias_type().alias_flags().IS_AUTOID_HASH(false); + + // type_object->minimal().alias_type().header()... Is empty + + // No flags apply + //type_object->minimal().alias_type().body().common().related_flags().TRY_CONSTRUCT1(false); + //type_object->minimal().alias_type().body().common().related_flags().TRY_CONSTRUCT2(false); + //type_object->minimal().alias_type().body().common().related_flags().IS_EXTERNAL(false); + //type_object->minimal().alias_type().body().common().related_flags().IS_OPTIONAL(false); + //type_object->minimal().alias_type().body().common().related_flags().IS_MUST_UNDERSTAND(false); + //type_object->minimal().alias_type().body().common().related_flags().IS_KEY(false); + //type_object->minimal().alias_type().body().common().related_flags().IS_DEFAULT(false); + + // Must be defined already, if don't, may be an recursive alias + const TypeIdentifier *relatedType = TypeObjectFactory::get_instance()->get_type_identifier(TypeNamesGenerator::get_string_type_name(255, false), false); + + + if (relatedType != nullptr) + { + type_object->minimal().alias_type().body().common().related_type() = *relatedType; // Make a copy + } + else + { + // Cannot determine base type + delete type_object; + return nullptr; + } + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalAliasType::getCdrSerializedSize(type_object->minimal().alias_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]; + } + + // Don't add our TypeIdentifier but our alias + TypeObjectFactory::get_instance()->add_alias("MACHINEID", TypeNamesGenerator::get_string_type_name(255, false)); + + TypeObjectFactory::get_instance()->add_type_object("MACHINEID", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("MACHINEID", false); + } + + const TypeObject* GetCompleteMACHINEIDObject() + { + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MACHINEID", 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_ALIAS); + + // No flags apply + //type_object->complete().alias_type().alias_flags().IS_FINAL(false); + //type_object->complete().alias_type().alias_flags().IS_APPENDABLE(false); + //type_object->complete().alias_type().alias_flags().IS_MUTABLE(false); + //type_object->complete().alias_type().alias_flags().IS_NESTED(false); + //type_object->complete().alias_type().alias_flags().IS_AUTOID_HASH(false); + + //type_object->complete().alias_type().header().detail().ann_builtin().verbatim().placement("placement"); + //type_object->complete().alias_type().header().detail().ann_builtin().verbatim().language("language"); + //type_object->complete().alias_type().header().detail().ann_builtin().verbatim().text("text"); + //type_object->complete().alias_type().header().detail().ann_custom().push_back(...); + type_object->complete().alias_type().header().detail().type_name("MACHINEID"); + + // No flags apply + //type_object->complete().alias_type().body().common().related_flags().TRY_CONSTRUCT1(false); + //type_object->complete().alias_type().body().common().related_flags().TRY_CONSTRUCT2(false); + //type_object->complete().alias_type().body().common().related_flags().IS_EXTERNAL(false); + //type_object->complete().alias_type().body().common().related_flags().IS_OPTIONAL(false); + //type_object->complete().alias_type().body().common().related_flags().IS_MUST_UNDERSTAND(false); + //type_object->complete().alias_type().body().common().related_flags().IS_KEY(false); + //type_object->complete().alias_type().body().common().related_flags().IS_DEFAULT(false); + + //type_object->complete().alias_type().body().common().ann_builtin() + //type_object->complete().alias_type().body().common().ann_custom() + + // Must be defined already, if don't, may be an recursive alias + const TypeIdentifier *relatedType = TypeObjectFactory::get_instance()->get_type_identifier_trying_complete(TypeNamesGenerator::get_string_type_name(255, false)); + + + if (relatedType != nullptr) + { + type_object->complete().alias_type().body().common().related_type() = *relatedType; // Make a copy + } + else + { + // Cannot determine base type + delete type_object; + return nullptr; + } + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteAliasType::getCdrSerializedSize(type_object->complete().alias_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]; + } + + // Don't add our TypeIdentifier but our alias + TypeObjectFactory::get_instance()->add_alias("MACHINEID", TypeNamesGenerator::get_string_type_name(255, false)); + + TypeObjectFactory::get_instance()->add_type_object("MACHINEID", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("MACHINEID", true); + } + +} // namespace TestModule \ No newline at end of file diff --git a/test/blackbox/types/TestIncludeRegression3361TypeObject.h b/test/blackbox/types/TestIncludeRegression3361TypeObject.h new file mode 100644 index 00000000000..8162e40e7ee --- /dev/null +++ b/test/blackbox/types/TestIncludeRegression3361TypeObject.h @@ -0,0 +1,67 @@ +// 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 TestIncludeRegression3361TypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_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(TestIncludeRegression3361_SOURCE) +#define TestIncludeRegression3361_DllAPI __declspec( dllexport ) +#else +#define TestIncludeRegression3361_DllAPI __declspec( dllimport ) +#endif // TestIncludeRegression3361_SOURCE +#else +#define TestIncludeRegression3361_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define TestIncludeRegression3361_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerTestIncludeRegression3361Types(); + +namespace TestModule { +eProsima_user_DllExport const TypeIdentifier* GetMACHINEIDIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMACHINEIDObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalMACHINEIDObject(); +eProsima_user_DllExport const TypeObject* GetCompleteMACHINEIDObject(); + +} // namespace TestModule + +#endif // _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/test/blackbox/types/TestRegression3361.cxx b/test/blackbox/types/TestRegression3361.cxx new file mode 100644 index 00000000000..d7d8feb118a --- /dev/null +++ b/test/blackbox/types/TestRegression3361.cxx @@ -0,0 +1,187 @@ +// 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 TestRegression3361.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "TestRegression3361.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +TestRegression3361::TestRegression3361() +{ + // m_uuid com.eprosima.idl.parser.typecode.AliasTypeCode@212bf671 + m_uuid =""; + +} + +TestRegression3361::~TestRegression3361() +{ +} + +TestRegression3361::TestRegression3361( + const TestRegression3361& x) +{ + m_uuid = x.m_uuid; +} + +TestRegression3361::TestRegression3361( + TestRegression3361&& x) +{ + m_uuid = std::move(x.m_uuid); +} + +TestRegression3361& TestRegression3361::operator =( + const TestRegression3361& x) +{ + + m_uuid = x.m_uuid; + + return *this; +} + +TestRegression3361& TestRegression3361::operator =( + TestRegression3361&& x) +{ + + m_uuid = std::move(x.m_uuid); + + return *this; +} + +bool TestRegression3361::operator ==( + const TestRegression3361& x) const +{ + + return (m_uuid == x.m_uuid); +} + +bool TestRegression3361::operator !=( + const TestRegression3361& x) const +{ + return !(*this == x); +} + +size_t TestRegression3361::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1; + + return current_alignment - initial_alignment; +} + +size_t TestRegression3361::getCdrSerializedSize( + const TestRegression3361& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.uuid().size() + 1; + + return current_alignment - initial_alignment; +} + +void TestRegression3361::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_uuid.c_str(); + +} + +void TestRegression3361::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_uuid;} + +/*! + * @brief This function copies the value in member uuid + * @param _uuid New value to be copied in member uuid + */ +void TestRegression3361::uuid( + const TestModule::MACHINEID& _uuid) +{ + m_uuid = _uuid; +} + +/*! + * @brief This function moves the value in member uuid + * @param _uuid New value to be moved in member uuid + */ +void TestRegression3361::uuid( + TestModule::MACHINEID&& _uuid) +{ + m_uuid = std::move(_uuid); +} + +/*! + * @brief This function returns a constant reference to member uuid + * @return Constant reference to member uuid + */ +const TestModule::MACHINEID& TestRegression3361::uuid() const +{ + return m_uuid; +} + +/*! + * @brief This function returns a reference to member uuid + * @return Reference to member uuid + */ +TestModule::MACHINEID& TestRegression3361::uuid() +{ + return m_uuid; +} + +size_t TestRegression3361::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + return current_align; +} + +bool TestRegression3361::isKeyDefined() +{ + return false; +} + +void TestRegression3361::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/test/blackbox/types/TestRegression3361.h b/test/blackbox/types/TestRegression3361.h new file mode 100644 index 00000000000..5d2ca62320f --- /dev/null +++ b/test/blackbox/types/TestRegression3361.h @@ -0,0 +1,215 @@ +// 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 TestRegression3361.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_TESTREGRESSION3361_H_ +#define _FAST_DDS_GENERATED_TESTREGRESSION3361_H_ + +#include "TestIncludeRegression3361.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(TestRegression3361_SOURCE) +#define TestRegression3361_DllAPI __declspec( dllexport ) +#else +#define TestRegression3361_DllAPI __declspec( dllimport ) +#endif // TestRegression3361_SOURCE +#else +#define TestRegression3361_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define TestRegression3361_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure TestRegression3361 defined by the user in the IDL file. + * @ingroup TESTREGRESSION3361 + */ +class TestRegression3361 +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport TestRegression3361(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~TestRegression3361(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object TestRegression3361 that will be copied. + */ + eProsima_user_DllExport TestRegression3361( + const TestRegression3361& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object TestRegression3361 that will be copied. + */ + eProsima_user_DllExport TestRegression3361( + TestRegression3361&& x); + + /*! + * @brief Copy assignment. + * @param x Reference to the object TestRegression3361 that will be copied. + */ + eProsima_user_DllExport TestRegression3361& operator =( + const TestRegression3361& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object TestRegression3361 that will be copied. + */ + eProsima_user_DllExport TestRegression3361& operator =( + TestRegression3361&& x); + + /*! + * @brief Comparison operator. + * @param x TestRegression3361 object to compare. + */ + eProsima_user_DllExport bool operator ==( + const TestRegression3361& x) const; + + /*! + * @brief Comparison operator. + * @param x TestRegression3361 object to compare. + */ + eProsima_user_DllExport bool operator !=( + const TestRegression3361& x) const; + + /*! + * @brief This function copies the value in member uuid + * @param _uuid New value to be copied in member uuid + */ + eProsima_user_DllExport void uuid( + const TestModule::MACHINEID& _uuid); + + /*! + * @brief This function moves the value in member uuid + * @param _uuid New value to be moved in member uuid + */ + eProsima_user_DllExport void uuid( + TestModule::MACHINEID&& _uuid); + + /*! + * @brief This function returns a constant reference to member uuid + * @return Constant reference to member uuid + */ + eProsima_user_DllExport const TestModule::MACHINEID& uuid() const; + + /*! + * @brief This function returns a reference to member uuid + * @return Reference to member uuid + */ + eProsima_user_DllExport TestModule::MACHINEID& uuid(); + + /*! + * @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 TestRegression3361& 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: + + TestModule::MACHINEID m_uuid; +}; + +#endif // _FAST_DDS_GENERATED_TESTREGRESSION3361_H_ \ No newline at end of file diff --git a/test/blackbox/types/TestRegression3361.idl b/test/blackbox/types/TestRegression3361.idl new file mode 100644 index 00000000000..bfdef2d9080 --- /dev/null +++ b/test/blackbox/types/TestRegression3361.idl @@ -0,0 +1,10 @@ +#ifndef TEST_REGRESSION_3361 +#define TEST_REGRESSION_3361 + +#include "TestIncludeRegression3361.idl" + +struct TestRegression3361 { + TestModule::MACHINEID uuid; +}; + +#endif // TEST_REGRESSION_3361 diff --git a/test/blackbox/types/TestRegression3361PubSubTypes.cxx b/test/blackbox/types/TestRegression3361PubSubTypes.cxx new file mode 100644 index 00000000000..f179a0c9fc8 --- /dev/null +++ b/test/blackbox/types/TestRegression3361PubSubTypes.cxx @@ -0,0 +1,170 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file TestRegression3361PubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "TestRegression3361PubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +TestRegression3361PubSubType::TestRegression3361PubSubType() +{ + setName("TestRegression3361"); + auto type_size = TestRegression3361::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = TestRegression3361::isKeyDefined(); + size_t keyLength = TestRegression3361::getKeyMaxCdrSerializedSize() > 16 ? + TestRegression3361::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +TestRegression3361PubSubType::~TestRegression3361PubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool TestRegression3361PubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + TestRegression3361* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool TestRegression3361PubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + TestRegression3361* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function TestRegression3361PubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* TestRegression3361PubSubType::createData() +{ + return reinterpret_cast(new TestRegression3361()); +} + +void TestRegression3361PubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool TestRegression3361PubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + TestRegression3361* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + TestRegression3361::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || TestRegression3361::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + diff --git a/test/blackbox/types/TestRegression3361PubSubTypes.h b/test/blackbox/types/TestRegression3361PubSubTypes.h new file mode 100644 index 00000000000..73bb3f38fd5 --- /dev/null +++ b/test/blackbox/types/TestRegression3361PubSubTypes.h @@ -0,0 +1,101 @@ +// 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 TestRegression3361PubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_TESTREGRESSION3361_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_TESTREGRESSION3361_PUBSUBTYPES_H_ + +#include +#include + +#include "TestRegression3361.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated TestRegression3361 is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type TestRegression3361 defined by the user in the IDL file. + * @ingroup TESTREGRESSION3361 + */ +class TestRegression3361PubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef TestRegression3361 type; + + eProsima_user_DllExport TestRegression3361PubSubType(); + + eProsima_user_DllExport virtual ~TestRegression3361PubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_TESTREGRESSION3361_PUBSUBTYPES_H_ \ No newline at end of file diff --git a/test/blackbox/types/TestRegression3361TypeObject.cxx b/test/blackbox/types/TestRegression3361TypeObject.cxx new file mode 100644 index 00000000000..27d27ccd4ba --- /dev/null +++ b/test/blackbox/types/TestRegression3361TypeObject.cxx @@ -0,0 +1,217 @@ +// 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 TestRegression3361TypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "TestRegression3361.h" +#include "TestRegression3361TypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerTestRegression3361Types() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("TestModule::MACHINEID", TestModule::GetMACHINEIDIdentifier(true), + TestModule::GetMACHINEIDObject(true)); + factory->add_type_object("TestModule::MACHINEID", TestModule::GetMACHINEIDIdentifier(false), + TestModule::GetMACHINEIDObject(false)); + + + factory->add_type_object("TestRegression3361", GetTestRegression3361Identifier(true), + GetTestRegression3361Object(true)); + factory->add_type_object("TestRegression3361", GetTestRegression3361Identifier(false), + GetTestRegression3361Object(false)); + +} + +const TypeIdentifier* GetTestRegression3361Identifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("TestRegression3361", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetTestRegression3361Object(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("TestRegression3361", complete); +} + +const TypeObject* GetTestRegression3361Object(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TestRegression3361", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteTestRegression3361Object(); + } + //else + return GetMinimalTestRegression3361Object(); +} + +const TypeObject* GetMinimalTestRegression3361Object() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TestRegression3361", 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_uuid; + mst_uuid.common().member_id(memberId++); + mst_uuid.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_uuid.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_uuid.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_uuid.common().member_flags().IS_OPTIONAL(false); + mst_uuid.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_uuid.common().member_flags().IS_KEY(false); + mst_uuid.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_uuid.common().member_type_id(*TestModule::GetMACHINEIDIdentifier(false)); + MD5 uuid_hash("uuid"); + for(int i = 0; i < 4; ++i) + { + mst_uuid.detail().name_hash()[i] = uuid_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_uuid); + + + // 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("TestRegression3361", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("TestRegression3361", false); +} + +const TypeObject* GetCompleteTestRegression3361Object() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TestRegression3361", 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_uuid; + cst_uuid.common().member_id(memberId++); + cst_uuid.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_uuid.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_uuid.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_uuid.common().member_flags().IS_OPTIONAL(false); + cst_uuid.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_uuid.common().member_flags().IS_KEY(false); + cst_uuid.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_uuid.common().member_type_id(*TestModule::GetMACHINEIDIdentifier(true)); + cst_uuid.detail().name("uuid"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_uuid); + + + // Header + type_object->complete().struct_type().header().detail().type_name("TestRegression3361"); + // 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("TestRegression3361", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("TestRegression3361", true); +} diff --git a/test/blackbox/types/TestRegression3361TypeObject.h b/test/blackbox/types/TestRegression3361TypeObject.h new file mode 100644 index 00000000000..e6cb5c7fbc3 --- /dev/null +++ b/test/blackbox/types/TestRegression3361TypeObject.h @@ -0,0 +1,66 @@ +// 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 TestRegression3361TypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_TESTREGRESSION3361_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_TESTREGRESSION3361_TYPE_OBJECT_H_ + +#include "TestIncludeRegression3361TypeObject.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(TestRegression3361_SOURCE) +#define TestRegression3361_DllAPI __declspec( dllexport ) +#else +#define TestRegression3361_DllAPI __declspec( dllimport ) +#endif // TestRegression3361_SOURCE +#else +#define TestRegression3361_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define TestRegression3361_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerTestRegression3361Types(); + +eProsima_user_DllExport const TypeIdentifier* GetTestRegression3361Identifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetTestRegression3361Object( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalTestRegression3361Object(); +eProsima_user_DllExport const TypeObject* GetCompleteTestRegression3361Object(); + + +#endif // _FAST_DDS_GENERATED_TESTREGRESSION3361_TYPE_OBJECT_H_ \ No newline at end of file