diff --git a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationPubSubTypes.cxx b/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationPubSubTypes.cxx deleted file mode 100644 index 1f39315124a..00000000000 --- a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 AdvancedConfigurationPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "AdvancedConfigurationPubSubTypes.h" - -#include -#include - -#include "AdvancedConfigurationCdrAux.hpp" -#include "AdvancedConfigurationTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -AdvancedConfigurationPubSubType::AdvancedConfigurationPubSubType() -{ - setName("AdvancedConfiguration"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(AdvancedConfiguration::getMaxCdrSerializedSize()); -#else - AdvancedConfiguration_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = AdvancedConfiguration_max_key_cdr_typesize > 16 ? AdvancedConfiguration_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -AdvancedConfigurationPubSubType::~AdvancedConfigurationPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool AdvancedConfigurationPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - AdvancedConfiguration* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool AdvancedConfigurationPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - AdvancedConfiguration* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function AdvancedConfigurationPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* AdvancedConfigurationPubSubType::createData() -{ - return reinterpret_cast(new AdvancedConfiguration()); -} - -void AdvancedConfigurationPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool AdvancedConfigurationPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - AdvancedConfiguration* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - AdvancedConfiguration_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || AdvancedConfiguration_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void AdvancedConfigurationPubSubType::register_type_object_representation() -{ - register_AdvancedConfiguration_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "AdvancedConfigurationCdrAux.ipp" diff --git a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationPubSubTypes.h b/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationPubSubTypes.h deleted file mode 100644 index a34a56358e2..00000000000 --- a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 AdvancedConfigurationPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_ADVANCEDCONFIGURATION_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_ADVANCEDCONFIGURATION_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "AdvancedConfiguration.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated AdvancedConfiguration 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 AdvancedConfiguration defined by the user in the IDL file. - * @ingroup AdvancedConfiguration - */ -class AdvancedConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef AdvancedConfiguration type; - - eProsima_user_DllExport AdvancedConfigurationPubSubType(); - - eProsima_user_DllExport ~AdvancedConfigurationPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_ADVANCEDCONFIGURATION_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationTypeObjectSupport.cxx b/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationTypeObjectSupport.cxx deleted file mode 100644 index 1402c7ada5c..00000000000 --- a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationTypeObjectSupport.cxx +++ /dev/null @@ -1,226 +0,0 @@ -// 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 AdvancedConfigurationTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "AdvancedConfigurationTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AdvancedConfiguration.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_AdvancedConfiguration_type_identifier( - TypeIdentifierPair& type_ids_AdvancedConfiguration) -{ - - ReturnCode_t return_code_AdvancedConfiguration {eprosima::fastdds::dds::RETCODE_OK}; - return_code_AdvancedConfiguration = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "AdvancedConfiguration", type_ids_AdvancedConfiguration); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_AdvancedConfiguration) - { - StructTypeFlag struct_flags_AdvancedConfiguration = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_AdvancedConfiguration = "AdvancedConfiguration"; - eprosima::fastcdr::optional type_ann_builtin_AdvancedConfiguration; - eprosima::fastcdr::optional ann_custom_AdvancedConfiguration; - CompleteTypeDetail detail_AdvancedConfiguration = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_AdvancedConfiguration, ann_custom_AdvancedConfiguration, type_name_AdvancedConfiguration.to_string()); - CompleteStructHeader header_AdvancedConfiguration; - header_AdvancedConfiguration = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_AdvancedConfiguration); - CompleteStructMemberSeq member_seq_AdvancedConfiguration; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_AdvancedConfiguration.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_AdvancedConfiguration); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_AdvancedConfiguration, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_array_char_20", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_char", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Array element TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - bool element_identifier_anonymous_array_char_20_ec {false}; - TypeIdentifier* element_identifier_anonymous_array_char_20 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, element_identifier_anonymous_array_char_20_ec))}; - if (!element_identifier_anonymous_array_char_20_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); - return; - } - EquivalenceKind equiv_kind_anonymous_array_char_20 = EK_COMPLETE; - if (TK_NONE == type_ids_message.type_identifier2()._d()) - { - equiv_kind_anonymous_array_char_20 = EK_BOTH; - } - CollectionElementFlag element_flags_anonymous_array_char_20 = 0; - PlainCollectionHeader header_anonymous_array_char_20 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_char_20, element_flags_anonymous_array_char_20); - { - SBoundSeq array_bound_seq; - TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(20)); - - PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_char_20, array_bound_seq, - eprosima::fastcdr::external(element_identifier_anonymous_array_char_20)); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_char_20", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_array_char_20 already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_AdvancedConfiguration.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_AdvancedConfiguration); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_AdvancedConfiguration, member_message); - } - { - TypeIdentifierPair type_ids_data; - ReturnCode_t return_code_data {eprosima::fastdds::dds::RETCODE_OK}; - return_code_data = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_sequence_uint8_t_unbounded", type_ids_data); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_data) - { - return_code_data = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_data); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_data) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Sequence element TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - bool element_identifier_anonymous_sequence_uint8_t_unbounded_ec {false}; - TypeIdentifier* element_identifier_anonymous_sequence_uint8_t_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_data, element_identifier_anonymous_sequence_uint8_t_unbounded_ec))}; - if (!element_identifier_anonymous_sequence_uint8_t_unbounded_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); - return; - } - EquivalenceKind equiv_kind_anonymous_sequence_uint8_t_unbounded = EK_COMPLETE; - if (TK_NONE == type_ids_data.type_identifier2()._d()) - { - equiv_kind_anonymous_sequence_uint8_t_unbounded = EK_BOTH; - } - CollectionElementFlag element_flags_anonymous_sequence_uint8_t_unbounded = 0; - PlainCollectionHeader header_anonymous_sequence_uint8_t_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_uint8_t_unbounded, element_flags_anonymous_sequence_uint8_t_unbounded); - { - SBound bound = 0; - PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_uint8_t_unbounded, bound, - eprosima::fastcdr::external(element_identifier_anonymous_sequence_uint8_t_unbounded)); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_uint8_t_unbounded", type_ids_data)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_sequence_uint8_t_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_data = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_data = 0x00000002; - bool common_data_ec {false}; - CommonStructMember common_data {TypeObjectUtils::build_common_struct_member(member_id_data, member_flags_data, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_data, common_data_ec))}; - if (!common_data_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure data member TypeIdentifier inconsistent."); - return; - } - MemberName name_data = "data"; - eprosima::fastcdr::optional member_ann_builtin_data; - ann_custom_AdvancedConfiguration.reset(); - CompleteMemberDetail detail_data = TypeObjectUtils::build_complete_member_detail(name_data, member_ann_builtin_data, ann_custom_AdvancedConfiguration); - CompleteStructMember member_data = TypeObjectUtils::build_complete_struct_member(common_data, detail_data); - TypeObjectUtils::add_complete_struct_member(member_seq_AdvancedConfiguration, member_data); - } - CompleteStructType struct_type_AdvancedConfiguration = TypeObjectUtils::build_complete_struct_type(struct_flags_AdvancedConfiguration, header_AdvancedConfiguration, member_seq_AdvancedConfiguration); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_AdvancedConfiguration, type_name_AdvancedConfiguration.to_string(), type_ids_AdvancedConfiguration)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "AdvancedConfiguration already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationTypeObjectSupport.hpp b/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationTypeObjectSupport.hpp deleted file mode 100644 index 0766bc97e14..00000000000 --- a/examples/cpp/dds/AdvancedConfigurationExample/AdvancedConfigurationTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 AdvancedConfigurationTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_ADVANCEDCONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_ADVANCEDCONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register AdvancedConfiguration related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_AdvancedConfiguration_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_ADVANCEDCONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/BasicConfigurationExample/HelloWorldPubSubTypes.cxx b/examples/cpp/dds/BasicConfigurationExample/HelloWorldPubSubTypes.cxx deleted file mode 100644 index aa161b2e163..00000000000 --- a/examples/cpp/dds/BasicConfigurationExample/HelloWorldPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldPubSubTypes.h" - -#include -#include - -#include "HelloWorldCdrAux.hpp" -#include "HelloWorldTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -HelloWorldPubSubType::HelloWorldPubSubType() -{ - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloWorldPubSubType::~HelloWorldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloWorldPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* HelloWorldPubSubType::createData() -{ - return reinterpret_cast(new HelloWorld()); -} - -void HelloWorldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloWorldPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void HelloWorldPubSubType::register_type_object_representation() -{ - register_HelloWorld_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" diff --git a/examples/cpp/dds/BasicConfigurationExample/HelloWorldPubSubTypes.h b/examples/cpp/dds/BasicConfigurationExample/HelloWorldPubSubTypes.h deleted file mode 100644 index 4b09a679ee5..00000000000 --- a/examples/cpp/dds/BasicConfigurationExample/HelloWorldPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorldPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - -/*! - * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport ~HelloWorldPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/BasicConfigurationExample/HelloWorldTypeObjectSupport.cxx b/examples/cpp/dds/BasicConfigurationExample/HelloWorldTypeObjectSupport.cxx deleted file mode 100644 index 83279c5d000..00000000000 --- a/examples/cpp/dds/BasicConfigurationExample/HelloWorldTypeObjectSupport.cxx +++ /dev/null @@ -1,164 +0,0 @@ -// 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 HelloWorldTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_HelloWorld_type_identifier( - TypeIdentifierPair& type_ids_HelloWorld) -{ - - ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; - return_code_HelloWorld = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "HelloWorld", type_ids_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) - { - StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_HelloWorld = "HelloWorld"; - eprosima::fastcdr::optional type_ann_builtin_HelloWorld; - eprosima::fastcdr::optional ann_custom_HelloWorld; - CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); - CompleteStructHeader header_HelloWorld; - header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); - CompleteStructMemberSeq member_seq_HelloWorld; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_array_char_20", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_char", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Array element TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - bool element_identifier_anonymous_array_char_20_ec {false}; - TypeIdentifier* element_identifier_anonymous_array_char_20 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, element_identifier_anonymous_array_char_20_ec))}; - if (!element_identifier_anonymous_array_char_20_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); - return; - } - EquivalenceKind equiv_kind_anonymous_array_char_20 = EK_COMPLETE; - if (TK_NONE == type_ids_message.type_identifier2()._d()) - { - equiv_kind_anonymous_array_char_20 = EK_BOTH; - } - CollectionElementFlag element_flags_anonymous_array_char_20 = 0; - PlainCollectionHeader header_anonymous_array_char_20 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_char_20, element_flags_anonymous_array_char_20); - { - SBoundSeq array_bound_seq; - TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(20)); - - PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_char_20, array_bound_seq, - eprosima::fastcdr::external(element_identifier_anonymous_array_char_20)); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_char_20", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_array_char_20 already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); - } - CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "HelloWorld already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/BasicConfigurationExample/HelloWorldTypeObjectSupport.hpp b/examples/cpp/dds/BasicConfigurationExample/HelloWorldTypeObjectSupport.hpp deleted file mode 100644 index 2eba797b07f..00000000000 --- a/examples/cpp/dds/BasicConfigurationExample/HelloWorldTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 HelloWorldTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register HelloWorld related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_HelloWorld_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/Configurability/samplePubSubTypes.cxx b/examples/cpp/dds/Configurability/samplePubSubTypes.cxx deleted file mode 100644 index 321f250d975..00000000000 --- a/examples/cpp/dds/Configurability/samplePubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 samplePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "samplePubSubTypes.h" - -#include -#include - -#include "sampleCdrAux.hpp" -#include "sampleTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -samplePubSubType::samplePubSubType() -{ - setName("sample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sample::getMaxCdrSerializedSize()); -#else - sample_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -samplePubSubType::~samplePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool samplePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - sample* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool samplePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - sample* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function samplePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* samplePubSubType::createData() -{ - return reinterpret_cast(new sample()); -} - -void samplePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool samplePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - sample* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - sample_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || sample_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void samplePubSubType::register_type_object_representation() -{ - register_sample_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "sampleCdrAux.ipp" diff --git a/examples/cpp/dds/Configurability/samplePubSubTypes.h b/examples/cpp/dds/Configurability/samplePubSubTypes.h deleted file mode 100644 index 1ec6375ba7f..00000000000 --- a/examples/cpp/dds/Configurability/samplePubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 samplePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated sample 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 sample defined by the user in the IDL file. - * @ingroup sample - */ -class samplePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef sample type; - - eProsima_user_DllExport samplePubSubType(); - - eProsima_user_DllExport ~samplePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/Configurability/sampleTypeObjectSupport.cxx b/examples/cpp/dds/Configurability/sampleTypeObjectSupport.cxx deleted file mode 100644 index e9dcd1a977b..00000000000 --- a/examples/cpp/dds/Configurability/sampleTypeObjectSupport.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// 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 sampleTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "sampleTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_sample_type_identifier( - TypeIdentifierPair& type_ids_sample) -{ - - ReturnCode_t return_code_sample {eprosima::fastdds::dds::RETCODE_OK}; - return_code_sample = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "sample", type_ids_sample); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_sample) - { - StructTypeFlag struct_flags_sample = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_sample = "sample"; - eprosima::fastcdr::optional type_ann_builtin_sample; - eprosima::fastcdr::optional ann_custom_sample; - CompleteTypeDetail detail_sample = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_sample, ann_custom_sample, type_name_sample.to_string()); - CompleteStructHeader header_sample; - header_sample = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_sample); - CompleteStructMemberSeq member_seq_sample; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_sample.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_sample); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_index); - } - { - TypeIdentifierPair type_ids_key_value; - ReturnCode_t return_code_key_value {eprosima::fastdds::dds::RETCODE_OK}; - return_code_key_value = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_key_value); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_key_value) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "key_value Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_key_value = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, true, false); - MemberId member_id_key_value = 0x00000001; - bool common_key_value_ec {false}; - CommonStructMember common_key_value {TypeObjectUtils::build_common_struct_member(member_id_key_value, member_flags_key_value, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_key_value, common_key_value_ec))}; - if (!common_key_value_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure key_value member TypeIdentifier inconsistent."); - return; - } - MemberName name_key_value = "key_value"; - eprosima::fastcdr::optional member_ann_builtin_key_value; - ann_custom_sample.reset(); - AppliedAnnotationSeq tmp_ann_custom_key_value; - eprosima::fastcdr::optional unit_key_value; - eprosima::fastcdr::optional min_key_value; - eprosima::fastcdr::optional max_key_value; - eprosima::fastcdr::optional hash_id_key_value; - if (unit_key_value.has_value() || min_key_value.has_value() || max_key_value.has_value() || hash_id_key_value.has_value()) - { - member_ann_builtin_key_value = TypeObjectUtils::build_applied_builtin_member_annotations(unit_key_value, min_key_value, max_key_value, hash_id_key_value); - } - if (!tmp_ann_custom_key_value.empty()) - { - ann_custom_sample = tmp_ann_custom_key_value; - } - CompleteMemberDetail detail_key_value = TypeObjectUtils::build_complete_member_detail(name_key_value, member_ann_builtin_key_value, ann_custom_sample); - CompleteStructMember member_key_value = TypeObjectUtils::build_complete_struct_member(common_key_value, detail_key_value); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_key_value); - } - CompleteStructType struct_type_sample = TypeObjectUtils::build_complete_struct_type(struct_flags_sample, header_sample, member_seq_sample); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_sample, type_name_sample.to_string(), type_ids_sample)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "sample already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/Configurability/sampleTypeObjectSupport.hpp b/examples/cpp/dds/Configurability/sampleTypeObjectSupport.hpp deleted file mode 100644 index 013609fa263..00000000000 --- a/examples/cpp/dds/Configurability/sampleTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 sampleTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register sample related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_sample_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/CustomListenerExample/TopicPubSubTypes.cxx b/examples/cpp/dds/CustomListenerExample/TopicPubSubTypes.cxx deleted file mode 100644 index 70697eb1c1d..00000000000 --- a/examples/cpp/dds/CustomListenerExample/TopicPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 TopicPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "TopicPubSubTypes.h" - -#include -#include - -#include "TopicCdrAux.hpp" -#include "TopicTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -TopicPubSubType::TopicPubSubType() -{ - setName("Topic"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Topic::getMaxCdrSerializedSize()); -#else - Topic_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Topic_max_key_cdr_typesize > 16 ? Topic_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -TopicPubSubType::~TopicPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool TopicPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - Topic* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool TopicPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - Topic* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function TopicPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TopicPubSubType::createData() -{ - return reinterpret_cast(new Topic()); -} - -void TopicPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool TopicPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - Topic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - Topic_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || Topic_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void TopicPubSubType::register_type_object_representation() -{ - register_Topic_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "TopicCdrAux.ipp" diff --git a/examples/cpp/dds/CustomListenerExample/TopicPubSubTypes.h b/examples/cpp/dds/CustomListenerExample/TopicPubSubTypes.h deleted file mode 100644 index 8af82d4fcdf..00000000000 --- a/examples/cpp/dds/CustomListenerExample/TopicPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 TopicPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_TOPIC_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_TOPIC_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "Topic.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated Topic 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 Topic defined by the user in the IDL file. - * @ingroup Topic - */ -class TopicPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef Topic type; - - eProsima_user_DllExport TopicPubSubType(); - - eProsima_user_DllExport ~TopicPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_TOPIC_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/CustomListenerExample/TopicTypeObjectSupport.cxx b/examples/cpp/dds/CustomListenerExample/TopicTypeObjectSupport.cxx deleted file mode 100644 index ec70f284376..00000000000 --- a/examples/cpp/dds/CustomListenerExample/TopicTypeObjectSupport.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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 TopicTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "TopicTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Topic.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_Topic_type_identifier( - TypeIdentifierPair& type_ids_Topic) -{ - - ReturnCode_t return_code_Topic {eprosima::fastdds::dds::RETCODE_OK}; - return_code_Topic = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "Topic", type_ids_Topic); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_Topic) - { - StructTypeFlag struct_flags_Topic = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_Topic = "Topic"; - eprosima::fastcdr::optional type_ann_builtin_Topic; - eprosima::fastcdr::optional ann_custom_Topic; - CompleteTypeDetail detail_Topic = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Topic, ann_custom_Topic, type_name_Topic.to_string()); - CompleteStructHeader header_Topic; - header_Topic = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Topic); - CompleteStructMemberSeq member_seq_Topic; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_Topic.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_Topic); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_Topic, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_Topic.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_Topic); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_Topic, member_message); - } - CompleteStructType struct_type_Topic = TypeObjectUtils::build_complete_struct_type(struct_flags_Topic, header_Topic, member_seq_Topic); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_Topic, type_name_Topic.to_string(), type_ids_Topic)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Topic already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/CustomListenerExample/TopicTypeObjectSupport.hpp b/examples/cpp/dds/CustomListenerExample/TopicTypeObjectSupport.hpp deleted file mode 100644 index 6b3e255eba0..00000000000 --- a/examples/cpp/dds/CustomListenerExample/TopicTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 TopicTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register Topic related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_Topic_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/CustomPayloadPoolExample/CustomPayloadPoolDataTypeObjectSupport.cxx b/examples/cpp/dds/CustomPayloadPoolExample/CustomPayloadPoolDataTypeObjectSupport.cxx deleted file mode 100644 index 80a797f7f94..00000000000 --- a/examples/cpp/dds/CustomPayloadPoolExample/CustomPayloadPoolDataTypeObjectSupport.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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 CustomPayloadPoolDataTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "CustomPayloadPoolDataTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "CustomPayloadPoolData.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_CustomPayloadPoolData_type_identifier( - TypeIdentifierPair& type_ids_CustomPayloadPoolData) -{ - - ReturnCode_t return_code_CustomPayloadPoolData {eprosima::fastdds::dds::RETCODE_OK}; - return_code_CustomPayloadPoolData = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "CustomPayloadPoolData", type_ids_CustomPayloadPoolData); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_CustomPayloadPoolData) - { - StructTypeFlag struct_flags_CustomPayloadPoolData = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, - false, false); - QualifiedTypeName type_name_CustomPayloadPoolData = "CustomPayloadPoolData"; - eprosima::fastcdr::optional type_ann_builtin_CustomPayloadPoolData; - eprosima::fastcdr::optional ann_custom_CustomPayloadPoolData; - CompleteTypeDetail detail_CustomPayloadPoolData = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_CustomPayloadPoolData, ann_custom_CustomPayloadPoolData, type_name_CustomPayloadPoolData.to_string()); - CompleteStructHeader header_CustomPayloadPoolData; - header_CustomPayloadPoolData = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_CustomPayloadPoolData); - CompleteStructMemberSeq member_seq_CustomPayloadPoolData; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_CustomPayloadPoolData.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_CustomPayloadPoolData); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_CustomPayloadPoolData, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_CustomPayloadPoolData.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_CustomPayloadPoolData); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_CustomPayloadPoolData, member_message); - } - CompleteStructType struct_type_CustomPayloadPoolData = TypeObjectUtils::build_complete_struct_type(struct_flags_CustomPayloadPoolData, header_CustomPayloadPoolData, member_seq_CustomPayloadPoolData); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_CustomPayloadPoolData, type_name_CustomPayloadPoolData.to_string(), type_ids_CustomPayloadPoolData)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "CustomPayloadPoolData already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadPubSubTypes.cxx b/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadPubSubTypes.cxx deleted file mode 100644 index 4039df4d417..00000000000 --- a/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 deadlinepayloadPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "deadlinepayloadPubSubTypes.h" - -#include -#include - -#include "deadlinepayloadCdrAux.hpp" -#include "deadlinepayloadTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -HelloMsgPubSubType::HelloMsgPubSubType() -{ - setName("HelloMsg"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloMsg::getMaxCdrSerializedSize()); -#else - HelloMsg_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = HelloMsg_max_key_cdr_typesize > 16 ? HelloMsg_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloMsgPubSubType::~HelloMsgPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloMsgPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - HelloMsg* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool HelloMsgPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - HelloMsg* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function HelloMsgPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* HelloMsgPubSubType::createData() -{ - return reinterpret_cast(new HelloMsg()); -} - -void HelloMsgPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloMsgPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - HelloMsg* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloMsg_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || HelloMsg_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void HelloMsgPubSubType::register_type_object_representation() -{ - register_HelloMsg_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "deadlinepayloadCdrAux.ipp" diff --git a/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadPubSubTypes.h b/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadPubSubTypes.h deleted file mode 100644 index 7a354e84055..00000000000 --- a/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 deadlinepayloadPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_DEADLINEPAYLOAD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DEADLINEPAYLOAD_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "deadlinepayload.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated deadlinepayload 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 HelloMsg defined by the user in the IDL file. - * @ingroup deadlinepayload - */ -class HelloMsgPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloMsg type; - - eProsima_user_DllExport HelloMsgPubSubType(); - - eProsima_user_DllExport ~HelloMsgPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_DEADLINEPAYLOAD_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadTypeObjectSupport.cxx b/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadTypeObjectSupport.cxx deleted file mode 100644 index b9768d78f93..00000000000 --- a/examples/cpp/dds/DeadlineQoSExample/deadlinepayloadTypeObjectSupport.cxx +++ /dev/null @@ -1,151 +0,0 @@ -// 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 deadlinepayloadTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "deadlinepayloadTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "deadlinepayload.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_HelloMsg_type_identifier( - TypeIdentifierPair& type_ids_HelloMsg) -{ - - ReturnCode_t return_code_HelloMsg {eprosima::fastdds::dds::RETCODE_OK}; - return_code_HelloMsg = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "HelloMsg", type_ids_HelloMsg); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloMsg) - { - StructTypeFlag struct_flags_HelloMsg = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_HelloMsg = "HelloMsg"; - eprosima::fastcdr::optional type_ann_builtin_HelloMsg; - eprosima::fastcdr::optional ann_custom_HelloMsg; - CompleteTypeDetail detail_HelloMsg = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloMsg, ann_custom_HelloMsg, type_name_HelloMsg.to_string()); - CompleteStructHeader header_HelloMsg; - header_HelloMsg = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloMsg); - CompleteStructMemberSeq member_seq_HelloMsg; - { - TypeIdentifierPair type_ids_deadlinekey; - ReturnCode_t return_code_deadlinekey {eprosima::fastdds::dds::RETCODE_OK}; - return_code_deadlinekey = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint16_t", type_ids_deadlinekey); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_deadlinekey) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "deadlinekey Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_deadlinekey = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, true, false); - MemberId member_id_deadlinekey = 0x00000000; - bool common_deadlinekey_ec {false}; - CommonStructMember common_deadlinekey {TypeObjectUtils::build_common_struct_member(member_id_deadlinekey, member_flags_deadlinekey, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_deadlinekey, common_deadlinekey_ec))}; - if (!common_deadlinekey_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure deadlinekey member TypeIdentifier inconsistent."); - return; - } - MemberName name_deadlinekey = "deadlinekey"; - eprosima::fastcdr::optional member_ann_builtin_deadlinekey; - ann_custom_HelloMsg.reset(); - AppliedAnnotationSeq tmp_ann_custom_deadlinekey; - eprosima::fastcdr::optional unit_deadlinekey; - eprosima::fastcdr::optional min_deadlinekey; - eprosima::fastcdr::optional max_deadlinekey; - eprosima::fastcdr::optional hash_id_deadlinekey; - if (unit_deadlinekey.has_value() || min_deadlinekey.has_value() || max_deadlinekey.has_value() || hash_id_deadlinekey.has_value()) - { - member_ann_builtin_deadlinekey = TypeObjectUtils::build_applied_builtin_member_annotations(unit_deadlinekey, min_deadlinekey, max_deadlinekey, hash_id_deadlinekey); - } - if (!tmp_ann_custom_deadlinekey.empty()) - { - ann_custom_HelloMsg = tmp_ann_custom_deadlinekey; - } - CompleteMemberDetail detail_deadlinekey = TypeObjectUtils::build_complete_member_detail(name_deadlinekey, member_ann_builtin_deadlinekey, ann_custom_HelloMsg); - CompleteStructMember member_deadlinekey = TypeObjectUtils::build_complete_struct_member(common_deadlinekey, detail_deadlinekey); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloMsg, member_deadlinekey); - } - { - TypeIdentifierPair type_ids_payload; - ReturnCode_t return_code_payload {eprosima::fastdds::dds::RETCODE_OK}; - return_code_payload = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_256", type_ids_payload); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_payload) - { - { - LBound bound = 256; - StringLTypeDefn string_ldefn = TypeObjectUtils::build_string_l_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_l_string_type_identifier(string_ldefn, - "anonymous_string_256", type_ids_payload)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_256 already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_payload = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_payload = 0x00000001; - bool common_payload_ec {false}; - CommonStructMember common_payload {TypeObjectUtils::build_common_struct_member(member_id_payload, member_flags_payload, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_payload, common_payload_ec))}; - if (!common_payload_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure payload member TypeIdentifier inconsistent."); - return; - } - MemberName name_payload = "payload"; - eprosima::fastcdr::optional member_ann_builtin_payload; - ann_custom_HelloMsg.reset(); - CompleteMemberDetail detail_payload = TypeObjectUtils::build_complete_member_detail(name_payload, member_ann_builtin_payload, ann_custom_HelloMsg); - CompleteStructMember member_payload = TypeObjectUtils::build_complete_struct_member(common_payload, detail_payload); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloMsg, member_payload); - } - CompleteStructType struct_type_HelloMsg = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloMsg, header_HelloMsg, member_seq_HelloMsg); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloMsg, type_name_HelloMsg.to_string(), type_ids_HelloMsg)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "HelloMsg already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/DisablePositiveACKs/TopicTypeObjectSupport.cxx b/examples/cpp/dds/DisablePositiveACKs/TopicTypeObjectSupport.cxx deleted file mode 100644 index ec70f284376..00000000000 --- a/examples/cpp/dds/DisablePositiveACKs/TopicTypeObjectSupport.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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 TopicTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "TopicTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Topic.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_Topic_type_identifier( - TypeIdentifierPair& type_ids_Topic) -{ - - ReturnCode_t return_code_Topic {eprosima::fastdds::dds::RETCODE_OK}; - return_code_Topic = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "Topic", type_ids_Topic); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_Topic) - { - StructTypeFlag struct_flags_Topic = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_Topic = "Topic"; - eprosima::fastcdr::optional type_ann_builtin_Topic; - eprosima::fastcdr::optional ann_custom_Topic; - CompleteTypeDetail detail_Topic = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Topic, ann_custom_Topic, type_name_Topic.to_string()); - CompleteStructHeader header_Topic; - header_Topic = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Topic); - CompleteStructMemberSeq member_seq_Topic; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_Topic.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_Topic); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_Topic, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_Topic.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_Topic); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_Topic, member_message); - } - CompleteStructType struct_type_Topic = TypeObjectUtils::build_complete_struct_type(struct_flags_Topic, header_Topic, member_seq_Topic); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_Topic, type_name_Topic.to_string(), type_ids_Topic)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Topic already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/DisablePositiveACKs/TopicTypeObjectSupport.hpp b/examples/cpp/dds/DisablePositiveACKs/TopicTypeObjectSupport.hpp deleted file mode 100644 index 6b3e255eba0..00000000000 --- a/examples/cpp/dds/DisablePositiveACKs/TopicTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 TopicTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register Topic related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_Topic_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/Filtering/FilteringExamplePubSubTypes.cxx b/examples/cpp/dds/Filtering/FilteringExamplePubSubTypes.cxx deleted file mode 100644 index fb77a83726d..00000000000 --- a/examples/cpp/dds/Filtering/FilteringExamplePubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 FilteringExamplePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "FilteringExamplePubSubTypes.h" - -#include -#include - -#include "FilteringExampleCdrAux.hpp" -#include "FilteringExampleTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -FilteringExamplePubSubType::FilteringExamplePubSubType() -{ - setName("FilteringExample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(FilteringExample::getMaxCdrSerializedSize()); -#else - FilteringExample_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = FilteringExample_max_key_cdr_typesize > 16 ? FilteringExample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -FilteringExamplePubSubType::~FilteringExamplePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool FilteringExamplePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - FilteringExample* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool FilteringExamplePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - FilteringExample* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function FilteringExamplePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* FilteringExamplePubSubType::createData() -{ - return reinterpret_cast(new FilteringExample()); -} - -void FilteringExamplePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool FilteringExamplePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - FilteringExample* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - FilteringExample_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || FilteringExample_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void FilteringExamplePubSubType::register_type_object_representation() -{ - register_FilteringExample_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "FilteringExampleCdrAux.ipp" diff --git a/examples/cpp/dds/Filtering/FilteringExamplePubSubTypes.h b/examples/cpp/dds/Filtering/FilteringExamplePubSubTypes.h deleted file mode 100644 index 379c2b76c26..00000000000 --- a/examples/cpp/dds/Filtering/FilteringExamplePubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 FilteringExamplePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_FILTERINGEXAMPLE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_FILTERINGEXAMPLE_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "FilteringExample.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated FilteringExample 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 FilteringExample defined by the user in the IDL file. - * @ingroup FilteringExample - */ -class FilteringExamplePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef FilteringExample type; - - eProsima_user_DllExport FilteringExamplePubSubType(); - - eProsima_user_DllExport ~FilteringExamplePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_FILTERINGEXAMPLE_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/Filtering/FilteringExampleTypeObjectSupport.cxx b/examples/cpp/dds/Filtering/FilteringExampleTypeObjectSupport.cxx deleted file mode 100644 index 25a58904bf2..00000000000 --- a/examples/cpp/dds/Filtering/FilteringExampleTypeObjectSupport.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// 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 FilteringExampleTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "FilteringExampleTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "FilteringExample.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_FilteringExample_type_identifier( - TypeIdentifierPair& type_ids_FilteringExample) -{ - - ReturnCode_t return_code_FilteringExample {eprosima::fastdds::dds::RETCODE_OK}; - return_code_FilteringExample = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "FilteringExample", type_ids_FilteringExample); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_FilteringExample) - { - StructTypeFlag struct_flags_FilteringExample = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_FilteringExample = "FilteringExample"; - eprosima::fastcdr::optional type_ann_builtin_FilteringExample; - eprosima::fastcdr::optional ann_custom_FilteringExample; - CompleteTypeDetail detail_FilteringExample = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_FilteringExample, ann_custom_FilteringExample, type_name_FilteringExample.to_string()); - CompleteStructHeader header_FilteringExample; - header_FilteringExample = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_FilteringExample); - CompleteStructMemberSeq member_seq_FilteringExample; - { - TypeIdentifierPair type_ids_sampleNumber; - ReturnCode_t return_code_sampleNumber {eprosima::fastdds::dds::RETCODE_OK}; - return_code_sampleNumber = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_int32_t", type_ids_sampleNumber); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_sampleNumber) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "sampleNumber Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_sampleNumber = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_sampleNumber = 0x00000000; - bool common_sampleNumber_ec {false}; - CommonStructMember common_sampleNumber {TypeObjectUtils::build_common_struct_member(member_id_sampleNumber, member_flags_sampleNumber, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_sampleNumber, common_sampleNumber_ec))}; - if (!common_sampleNumber_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure sampleNumber member TypeIdentifier inconsistent."); - return; - } - MemberName name_sampleNumber = "sampleNumber"; - eprosima::fastcdr::optional member_ann_builtin_sampleNumber; - ann_custom_FilteringExample.reset(); - CompleteMemberDetail detail_sampleNumber = TypeObjectUtils::build_complete_member_detail(name_sampleNumber, member_ann_builtin_sampleNumber, ann_custom_FilteringExample); - CompleteStructMember member_sampleNumber = TypeObjectUtils::build_complete_struct_member(common_sampleNumber, detail_sampleNumber); - TypeObjectUtils::add_complete_struct_member(member_seq_FilteringExample, member_sampleNumber); - } - CompleteStructType struct_type_FilteringExample = TypeObjectUtils::build_complete_struct_type(struct_flags_FilteringExample, header_FilteringExample, member_seq_FilteringExample); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_FilteringExample, type_name_FilteringExample.to_string(), type_ids_FilteringExample)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "FilteringExample already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/Filtering/FilteringExampleTypeObjectSupport.hpp b/examples/cpp/dds/Filtering/FilteringExampleTypeObjectSupport.hpp deleted file mode 100644 index 458f0657204..00000000000 --- a/examples/cpp/dds/Filtering/FilteringExampleTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 FilteringExampleTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_FILTERINGEXAMPLE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_FILTERINGEXAMPLE_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register FilteringExample related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_FilteringExample_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_FILTERINGEXAMPLE_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/HistoryKind/samplePubSubTypes.cxx b/examples/cpp/dds/HistoryKind/samplePubSubTypes.cxx deleted file mode 100644 index 321f250d975..00000000000 --- a/examples/cpp/dds/HistoryKind/samplePubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 samplePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "samplePubSubTypes.h" - -#include -#include - -#include "sampleCdrAux.hpp" -#include "sampleTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -samplePubSubType::samplePubSubType() -{ - setName("sample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sample::getMaxCdrSerializedSize()); -#else - sample_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -samplePubSubType::~samplePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool samplePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - sample* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool samplePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - sample* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function samplePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* samplePubSubType::createData() -{ - return reinterpret_cast(new sample()); -} - -void samplePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool samplePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - sample* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - sample_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || sample_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void samplePubSubType::register_type_object_representation() -{ - register_sample_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "sampleCdrAux.ipp" diff --git a/examples/cpp/dds/HistoryKind/samplePubSubTypes.h b/examples/cpp/dds/HistoryKind/samplePubSubTypes.h deleted file mode 100644 index 1ec6375ba7f..00000000000 --- a/examples/cpp/dds/HistoryKind/samplePubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 samplePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated sample 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 sample defined by the user in the IDL file. - * @ingroup sample - */ -class samplePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef sample type; - - eProsima_user_DllExport samplePubSubType(); - - eProsima_user_DllExport ~samplePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/HistoryKind/sampleTypeObjectSupport.cxx b/examples/cpp/dds/HistoryKind/sampleTypeObjectSupport.cxx deleted file mode 100644 index e9dcd1a977b..00000000000 --- a/examples/cpp/dds/HistoryKind/sampleTypeObjectSupport.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// 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 sampleTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "sampleTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_sample_type_identifier( - TypeIdentifierPair& type_ids_sample) -{ - - ReturnCode_t return_code_sample {eprosima::fastdds::dds::RETCODE_OK}; - return_code_sample = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "sample", type_ids_sample); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_sample) - { - StructTypeFlag struct_flags_sample = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_sample = "sample"; - eprosima::fastcdr::optional type_ann_builtin_sample; - eprosima::fastcdr::optional ann_custom_sample; - CompleteTypeDetail detail_sample = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_sample, ann_custom_sample, type_name_sample.to_string()); - CompleteStructHeader header_sample; - header_sample = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_sample); - CompleteStructMemberSeq member_seq_sample; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_sample.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_sample); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_index); - } - { - TypeIdentifierPair type_ids_key_value; - ReturnCode_t return_code_key_value {eprosima::fastdds::dds::RETCODE_OK}; - return_code_key_value = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_key_value); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_key_value) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "key_value Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_key_value = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, true, false); - MemberId member_id_key_value = 0x00000001; - bool common_key_value_ec {false}; - CommonStructMember common_key_value {TypeObjectUtils::build_common_struct_member(member_id_key_value, member_flags_key_value, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_key_value, common_key_value_ec))}; - if (!common_key_value_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure key_value member TypeIdentifier inconsistent."); - return; - } - MemberName name_key_value = "key_value"; - eprosima::fastcdr::optional member_ann_builtin_key_value; - ann_custom_sample.reset(); - AppliedAnnotationSeq tmp_ann_custom_key_value; - eprosima::fastcdr::optional unit_key_value; - eprosima::fastcdr::optional min_key_value; - eprosima::fastcdr::optional max_key_value; - eprosima::fastcdr::optional hash_id_key_value; - if (unit_key_value.has_value() || min_key_value.has_value() || max_key_value.has_value() || hash_id_key_value.has_value()) - { - member_ann_builtin_key_value = TypeObjectUtils::build_applied_builtin_member_annotations(unit_key_value, min_key_value, max_key_value, hash_id_key_value); - } - if (!tmp_ann_custom_key_value.empty()) - { - ann_custom_sample = tmp_ann_custom_key_value; - } - CompleteMemberDetail detail_key_value = TypeObjectUtils::build_complete_member_detail(name_key_value, member_ann_builtin_key_value, ann_custom_sample); - CompleteStructMember member_key_value = TypeObjectUtils::build_complete_struct_member(common_key_value, detail_key_value); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_key_value); - } - CompleteStructType struct_type_sample = TypeObjectUtils::build_complete_struct_type(struct_flags_sample, header_sample, member_seq_sample); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_sample, type_name_sample.to_string(), type_ids_sample)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "sample already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/HistoryKind/sampleTypeObjectSupport.hpp b/examples/cpp/dds/HistoryKind/sampleTypeObjectSupport.hpp deleted file mode 100644 index 013609fa263..00000000000 --- a/examples/cpp/dds/HistoryKind/sampleTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 sampleTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register sample related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_sample_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/LateJoiners/samplePubSubTypes.cxx b/examples/cpp/dds/LateJoiners/samplePubSubTypes.cxx deleted file mode 100644 index 321f250d975..00000000000 --- a/examples/cpp/dds/LateJoiners/samplePubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 samplePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "samplePubSubTypes.h" - -#include -#include - -#include "sampleCdrAux.hpp" -#include "sampleTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -samplePubSubType::samplePubSubType() -{ - setName("sample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sample::getMaxCdrSerializedSize()); -#else - sample_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -samplePubSubType::~samplePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool samplePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - sample* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool samplePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - sample* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function samplePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* samplePubSubType::createData() -{ - return reinterpret_cast(new sample()); -} - -void samplePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool samplePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - sample* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - sample_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || sample_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void samplePubSubType::register_type_object_representation() -{ - register_sample_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "sampleCdrAux.ipp" diff --git a/examples/cpp/dds/LateJoiners/samplePubSubTypes.h b/examples/cpp/dds/LateJoiners/samplePubSubTypes.h deleted file mode 100644 index 1ec6375ba7f..00000000000 --- a/examples/cpp/dds/LateJoiners/samplePubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 samplePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated sample 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 sample defined by the user in the IDL file. - * @ingroup sample - */ -class samplePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef sample type; - - eProsima_user_DllExport samplePubSubType(); - - eProsima_user_DllExport ~samplePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/LateJoiners/sampleTypeObjectSupport.cxx b/examples/cpp/dds/LateJoiners/sampleTypeObjectSupport.cxx deleted file mode 100644 index e9dcd1a977b..00000000000 --- a/examples/cpp/dds/LateJoiners/sampleTypeObjectSupport.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// 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 sampleTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "sampleTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_sample_type_identifier( - TypeIdentifierPair& type_ids_sample) -{ - - ReturnCode_t return_code_sample {eprosima::fastdds::dds::RETCODE_OK}; - return_code_sample = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "sample", type_ids_sample); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_sample) - { - StructTypeFlag struct_flags_sample = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_sample = "sample"; - eprosima::fastcdr::optional type_ann_builtin_sample; - eprosima::fastcdr::optional ann_custom_sample; - CompleteTypeDetail detail_sample = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_sample, ann_custom_sample, type_name_sample.to_string()); - CompleteStructHeader header_sample; - header_sample = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_sample); - CompleteStructMemberSeq member_seq_sample; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_sample.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_sample); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_index); - } - { - TypeIdentifierPair type_ids_key_value; - ReturnCode_t return_code_key_value {eprosima::fastdds::dds::RETCODE_OK}; - return_code_key_value = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_key_value); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_key_value) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "key_value Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_key_value = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, true, false); - MemberId member_id_key_value = 0x00000001; - bool common_key_value_ec {false}; - CommonStructMember common_key_value {TypeObjectUtils::build_common_struct_member(member_id_key_value, member_flags_key_value, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_key_value, common_key_value_ec))}; - if (!common_key_value_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure key_value member TypeIdentifier inconsistent."); - return; - } - MemberName name_key_value = "key_value"; - eprosima::fastcdr::optional member_ann_builtin_key_value; - ann_custom_sample.reset(); - AppliedAnnotationSeq tmp_ann_custom_key_value; - eprosima::fastcdr::optional unit_key_value; - eprosima::fastcdr::optional min_key_value; - eprosima::fastcdr::optional max_key_value; - eprosima::fastcdr::optional hash_id_key_value; - if (unit_key_value.has_value() || min_key_value.has_value() || max_key_value.has_value() || hash_id_key_value.has_value()) - { - member_ann_builtin_key_value = TypeObjectUtils::build_applied_builtin_member_annotations(unit_key_value, min_key_value, max_key_value, hash_id_key_value); - } - if (!tmp_ann_custom_key_value.empty()) - { - ann_custom_sample = tmp_ann_custom_key_value; - } - CompleteMemberDetail detail_key_value = TypeObjectUtils::build_complete_member_detail(name_key_value, member_ann_builtin_key_value, ann_custom_sample); - CompleteStructMember member_key_value = TypeObjectUtils::build_complete_struct_member(common_key_value, detail_key_value); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_key_value); - } - CompleteStructType struct_type_sample = TypeObjectUtils::build_complete_struct_type(struct_flags_sample, header_sample, member_seq_sample); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_sample, type_name_sample.to_string(), type_ids_sample)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "sample already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/LateJoiners/sampleTypeObjectSupport.hpp b/examples/cpp/dds/LateJoiners/sampleTypeObjectSupport.hpp deleted file mode 100644 index 013609fa263..00000000000 --- a/examples/cpp/dds/LateJoiners/sampleTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 sampleTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register sample related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_sample_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/LifespanQoSExample/LifespanPubSubTypes.cxx b/examples/cpp/dds/LifespanQoSExample/LifespanPubSubTypes.cxx deleted file mode 100644 index 30d909b77f5..00000000000 --- a/examples/cpp/dds/LifespanQoSExample/LifespanPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 LifespanPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "LifespanPubSubTypes.h" - -#include -#include - -#include "LifespanCdrAux.hpp" -#include "LifespanTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -LifespanPubSubType::LifespanPubSubType() -{ - setName("Lifespan"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Lifespan::getMaxCdrSerializedSize()); -#else - Lifespan_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Lifespan_max_key_cdr_typesize > 16 ? Lifespan_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -LifespanPubSubType::~LifespanPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool LifespanPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - Lifespan* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool LifespanPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - Lifespan* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function LifespanPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* LifespanPubSubType::createData() -{ - return reinterpret_cast(new Lifespan()); -} - -void LifespanPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool LifespanPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - Lifespan* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - Lifespan_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || Lifespan_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void LifespanPubSubType::register_type_object_representation() -{ - register_Lifespan_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "LifespanCdrAux.ipp" diff --git a/examples/cpp/dds/LifespanQoSExample/LifespanPubSubTypes.h b/examples/cpp/dds/LifespanQoSExample/LifespanPubSubTypes.h deleted file mode 100644 index 1314dbb2e9f..00000000000 --- a/examples/cpp/dds/LifespanQoSExample/LifespanPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 LifespanPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_LIFESPAN_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_LIFESPAN_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "Lifespan.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated Lifespan 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 Lifespan defined by the user in the IDL file. - * @ingroup Lifespan - */ -class LifespanPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef Lifespan type; - - eProsima_user_DllExport LifespanPubSubType(); - - eProsima_user_DllExport ~LifespanPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_LIFESPAN_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/LifespanQoSExample/LifespanTypeObjectSupport.cxx b/examples/cpp/dds/LifespanQoSExample/LifespanTypeObjectSupport.cxx deleted file mode 100644 index 9306797b046..00000000000 --- a/examples/cpp/dds/LifespanQoSExample/LifespanTypeObjectSupport.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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 LifespanTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "LifespanTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Lifespan.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_Lifespan_type_identifier( - TypeIdentifierPair& type_ids_Lifespan) -{ - - ReturnCode_t return_code_Lifespan {eprosima::fastdds::dds::RETCODE_OK}; - return_code_Lifespan = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "Lifespan", type_ids_Lifespan); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_Lifespan) - { - StructTypeFlag struct_flags_Lifespan = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_Lifespan = "Lifespan"; - eprosima::fastcdr::optional type_ann_builtin_Lifespan; - eprosima::fastcdr::optional ann_custom_Lifespan; - CompleteTypeDetail detail_Lifespan = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Lifespan, ann_custom_Lifespan, type_name_Lifespan.to_string()); - CompleteStructHeader header_Lifespan; - header_Lifespan = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Lifespan); - CompleteStructMemberSeq member_seq_Lifespan; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_Lifespan.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_Lifespan); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_Lifespan, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_Lifespan.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_Lifespan); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_Lifespan, member_message); - } - CompleteStructType struct_type_Lifespan = TypeObjectUtils::build_complete_struct_type(struct_flags_Lifespan, header_Lifespan, member_seq_Lifespan); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_Lifespan, type_name_Lifespan.to_string(), type_ids_Lifespan)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Lifespan already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/LifespanQoSExample/LifespanTypeObjectSupport.hpp b/examples/cpp/dds/LifespanQoSExample/LifespanTypeObjectSupport.hpp deleted file mode 100644 index 9ddc11df87d..00000000000 --- a/examples/cpp/dds/LifespanQoSExample/LifespanTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 LifespanTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_LIFESPAN_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_LIFESPAN_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register Lifespan related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_Lifespan_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_LIFESPAN_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/LivelinessQoS/TopicPubSubTypes.cxx b/examples/cpp/dds/LivelinessQoS/TopicPubSubTypes.cxx deleted file mode 100644 index 70697eb1c1d..00000000000 --- a/examples/cpp/dds/LivelinessQoS/TopicPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 TopicPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "TopicPubSubTypes.h" - -#include -#include - -#include "TopicCdrAux.hpp" -#include "TopicTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -TopicPubSubType::TopicPubSubType() -{ - setName("Topic"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(Topic::getMaxCdrSerializedSize()); -#else - Topic_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = Topic_max_key_cdr_typesize > 16 ? Topic_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -TopicPubSubType::~TopicPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool TopicPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - Topic* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool TopicPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - Topic* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function TopicPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* TopicPubSubType::createData() -{ - return reinterpret_cast(new Topic()); -} - -void TopicPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool TopicPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - Topic* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - Topic_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || Topic_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void TopicPubSubType::register_type_object_representation() -{ - register_Topic_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "TopicCdrAux.ipp" diff --git a/examples/cpp/dds/LivelinessQoS/TopicPubSubTypes.h b/examples/cpp/dds/LivelinessQoS/TopicPubSubTypes.h deleted file mode 100644 index 8af82d4fcdf..00000000000 --- a/examples/cpp/dds/LivelinessQoS/TopicPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 TopicPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_TOPIC_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_TOPIC_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "Topic.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated Topic 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 Topic defined by the user in the IDL file. - * @ingroup Topic - */ -class TopicPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef Topic type; - - eProsima_user_DllExport TopicPubSubType(); - - eProsima_user_DllExport ~TopicPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_TOPIC_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/LivelinessQoS/TopicTypeObjectSupport.cxx b/examples/cpp/dds/LivelinessQoS/TopicTypeObjectSupport.cxx deleted file mode 100644 index ec70f284376..00000000000 --- a/examples/cpp/dds/LivelinessQoS/TopicTypeObjectSupport.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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 TopicTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "TopicTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Topic.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_Topic_type_identifier( - TypeIdentifierPair& type_ids_Topic) -{ - - ReturnCode_t return_code_Topic {eprosima::fastdds::dds::RETCODE_OK}; - return_code_Topic = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "Topic", type_ids_Topic); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_Topic) - { - StructTypeFlag struct_flags_Topic = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_Topic = "Topic"; - eprosima::fastcdr::optional type_ann_builtin_Topic; - eprosima::fastcdr::optional ann_custom_Topic; - CompleteTypeDetail detail_Topic = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Topic, ann_custom_Topic, type_name_Topic.to_string()); - CompleteStructHeader header_Topic; - header_Topic = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Topic); - CompleteStructMemberSeq member_seq_Topic; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_Topic.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_Topic); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_Topic, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_Topic.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_Topic); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_Topic, member_message); - } - CompleteStructType struct_type_Topic = TypeObjectUtils::build_complete_struct_type(struct_flags_Topic, header_Topic, member_seq_Topic); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_Topic, type_name_Topic.to_string(), type_ids_Topic)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Topic already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/LivelinessQoS/TopicTypeObjectSupport.hpp b/examples/cpp/dds/LivelinessQoS/TopicTypeObjectSupport.hpp deleted file mode 100644 index 6b3e255eba0..00000000000 --- a/examples/cpp/dds/LivelinessQoS/TopicTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 TopicTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register Topic related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_Topic_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_TOPIC_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthPubSubTypes.cxx b/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthPubSubTypes.cxx deleted file mode 100644 index 21831e3b34e..00000000000 --- a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 OwnershipStrengthPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "OwnershipStrengthPubSubTypes.h" - -#include -#include - -#include "OwnershipStrengthCdrAux.hpp" -#include "OwnershipStrengthTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -ExampleMessagePubSubType::ExampleMessagePubSubType() -{ - setName("ExampleMessage"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(ExampleMessage::getMaxCdrSerializedSize()); -#else - ExampleMessage_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = ExampleMessage_max_key_cdr_typesize > 16 ? ExampleMessage_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -ExampleMessagePubSubType::~ExampleMessagePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool ExampleMessagePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - ExampleMessage* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool ExampleMessagePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - ExampleMessage* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function ExampleMessagePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* ExampleMessagePubSubType::createData() -{ - return reinterpret_cast(new ExampleMessage()); -} - -void ExampleMessagePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool ExampleMessagePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - ExampleMessage* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - ExampleMessage_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || ExampleMessage_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void ExampleMessagePubSubType::register_type_object_representation() -{ - register_ExampleMessage_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "OwnershipStrengthCdrAux.ipp" diff --git a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthPubSubTypes.h b/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthPubSubTypes.h deleted file mode 100644 index 21f51bc127f..00000000000 --- a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 OwnershipStrengthPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_OWNERSHIPSTRENGTH_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_OWNERSHIPSTRENGTH_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "OwnershipStrength.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated OwnershipStrength 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 ExampleMessage defined by the user in the IDL file. - * @ingroup OwnershipStrength - */ -class ExampleMessagePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef ExampleMessage type; - - eProsima_user_DllExport ExampleMessagePubSubType(); - - eProsima_user_DllExport ~ExampleMessagePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_OWNERSHIPSTRENGTH_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthTypeObjectSupport.cxx b/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthTypeObjectSupport.cxx deleted file mode 100644 index 9c4650ab567..00000000000 --- a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthTypeObjectSupport.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// 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 OwnershipStrengthTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "OwnershipStrengthTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "OwnershipStrength.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_ExampleMessage_type_identifier( - TypeIdentifierPair& type_ids_ExampleMessage) -{ - - ReturnCode_t return_code_ExampleMessage {eprosima::fastdds::dds::RETCODE_OK}; - return_code_ExampleMessage = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "ExampleMessage", type_ids_ExampleMessage); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_ExampleMessage) - { - StructTypeFlag struct_flags_ExampleMessage = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_ExampleMessage = "ExampleMessage"; - eprosima::fastcdr::optional type_ann_builtin_ExampleMessage; - eprosima::fastcdr::optional ann_custom_ExampleMessage; - CompleteTypeDetail detail_ExampleMessage = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_ExampleMessage, ann_custom_ExampleMessage, type_name_ExampleMessage.to_string()); - CompleteStructHeader header_ExampleMessage; - header_ExampleMessage = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_ExampleMessage); - CompleteStructMemberSeq member_seq_ExampleMessage; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_ExampleMessage.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_ExampleMessage); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_ExampleMessage, member_index); - } - { - TypeIdentifierPair type_ids_ownershipStrength; - ReturnCode_t return_code_ownershipStrength {eprosima::fastdds::dds::RETCODE_OK}; - return_code_ownershipStrength = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_ownershipStrength); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_ownershipStrength) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "ownershipStrength Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_ownershipStrength = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_ownershipStrength = 0x00000001; - bool common_ownershipStrength_ec {false}; - CommonStructMember common_ownershipStrength {TypeObjectUtils::build_common_struct_member(member_id_ownershipStrength, member_flags_ownershipStrength, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_ownershipStrength, common_ownershipStrength_ec))}; - if (!common_ownershipStrength_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure ownershipStrength member TypeIdentifier inconsistent."); - return; - } - MemberName name_ownershipStrength = "ownershipStrength"; - eprosima::fastcdr::optional member_ann_builtin_ownershipStrength; - ann_custom_ExampleMessage.reset(); - CompleteMemberDetail detail_ownershipStrength = TypeObjectUtils::build_complete_member_detail(name_ownershipStrength, member_ann_builtin_ownershipStrength, ann_custom_ExampleMessage); - CompleteStructMember member_ownershipStrength = TypeObjectUtils::build_complete_struct_member(common_ownershipStrength, detail_ownershipStrength); - TypeObjectUtils::add_complete_struct_member(member_seq_ExampleMessage, member_ownershipStrength); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_message = 0x00000002; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_ExampleMessage.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_ExampleMessage); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_ExampleMessage, member_message); - } - CompleteStructType struct_type_ExampleMessage = TypeObjectUtils::build_complete_struct_type(struct_flags_ExampleMessage, header_ExampleMessage, member_seq_ExampleMessage); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_ExampleMessage, type_name_ExampleMessage.to_string(), type_ids_ExampleMessage)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "ExampleMessage already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthTypeObjectSupport.hpp b/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthTypeObjectSupport.hpp deleted file mode 100644 index df3ccd0dab7..00000000000 --- a/examples/cpp/dds/OwnershipStrengthQoSExample/OwnershipStrengthTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 OwnershipStrengthTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_OWNERSHIPSTRENGTH_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_OWNERSHIPSTRENGTH_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register ExampleMessage related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_ExampleMessage_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_OWNERSHIPSTRENGTH_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/SampleConfig_Controller/samplePubSubTypes.cxx b/examples/cpp/dds/SampleConfig_Controller/samplePubSubTypes.cxx deleted file mode 100644 index 321f250d975..00000000000 --- a/examples/cpp/dds/SampleConfig_Controller/samplePubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 samplePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "samplePubSubTypes.h" - -#include -#include - -#include "sampleCdrAux.hpp" -#include "sampleTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -samplePubSubType::samplePubSubType() -{ - setName("sample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sample::getMaxCdrSerializedSize()); -#else - sample_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -samplePubSubType::~samplePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool samplePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - sample* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool samplePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - sample* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function samplePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* samplePubSubType::createData() -{ - return reinterpret_cast(new sample()); -} - -void samplePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool samplePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - sample* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - sample_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || sample_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void samplePubSubType::register_type_object_representation() -{ - register_sample_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "sampleCdrAux.ipp" diff --git a/examples/cpp/dds/SampleConfig_Controller/samplePubSubTypes.h b/examples/cpp/dds/SampleConfig_Controller/samplePubSubTypes.h deleted file mode 100644 index 1ec6375ba7f..00000000000 --- a/examples/cpp/dds/SampleConfig_Controller/samplePubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 samplePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated sample 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 sample defined by the user in the IDL file. - * @ingroup sample - */ -class samplePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef sample type; - - eProsima_user_DllExport samplePubSubType(); - - eProsima_user_DllExport ~samplePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/SampleConfig_Controller/sampleTypeObjectSupport.cxx b/examples/cpp/dds/SampleConfig_Controller/sampleTypeObjectSupport.cxx deleted file mode 100644 index e9dcd1a977b..00000000000 --- a/examples/cpp/dds/SampleConfig_Controller/sampleTypeObjectSupport.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// 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 sampleTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "sampleTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_sample_type_identifier( - TypeIdentifierPair& type_ids_sample) -{ - - ReturnCode_t return_code_sample {eprosima::fastdds::dds::RETCODE_OK}; - return_code_sample = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "sample", type_ids_sample); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_sample) - { - StructTypeFlag struct_flags_sample = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_sample = "sample"; - eprosima::fastcdr::optional type_ann_builtin_sample; - eprosima::fastcdr::optional ann_custom_sample; - CompleteTypeDetail detail_sample = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_sample, ann_custom_sample, type_name_sample.to_string()); - CompleteStructHeader header_sample; - header_sample = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_sample); - CompleteStructMemberSeq member_seq_sample; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_sample.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_sample); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_index); - } - { - TypeIdentifierPair type_ids_key_value; - ReturnCode_t return_code_key_value {eprosima::fastdds::dds::RETCODE_OK}; - return_code_key_value = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_key_value); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_key_value) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "key_value Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_key_value = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, true, false); - MemberId member_id_key_value = 0x00000001; - bool common_key_value_ec {false}; - CommonStructMember common_key_value {TypeObjectUtils::build_common_struct_member(member_id_key_value, member_flags_key_value, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_key_value, common_key_value_ec))}; - if (!common_key_value_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure key_value member TypeIdentifier inconsistent."); - return; - } - MemberName name_key_value = "key_value"; - eprosima::fastcdr::optional member_ann_builtin_key_value; - ann_custom_sample.reset(); - AppliedAnnotationSeq tmp_ann_custom_key_value; - eprosima::fastcdr::optional unit_key_value; - eprosima::fastcdr::optional min_key_value; - eprosima::fastcdr::optional max_key_value; - eprosima::fastcdr::optional hash_id_key_value; - if (unit_key_value.has_value() || min_key_value.has_value() || max_key_value.has_value() || hash_id_key_value.has_value()) - { - member_ann_builtin_key_value = TypeObjectUtils::build_applied_builtin_member_annotations(unit_key_value, min_key_value, max_key_value, hash_id_key_value); - } - if (!tmp_ann_custom_key_value.empty()) - { - ann_custom_sample = tmp_ann_custom_key_value; - } - CompleteMemberDetail detail_key_value = TypeObjectUtils::build_complete_member_detail(name_key_value, member_ann_builtin_key_value, ann_custom_sample); - CompleteStructMember member_key_value = TypeObjectUtils::build_complete_struct_member(common_key_value, detail_key_value); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_key_value); - } - CompleteStructType struct_type_sample = TypeObjectUtils::build_complete_struct_type(struct_flags_sample, header_sample, member_seq_sample); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_sample, type_name_sample.to_string(), type_ids_sample)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "sample already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/SampleConfig_Controller/sampleTypeObjectSupport.hpp b/examples/cpp/dds/SampleConfig_Controller/sampleTypeObjectSupport.hpp deleted file mode 100644 index 013609fa263..00000000000 --- a/examples/cpp/dds/SampleConfig_Controller/sampleTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 sampleTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register sample related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_sample_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/SampleConfig_Events/samplePubSubTypes.cxx b/examples/cpp/dds/SampleConfig_Events/samplePubSubTypes.cxx deleted file mode 100644 index 321f250d975..00000000000 --- a/examples/cpp/dds/SampleConfig_Events/samplePubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 samplePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "samplePubSubTypes.h" - -#include -#include - -#include "sampleCdrAux.hpp" -#include "sampleTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -samplePubSubType::samplePubSubType() -{ - setName("sample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sample::getMaxCdrSerializedSize()); -#else - sample_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -samplePubSubType::~samplePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool samplePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - sample* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool samplePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - sample* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function samplePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* samplePubSubType::createData() -{ - return reinterpret_cast(new sample()); -} - -void samplePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool samplePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - sample* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - sample_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || sample_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void samplePubSubType::register_type_object_representation() -{ - register_sample_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "sampleCdrAux.ipp" diff --git a/examples/cpp/dds/SampleConfig_Events/samplePubSubTypes.h b/examples/cpp/dds/SampleConfig_Events/samplePubSubTypes.h deleted file mode 100644 index 1ec6375ba7f..00000000000 --- a/examples/cpp/dds/SampleConfig_Events/samplePubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 samplePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated sample 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 sample defined by the user in the IDL file. - * @ingroup sample - */ -class samplePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef sample type; - - eProsima_user_DllExport samplePubSubType(); - - eProsima_user_DllExport ~samplePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/SampleConfig_Events/sampleTypeObjectSupport.cxx b/examples/cpp/dds/SampleConfig_Events/sampleTypeObjectSupport.cxx deleted file mode 100644 index e9dcd1a977b..00000000000 --- a/examples/cpp/dds/SampleConfig_Events/sampleTypeObjectSupport.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// 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 sampleTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "sampleTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_sample_type_identifier( - TypeIdentifierPair& type_ids_sample) -{ - - ReturnCode_t return_code_sample {eprosima::fastdds::dds::RETCODE_OK}; - return_code_sample = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "sample", type_ids_sample); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_sample) - { - StructTypeFlag struct_flags_sample = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_sample = "sample"; - eprosima::fastcdr::optional type_ann_builtin_sample; - eprosima::fastcdr::optional ann_custom_sample; - CompleteTypeDetail detail_sample = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_sample, ann_custom_sample, type_name_sample.to_string()); - CompleteStructHeader header_sample; - header_sample = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_sample); - CompleteStructMemberSeq member_seq_sample; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_sample.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_sample); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_index); - } - { - TypeIdentifierPair type_ids_key_value; - ReturnCode_t return_code_key_value {eprosima::fastdds::dds::RETCODE_OK}; - return_code_key_value = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_key_value); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_key_value) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "key_value Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_key_value = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, true, false); - MemberId member_id_key_value = 0x00000001; - bool common_key_value_ec {false}; - CommonStructMember common_key_value {TypeObjectUtils::build_common_struct_member(member_id_key_value, member_flags_key_value, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_key_value, common_key_value_ec))}; - if (!common_key_value_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure key_value member TypeIdentifier inconsistent."); - return; - } - MemberName name_key_value = "key_value"; - eprosima::fastcdr::optional member_ann_builtin_key_value; - ann_custom_sample.reset(); - AppliedAnnotationSeq tmp_ann_custom_key_value; - eprosima::fastcdr::optional unit_key_value; - eprosima::fastcdr::optional min_key_value; - eprosima::fastcdr::optional max_key_value; - eprosima::fastcdr::optional hash_id_key_value; - if (unit_key_value.has_value() || min_key_value.has_value() || max_key_value.has_value() || hash_id_key_value.has_value()) - { - member_ann_builtin_key_value = TypeObjectUtils::build_applied_builtin_member_annotations(unit_key_value, min_key_value, max_key_value, hash_id_key_value); - } - if (!tmp_ann_custom_key_value.empty()) - { - ann_custom_sample = tmp_ann_custom_key_value; - } - CompleteMemberDetail detail_key_value = TypeObjectUtils::build_complete_member_detail(name_key_value, member_ann_builtin_key_value, ann_custom_sample); - CompleteStructMember member_key_value = TypeObjectUtils::build_complete_struct_member(common_key_value, detail_key_value); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_key_value); - } - CompleteStructType struct_type_sample = TypeObjectUtils::build_complete_struct_type(struct_flags_sample, header_sample, member_seq_sample); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_sample, type_name_sample.to_string(), type_ids_sample)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "sample already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/SampleConfig_Events/sampleTypeObjectSupport.hpp b/examples/cpp/dds/SampleConfig_Events/sampleTypeObjectSupport.hpp deleted file mode 100644 index 013609fa263..00000000000 --- a/examples/cpp/dds/SampleConfig_Events/sampleTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 sampleTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register sample related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_sample_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/examples/cpp/dds/SampleConfig_Multimedia/samplePubSubTypes.cxx b/examples/cpp/dds/SampleConfig_Multimedia/samplePubSubTypes.cxx deleted file mode 100644 index 321f250d975..00000000000 --- a/examples/cpp/dds/SampleConfig_Multimedia/samplePubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 samplePubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "samplePubSubTypes.h" - -#include -#include - -#include "sampleCdrAux.hpp" -#include "sampleTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -samplePubSubType::samplePubSubType() -{ - setName("sample"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(sample::getMaxCdrSerializedSize()); -#else - sample_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = sample_max_key_cdr_typesize > 16 ? sample_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -samplePubSubType::~samplePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool samplePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - sample* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool samplePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - sample* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function samplePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* samplePubSubType::createData() -{ - return reinterpret_cast(new sample()); -} - -void samplePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool samplePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - sample* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - sample_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || sample_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void samplePubSubType::register_type_object_representation() -{ - register_sample_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "sampleCdrAux.ipp" diff --git a/examples/cpp/dds/SampleConfig_Multimedia/samplePubSubTypes.h b/examples/cpp/dds/SampleConfig_Multimedia/samplePubSubTypes.h deleted file mode 100644 index 1ec6375ba7f..00000000000 --- a/examples/cpp/dds/SampleConfig_Multimedia/samplePubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 samplePubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated sample 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 sample defined by the user in the IDL file. - * @ingroup sample - */ -class samplePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef sample type; - - eProsima_user_DllExport samplePubSubType(); - - eProsima_user_DllExport ~samplePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_SAMPLE_PUBSUBTYPES_H_ - diff --git a/examples/cpp/dds/SampleConfig_Multimedia/sampleTypeObjectSupport.cxx b/examples/cpp/dds/SampleConfig_Multimedia/sampleTypeObjectSupport.cxx deleted file mode 100644 index e9dcd1a977b..00000000000 --- a/examples/cpp/dds/SampleConfig_Multimedia/sampleTypeObjectSupport.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// 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 sampleTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "sampleTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sample.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_sample_type_identifier( - TypeIdentifierPair& type_ids_sample) -{ - - ReturnCode_t return_code_sample {eprosima::fastdds::dds::RETCODE_OK}; - return_code_sample = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "sample", type_ids_sample); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_sample) - { - StructTypeFlag struct_flags_sample = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, - false, false); - QualifiedTypeName type_name_sample = "sample"; - eprosima::fastcdr::optional type_ann_builtin_sample; - eprosima::fastcdr::optional ann_custom_sample; - CompleteTypeDetail detail_sample = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_sample, ann_custom_sample, type_name_sample.to_string()); - CompleteStructHeader header_sample; - header_sample = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_sample); - CompleteStructMemberSeq member_seq_sample; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_sample.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_sample); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_index); - } - { - TypeIdentifierPair type_ids_key_value; - ReturnCode_t return_code_key_value {eprosima::fastdds::dds::RETCODE_OK}; - return_code_key_value = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_byte", type_ids_key_value); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_key_value) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "key_value Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_key_value = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, - false, false, true, false); - MemberId member_id_key_value = 0x00000001; - bool common_key_value_ec {false}; - CommonStructMember common_key_value {TypeObjectUtils::build_common_struct_member(member_id_key_value, member_flags_key_value, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_key_value, common_key_value_ec))}; - if (!common_key_value_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure key_value member TypeIdentifier inconsistent."); - return; - } - MemberName name_key_value = "key_value"; - eprosima::fastcdr::optional member_ann_builtin_key_value; - ann_custom_sample.reset(); - AppliedAnnotationSeq tmp_ann_custom_key_value; - eprosima::fastcdr::optional unit_key_value; - eprosima::fastcdr::optional min_key_value; - eprosima::fastcdr::optional max_key_value; - eprosima::fastcdr::optional hash_id_key_value; - if (unit_key_value.has_value() || min_key_value.has_value() || max_key_value.has_value() || hash_id_key_value.has_value()) - { - member_ann_builtin_key_value = TypeObjectUtils::build_applied_builtin_member_annotations(unit_key_value, min_key_value, max_key_value, hash_id_key_value); - } - if (!tmp_ann_custom_key_value.empty()) - { - ann_custom_sample = tmp_ann_custom_key_value; - } - CompleteMemberDetail detail_key_value = TypeObjectUtils::build_complete_member_detail(name_key_value, member_ann_builtin_key_value, ann_custom_sample); - CompleteStructMember member_key_value = TypeObjectUtils::build_complete_struct_member(common_key_value, detail_key_value); - TypeObjectUtils::add_complete_struct_member(member_seq_sample, member_key_value); - } - CompleteStructType struct_type_sample = TypeObjectUtils::build_complete_struct_type(struct_flags_sample, header_sample, member_seq_sample); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_sample, type_name_sample.to_string(), type_ids_sample)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "sample already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/examples/cpp/dds/SampleConfig_Multimedia/sampleTypeObjectSupport.hpp b/examples/cpp/dds/SampleConfig_Multimedia/sampleTypeObjectSupport.hpp deleted file mode 100644 index 013609fa263..00000000000 --- a/examples/cpp/dds/SampleConfig_Multimedia/sampleTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 sampleTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register sample related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_sample_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_SAMPLE_TYPE_OBJECT_SUPPORT_HPP_