From a4334774ade8d7cc354781d71bf9c5c9b004e6a1 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Mon, 20 May 2024 15:35:34 +0200 Subject: [PATCH 01/10] Update repository for Fast DDS 3.0.0 compatibility Signed-off-by: Lucia Echevarria --- .../model/DataStreamer.hpp | 12 ++++-- .../model/NetworkDatabase.hpp | 2 +- .../participant/SpyDdsParticipant.hpp | 12 +++--- fastddsspy_participants/package.xml | 2 +- .../project_settings.cmake | 4 +- .../src/cpp/model/DataStreamer.cpp | 18 ++++---- .../src/cpp/participant/SpyDdsParticipant.cpp | 41 ++++++++++++------- .../src/cpp/participant/SpyParticipant.cpp | 4 +- fastddsspy_tool/project_settings.cmake | 2 +- fastddsspy_tool/src/cpp/tool/Controller.cpp | 41 +++++++++++-------- fastddsspy_tool/src/cpp/tool/Controller.hpp | 11 ++--- fastddsspy_yaml/project_settings.cmake | 2 +- 12 files changed, 89 insertions(+), 62 deletions(-) diff --git a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp index 3da7d7b5..7b5f0ea3 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp @@ -17,8 +17,11 @@ #include #include #include +#include -#include +#include + +#include #include #include @@ -39,7 +42,7 @@ class DataStreamer : public TopicRateCalculator using CallbackType = std::function; FASTDDSSPY_PARTICIPANTS_DllAPI @@ -56,7 +59,8 @@ class DataStreamer : public TopicRateCalculator FASTDDSSPY_PARTICIPANTS_DllAPI void add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) override; + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::tuple& type_ids_tuple) override; FASTDDSSPY_PARTICIPANTS_DllAPI void add_data( @@ -80,7 +84,7 @@ class DataStreamer : public TopicRateCalculator ddspipe::core::types::DdsTopic activated_topic_; - std::map types_discovered_; + std::map types_discovered_; mutable std::shared_timed_mutex mutex_; }; diff --git a/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp b/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp index 185665d3..2cf1dd20 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp @@ -14,7 +14,7 @@ #pragma once -#include +#include #include #include diff --git a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp index f7186e20..70d34028 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp @@ -47,18 +47,18 @@ class SpyDdsParticipant : public ddspipe::participants::DynTypesParticipant const ddspipe::core::ITopic& topic) override; FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void on_participant_discovery( - fastdds::dds::DomainParticipant* participant, + virtual void onParticipantDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ParticipantDiscoveryInfo&& info) override; FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void on_subscriber_discovery( - fastdds::dds::DomainParticipant* participant, + virtual void onReaderDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ReaderDiscoveryInfo&& info); FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void on_publisher_discovery( - fastdds::dds::DomainParticipant* participant, + virtual void onWriterDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::WriterDiscoveryInfo&& info); protected: diff --git a/fastddsspy_participants/package.xml b/fastddsspy_participants/package.xml index dc40f5ff..7c296439 100644 --- a/fastddsspy_participants/package.xml +++ b/fastddsspy_participants/package.xml @@ -21,7 +21,7 @@ cpp_utils ddspipe_core ddspipe_participants - fastrtps + fastdds doxygen diff --git a/fastddsspy_participants/project_settings.cmake b/fastddsspy_participants/project_settings.cmake index aaed7e9e..61c9e459 100644 --- a/fastddsspy_participants/project_settings.cmake +++ b/fastddsspy_participants/project_settings.cmake @@ -24,12 +24,12 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants) -set(fastrtps_MINIMUM_VERSION "2.8") +set(fastdds_MINIMUM_VERSION "3.0.0") set(MODULE_DEPENDENCIES $<$:iphlpapi$Shlwapi> diff --git a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp index 12d82e16..d0fbbded 100644 --- a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp +++ b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp @@ -14,11 +14,10 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -73,13 +72,16 @@ void DataStreamer::deactivate() } void DataStreamer::add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::tuple& type_ids_tuple) { + static_cast(type_ids_tuple); + std::unique_lock _(mutex_); // Add type to map if not yet // NOTE: it does not matter if it is already in set - types_discovered_[dynamic_type->get_name()] = dynamic_type; + types_discovered_[dynamic_type->get_name().to_string()] = dynamic_type; logInfo(FASTDDSSPY_DATASTREAMER, "\nAdding schema with name " << dynamic_type->get_name() << "."); } @@ -90,7 +92,7 @@ void DataStreamer::add_data( { TopicRateCalculator::add_data(topic, data); - fastrtps::types::DynamicType_ptr dyn_type; + fastdds::dds::DynamicType::_ref_type dyn_type; { std::shared_lock _(mutex_); diff --git a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp index c9c85f04..0a544ab3 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include +#include #include #include @@ -56,12 +59,14 @@ std::shared_ptr SpyDdsParticipant::create_reader( return ddspipe::participants::DynTypesParticipant::create_reader(topic); } -void SpyDdsParticipant::on_participant_discovery( - fastdds::dds::DomainParticipant* participant, +void SpyDdsParticipant::onParticipantDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ParticipantDiscoveryInfo&& discovery_info) { + fastrtps::rtps::ParticipantProxyData proxy_copy_info(discovery_info.info); + // If comes from this participant is not interesting - if (come_from_this_participant_(discovery_info.info.m_guid)) + if (come_from_this_participant_(proxy_copy_info.m_guid)) { return; } @@ -69,18 +74,22 @@ void SpyDdsParticipant::on_participant_discovery( ParticipantInfo info; info.active = (discovery_info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT || discovery_info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT); - info.name = std::string(discovery_info.info.m_participantName); - info.guid = discovery_info.info.m_guid; + info.name = std::string(proxy_copy_info.m_participantName); + info.guid = proxy_copy_info.m_guid; + + ddspipe::participants::rtps::CommonParticipant::onParticipantDiscovery(participant, std::move(discovery_info)); internal_notify_participant_discovered_(info); } -void SpyDdsParticipant::on_subscriber_discovery( - fastdds::dds::DomainParticipant* participant, +void SpyDdsParticipant::onReaderDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ReaderDiscoveryInfo&& info) { + fastrtps::rtps::ReaderProxyData proxy_copy(info.info); + // If comes from this participant is not interesting - if (come_from_this_participant_(info.info.guid())) + if (come_from_this_participant_(proxy_copy.guid())) { return; } @@ -90,15 +99,19 @@ void SpyDdsParticipant::on_subscriber_discovery( // If participant left or dropped, this notification arrives as well endpoint_info.active = !(info.status == fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERY_STATUS::REMOVED_READER); + ddspipe::participants::DynTypesParticipant::onReaderDiscovery(participant, std::move(info)); + internal_notify_endpoint_discovered_(endpoint_info); } -void SpyDdsParticipant::on_publisher_discovery( - fastdds::dds::DomainParticipant* participant, +void SpyDdsParticipant::onWriterDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::WriterDiscoveryInfo&& info) { + fastrtps::rtps::WriterProxyData proxy_copy(info.info); + // If comes from this participant is not interesting - if (come_from_this_participant_(info.info.guid())) + if (come_from_this_participant_(proxy_copy.guid())) { return; } @@ -108,6 +121,8 @@ void SpyDdsParticipant::on_publisher_discovery( // If participant left or dropped, this notification arrives as well endpoint_info.active = !(info.status == fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::REMOVED_WRITER); + ddspipe::participants::DynTypesParticipant::onWriterDiscovery(participant, std::move(info)); + internal_notify_endpoint_discovered_(endpoint_info); } @@ -140,9 +155,7 @@ void SpyDdsParticipant::internal_notify_endpoint_discovered_( bool SpyDdsParticipant::come_from_this_participant_( const ddspipe::core::types::Guid& guid) const noexcept { - return (guid.guid_prefix() == dds_participant_->guid().guidPrefix - || guid.guid_prefix() == rtps_participant_->getGuid().guidPrefix - ); + return (guid.guid_prefix() == rtps_participant_->getGuid().guidPrefix); } } /* namespace participants */ diff --git a/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp index ad7ac427..22edf344 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp @@ -75,7 +75,7 @@ utils::ReturnCode SpyParticipant::new_participant_info_( ParticipantInfo info = participant_info.info; ddspipe::core::types::Guid guid = info.guid; model_->participant_database_.add_or_modify(std::move(guid), std::move(info)); - return utils::ReturnCode::RETCODE_OK; + return utils::ReturnCode::OK; } utils::ReturnCode SpyParticipant::new_endpoint_info_( @@ -86,7 +86,7 @@ utils::ReturnCode SpyParticipant::new_endpoint_info_( EndpointInfo info = endpoint_info.info; ddspipe::core::types::Guid guid = info.guid; model_->endpoint_database_.add_or_modify(std::move(guid), std::move(info)); - return utils::ReturnCode::RETCODE_OK; + return utils::ReturnCode::OK; } } /* namespace participants */ diff --git a/fastddsspy_tool/project_settings.cmake b/fastddsspy_tool/project_settings.cmake index 89b44db8..40cb75d9 100644 --- a/fastddsspy_tool/project_settings.cmake +++ b/fastddsspy_tool/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/fastddsspy_tool/src/cpp/tool/Controller.cpp b/fastddsspy_tool/src/cpp/tool/Controller.cpp index 3397d743..67c83e0c 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.cpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.cpp @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -111,25 +111,26 @@ void Controller::run_command_( } } -fastrtps::types::DynamicData_ptr Controller::get_dynamic_data_( - const fastrtps::types::DynamicType_ptr& dyn_type, +fastdds::dds::DynamicData::_ref_type Controller::get_dynamic_data_( + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) noexcept { // TODO fast this should not be done, but dyn types API is like it is. auto& data_no_const = const_cast(data); // Create PubSub Type - fastrtps::types::DynamicPubSubType pubsub_type(dyn_type); - fastrtps::types::DynamicData_ptr dyn_data(fastrtps::types::DynamicDataFactory::get_instance()->create_data(dyn_type)); + fastdds::dds::DynamicPubSubType pubsub_type(dyn_type); + fastdds::dds::DynamicData::_ref_type dyn_data(fastdds::dds::DynamicDataFactory::get_instance()->create_data(dyn_type)); - pubsub_type.deserialize(&data_no_const.payload, dyn_data.get()); + // pubsub_type.deserialize(&data_no_const.payload, dyn_data.get()); + pubsub_type.deserialize(&data_no_const.payload, &dyn_data); return dyn_data; } void Controller::data_stream_callback_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) { // Block entrance so prints does not collapse @@ -141,13 +142,16 @@ void Controller::data_stream_callback_( // TODO fast this does not make much sense as dynamictypes::print does not allow to choose target // change in dyn types to be able to print it in view view_.show("---"); - fastrtps::types::DynamicDataHelper::print(dyn_data.get()); + std::stringstream ss; + ss << std::setw(4); + auto ret = fastdds::dds::json_serialize(dyn_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + std::cout << ss.str() << std::endl; view_.show("---\n"); } void Controller::data_stream_callback_verbose_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) { // Block entrance so prints does not collapse @@ -170,7 +174,10 @@ void Controller::data_stream_callback_verbose_( // Print data view_.show("data:\n---"); - fastrtps::types::DynamicDataHelper::print(dyn_data.get()); + std::stringstream ss; + ss << std::setw(4); + auto ret = fastdds::dds::json_serialize(dyn_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + std::cout << ss.str() << std::endl; view_.show("---\n"); } @@ -310,7 +317,7 @@ void Controller::print_command_( std::make_shared( [this]( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data ) { @@ -363,7 +370,7 @@ void Controller::print_command_( callback = std::make_shared( [this]( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data ) { @@ -375,7 +382,7 @@ void Controller::print_command_( callback = std::make_shared( [this]( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data ) { diff --git a/fastddsspy_tool/src/cpp/tool/Controller.hpp b/fastddsspy_tool/src/cpp/tool/Controller.hpp index 7d722861..c5860092 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.hpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.hpp @@ -17,7 +17,8 @@ #include #include -#include +#include +#include #include @@ -52,18 +53,18 @@ class Controller //////////////////////////// // DATA STREAM CALLBACKS - static fastrtps::types::DynamicData_ptr get_dynamic_data_( - const fastrtps::types::DynamicType_ptr& dyn_type, + static fastdds::dds::DynamicData::_ref_type get_dynamic_data_( + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) noexcept; void data_stream_callback_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data); void data_stream_callback_verbose_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data); ///////////////////// diff --git a/fastddsspy_yaml/project_settings.cmake b/fastddsspy_yaml/project_settings.cmake index c8540d1d..3b024885 100644 --- a/fastddsspy_yaml/project_settings.cmake +++ b/fastddsspy_yaml/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants From f6a86e1e727f793cc4ecb0428bfa637e671ffd8c Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Thu, 11 Jul 2024 16:13:59 +0200 Subject: [PATCH 02/10] Regenerate types and change fastrtps dependency to fastdds Signed-off-by: Lucia Echevarria --- .../installation/sources/linux.rst | 2 +- .../installation/sources/windows.rst | 4 +- .../test/blackbox/model/CMakeLists.txt | 4 +- .../test/unittest/model/CMakeLists.txt | 2 +- .../unittest/visualization/CMakeLists.txt | 2 +- .../AdvancedConfigurationPublisher.h | 6 +- .../AdvancedConfigurationSubscriber.h | 6 +- .../CMakeLists.txt | 17 +- .../AdvancedConfigurationExample/README.md | 2 +- .../types/{v2/HelloWorld.h => HelloWorld.hpp} | 125 +++++--- .../types/{v1 => }/HelloWorld.idl | 0 .../types/{v2 => }/HelloWorldCdrAux.hpp | 10 +- .../types/{v2 => }/HelloWorldCdrAux.ipp | 8 +- .../types/{v2 => }/HelloWorldPubSubTypes.cxx | 31 +- ...ubSubTypes.h => HelloWorldPubSubTypes.hpp} | 43 +-- .../types/HelloWorldTypeObjectSupport.cxx | 164 ++++++++++ .../types/HelloWorldTypeObjectSupport.hpp | 56 ++++ .../types/v1/HelloWorld.cxx | 227 -------------- .../types/v1/HelloWorld.h | 235 -------------- .../types/v1/HelloWorldPubSubTypes.cxx | 170 ----------- .../types/v1/HelloWorldPubSubTypes.h | 145 --------- .../types/v2/HelloWorld.cxx | 168 ---------- .../types/v2/HelloWorld.idl | 5 - .../types/v2/HelloWorldv1.cxx | 288 ------------------ .../types/v2/HelloWorldv1.h | 243 --------------- 25 files changed, 362 insertions(+), 1601 deletions(-) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/{v2/HelloWorld.h => HelloWorld.hpp} (70%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/{v1 => }/HelloWorld.idl (100%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/{v2 => }/HelloWorldCdrAux.hpp (86%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/{v2 => }/HelloWorldCdrAux.ipp (96%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/{v2 => }/HelloWorldPubSubTypes.cxx (89%) rename fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/{v2/HelloWorldPubSubTypes.h => HelloWorldPubSubTypes.hpp} (74%) create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.cxx create mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.hpp delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.cxx delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.cxx delete mode 100644 fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.h diff --git a/docs/rst/developer_manual/installation/sources/linux.rst b/docs/rst/developer_manual/installation/sources/linux.rst index 12ed4a0c..cc9ae9e0 100644 --- a/docs/rst/developer_manual/installation/sources/linux.rst +++ b/docs/rst/developer_manual/installation/sources/linux.rst @@ -25,7 +25,7 @@ The following packages will be installed: - ``foonathan_memory_vendor``, an STL compatible C++ memory allocation library. - ``fastcdr``, a C++ library that serializes according to the standard CDR serialization mechanism. -- ``fastrtps``, the core library of eProsima Fast DDS library. +- ``fastdds``, the core library of eProsima Fast DDS library. - ``cmake_utils``, an eProsima utils library for CMake. - ``cpp_utils``, an eProsima utils library for C++. - ``ddspipe``, an eProsima internal library that enables the communication of DDS interfaces. diff --git a/docs/rst/developer_manual/installation/sources/windows.rst b/docs/rst/developer_manual/installation/sources/windows.rst index 20adf52f..bea5ff3a 100644 --- a/docs/rst/developer_manual/installation/sources/windows.rst +++ b/docs/rst/developer_manual/installation/sources/windows.rst @@ -25,7 +25,7 @@ The following packages will be installed: - ``foonathan_memory_vendor``, an STL compatible C++ memory allocation library. - ``fastcdr``, a C++ library that serializes according to the standard CDR serialization mechanism. -- ``fastrtps``, the core library of eProsima Fast DDS library. +- ``fastdds``, the core library of eProsima Fast DDS library. - ``cmake_utils``, an eProsima utils library for CMake. - ``cpp_utils``, an eProsima utils library for C++. - ``ddspipe``, an eProsima internal library that enables the communication of DDS interfaces. @@ -255,7 +255,7 @@ There are two possibilities: However, when running an instance of a |spy| compiled using CMake, it must be linked with its dependencies where the packages have been installed. This can be done by opening the *Edit system environment variables* control panel and adding to the ``PATH`` the |espy|, *Fast DDS*, *Fast CDR*, *DDS Pipe* installation directories: -* *Fast DDS*: ``C:\\Program Files\\fastrtps`` +* *Fast DDS*: ``C:\\Program Files\\fastdds`` * *Fast CDR*: ``C:\\Program Files\\fastcdr`` * *DDS Pipe*: ``C:\\Program Files\\ddspipe`` * |espy|: ``C:\\Program Files\\ddsrecord`` diff --git a/fastddsspy_participants/test/blackbox/model/CMakeLists.txt b/fastddsspy_participants/test/blackbox/model/CMakeLists.txt index 4c5a6d1a..ce3c8741 100644 --- a/fastddsspy_participants/test/blackbox/model/CMakeLists.txt +++ b/fastddsspy_participants/test/blackbox/model/CMakeLists.txt @@ -36,7 +36,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants @@ -80,7 +80,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/fastddsspy_participants/test/unittest/model/CMakeLists.txt b/fastddsspy_participants/test/unittest/model/CMakeLists.txt index a8799af1..fc315f77 100644 --- a/fastddsspy_participants/test/unittest/model/CMakeLists.txt +++ b/fastddsspy_participants/test/unittest/model/CMakeLists.txt @@ -31,7 +31,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/fastddsspy_participants/test/unittest/visualization/CMakeLists.txt b/fastddsspy_participants/test/unittest/visualization/CMakeLists.txt index 438ed18a..c7e985e4 100644 --- a/fastddsspy_participants/test/unittest/visualization/CMakeLists.txt +++ b/fastddsspy_participants/test/unittest/visualization/CMakeLists.txt @@ -72,7 +72,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h index 9dcd599a..304aa09e 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h @@ -28,11 +28,7 @@ #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include "types/v1/HelloWorldPubSubTypes.h" -#else - #include "types/v2/HelloWorldPubSubTypes.h" -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 +#include "types/HelloWorldPubSubTypes.hpp" #include "types.hpp" diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h index b3e0ccc8..786f78f5 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h @@ -28,11 +28,7 @@ #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include "types/v1/HelloWorldPubSubTypes.h" -#else - #include "types/v2/HelloWorldPubSubTypes.h" -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 +"types/HelloWorldPubSubTypes.hpp" #include "types.hpp" diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt index 1129030f..95701442 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt @@ -21,8 +21,8 @@ if(NOT fastcdr_FOUND) find_package(fastcdr REQUIRED) endif() -if(NOT fastrtps_FOUND) - find_package(fastrtps REQUIRED) +if(NOT fastdds_FOUND) + find_package(fastdds REQUIRED) endif() #Check C++11 @@ -35,23 +35,16 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") endif() endif() -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "v1") -else() - set(DDS_TYPES_VERSION "v2") -endif() - message(STATUS "Configuring AdvancedConfiguration example...") file( GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX "*.cxx" - "types/${DDS_TYPES_VERSION}/*.cxx" + "types/*.cxx" ) file( GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP "*.cpp" - "types/${DDS_TYPES_VERSION}/*.cpp" + "types/*.cpp" ) add_executable(${PROJECT_NAME} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP}) @@ -61,7 +54,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport ) -target_link_libraries(${PROJECT_NAME} fastrtps fastcdr fastdds::optionparser) +target_link_libraries(${PROJECT_NAME} fastdds fastcdr fastdds::optionparser) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION examples/cpp/dds/${PROJECT_NAME}/${BIN_INSTALL_DIR}) diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md index d824ad75..8ee4e1d0 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/README.md @@ -96,5 +96,5 @@ This code presents how to run a publisher with this example without Shared Memor ```sh # From AdvancedConfigurationExample installation dir -FASTRTPS_DEFAULT_PROFILES_FILE=shm_off.xml ./AdvancedConfigurationExample publisher --xml-profile no_shm_participant_profile +FASTDDS_DEFAULT_PROFILES_FILE=shm_off.xml ./AdvancedConfigurationExample publisher --xml-profile no_shm_participant_profile ``` diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorld.hpp similarity index 70% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.h rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorld.hpp index aaf09e4b..91c4d338 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorld.hpp @@ -13,32 +13,18 @@ // limitations under the License. /*! - * @file HelloWorld.h + * @file HelloWorld.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "HelloWorldv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_HPP #include -#include #include -#include -#include -#include - -#include -#include -#include - - +#include #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +50,6 @@ #define HELLOWORLD_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -86,73 +61,117 @@ class HelloWorld /*! * @brief Default constructor. */ - eProsima_user_DllExport HelloWorld(); + eProsima_user_DllExport HelloWorld() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~HelloWorld(); + eProsima_user_DllExport ~HelloWorld() + { + } /*! * @brief Copy constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - const HelloWorld& x); + const HelloWorld& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); + const HelloWorld& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -160,26 +179,40 @@ class HelloWorld * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::array& _message); + const std::array& _message) + { + m_message = _message; + } /*! * @brief This function moves the value in member message * @param _message New value to be moved in member message */ eProsima_user_DllExport void message( - std::array&& _message); + std::array&& _message) + { + m_message = std::move(_message); + } /*! * @brief This function returns a constant reference to member message * @return Constant reference to member message */ - eProsima_user_DllExport const std::array& message() const; + eProsima_user_DllExport const std::array& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::array& message(); + eProsima_user_DllExport std::array& message() + { + return m_message; + } + + private: @@ -188,8 +221,6 @@ class HelloWorld }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - +#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.idl b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorld.idl similarity index 100% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.idl rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorld.idl diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.hpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.hpp similarity index 86% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.hpp rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.hpp index 5c8468e7..8a4309ca 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.hpp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.hpp @@ -19,10 +19,10 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP -#include "HelloWorld.h" +#include "HelloWorld.hpp" constexpr uint32_t HelloWorld_max_cdr_typesize {28UL}; constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); @@ -44,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.ipp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.ipp similarity index 96% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.ipp rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.ipp index 42e91f3c..19316df7 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldCdrAux.ipp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP #include "HelloWorldCdrAux.hpp" @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -124,5 +122,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.cxx similarity index 89% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.cxx rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.cxx index 0e375416..38393dbf 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.cxx +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.cxx @@ -19,18 +19,18 @@ * This file was generated by the tool fastddsgen. */ +#include "HelloWorldPubSubTypes.hpp" +#include #include -#include "HelloWorldPubSubTypes.h" #include "HelloWorldCdrAux.hpp" +#include "HelloWorldTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); @@ -57,11 +57,11 @@ HelloWorldPubSubType::~HelloWorldPubSubType() } bool HelloWorldPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool HelloWorldPubSubType::deserialize( } std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( 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)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void HelloWorldPubSubType::deleteData( } bool HelloWorldPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool HelloWorldPubSubType::getKey( return false; } - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), @@ -218,3 +218,12 @@ bool HelloWorldPubSubType::getKey( } 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/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.hpp similarity index 74% rename from fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.h rename to fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.hpp index ddbfbab5..75830b9c 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldPubSubTypes.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.hpp @@ -13,23 +13,23 @@ // limitations under the License. /*! - * @file HelloWorldPubSubTypes.h + * @file HelloWorldPubSubTypes.hpp * 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_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include -#include "HelloWorld.h" +#include "HelloWorld.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -55,34 +53,34 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~HelloWorldPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::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, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; @@ -90,6 +88,9 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType 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 { @@ -105,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -123,10 +124,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.cxx new file mode 100644 index 00000000..0b3e6881 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.cxx @@ -0,0 +1,164 @@ +// 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::APPENDABLE, + 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::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_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::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_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/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.hpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.hpp new file mode 100644 index 00000000..ec922163 --- /dev/null +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx deleted file mode 100644 index 42283dee..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.cxx +++ /dev/null @@ -1,227 +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 HelloWorld.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define HelloWorld_max_cdr_typesize 24ULL; -#define HelloWorld_max_key_cdr_typesize 0ULL; - -HelloWorld::HelloWorld() -{ - // unsigned long m_index - m_index = 0; - // char m_message - memset(&m_message, 0, (20) * 1); - -} - -HelloWorld::~HelloWorld() -{ - - -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - - return (m_index == x.m_index && m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return HelloWorld_max_cdr_typesize; -} - -size_t HelloWorld::getCdrSerializedSize( - const HelloWorld& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += ((20) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - -void HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_index; - scdr << m_message; - - -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_index; - dcdr >> m_message; - -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::message( - const std::array& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void HelloWorld::message( - std::array&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::array& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::array& HelloWorld::message() -{ - return m_message; -} - -size_t HelloWorld::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return HelloWorld_max_key_cdr_typesize; -} - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h deleted file mode 100644 index 8c2988e5..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorld.h +++ /dev/null @@ -1,235 +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 HelloWorld.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::array& _message); - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::array&& _message); - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::array& message() const; - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::array& message(); - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const HelloWorld& data, - size_t current_alignment = 0); - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - /*! - * @brief This function returns the maximum serialized size of the Key of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - -private: - - uint32_t m_index; - std::array m_message; - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx deleted file mode 100644 index df22dd59..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.cxx +++ /dev/null @@ -1,170 +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 fastcdrgen. - */ - - -#include -#include - -#include "HelloWorldPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -HelloWorldPubSubType::HelloWorldPubSubType() -{ - setName("HelloWorld"); - auto type_size = HelloWorld::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = HelloWorld::isKeyDefined(); - size_t keyLength = HelloWorld::getKeyMaxCdrSerializedSize() > 16 ? - HelloWorld::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloWorldPubSubType::~HelloWorldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloWorldPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} - -bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::Cdr::DDS_CDR); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* HelloWorldPubSubType::createData() -{ - return reinterpret_cast(new HelloWorld()); -} - -void HelloWorldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloWorldPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || HelloWorld::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h deleted file mode 100644 index d7b5d31d..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v1/HelloWorldPubSubTypes.h +++ /dev/null @@ -1,145 +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 fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - -#include -#include - -#include "HelloWorld.h" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - -#ifndef SWIG -namespace detail { - -template -struct HelloWorld_rob -{ - friend constexpr typename Tag::type get( - Tag) - { - return M; - } - -}; - -struct HelloWorld_f -{ - typedef std::array HelloWorld::* type; - friend constexpr type get( - HelloWorld_f); -}; - -template struct HelloWorld_rob; - -template -inline size_t constexpr HelloWorld_offset_of() -{ - return ((::size_t) &reinterpret_cast((((T*)0)->*get(Tag())))); -} - -} // namespace detail -#endif // ifndef SWIG - -/*! - * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport virtual ~HelloWorldPubSubType() override; - - eProsima_user_DllExport virtual bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - - eProsima_user_DllExport virtual bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport virtual std::function getSerializedSizeProvider( - void* data) override; - - eProsima_user_DllExport virtual bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport virtual void* createData() override; - - eProsima_user_DllExport virtual void deleteData( - void* data) override; - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - -#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return is_plain_impl(); - } - -#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - -#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - new (memory) HelloWorld(); - return true; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -private: - - static constexpr bool is_plain_impl() - { - return 24ULL == - (detail::HelloWorld_offset_of() + sizeof(std::array)); - - } - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.cxx deleted file mode 100644 index 0d9236d0..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -HelloWorld::HelloWorld() -{ -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::message( - const std::array& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void HelloWorld::message( - std::array&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::array& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::array& HelloWorld::message() -{ - return m_message; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl deleted file mode 100644 index 9750fbe1..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorld.idl +++ /dev/null @@ -1,5 +0,0 @@ -struct HelloWorld -{ - unsigned long index; - char message[20]; -}; diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.cxx deleted file mode 100644 index 3b9a562b..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.cxx +++ /dev/null @@ -1,288 +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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define HelloWorld_max_cdr_typesize 28ULL; - - - - -HelloWorld::HelloWorld() -{ - // unsigned long m_index - m_index = 0; - // char m_message - memset(&m_message, 0, ((20)) * 1); - -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return HelloWorld_max_cdr_typesize; -} - -size_t HelloWorld::getCdrSerializedSize( - const HelloWorld& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += (((20)) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - - return current_alignment - initial_alignment; -} - - -void HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_message; - - -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_message; - - -} - - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::message( - const std::array& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void HelloWorld::message( - std::array&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::array& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::array& HelloWorld::message() -{ - return m_message; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.h deleted file mode 100644 index 4d6e4158..00000000 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/v2/HelloWorldv1.h +++ /dev/null @@ -1,243 +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 HelloWorld.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - - -#include - -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::array& _message); - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::array&& _message); - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::array& message() const; - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::array& message(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const HelloWorld& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - uint32_t m_index; - std::array m_message; - -}; - - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 From 9387a18d35d50dffce62762ae837099d864ed23e Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Thu, 11 Jul 2024 16:32:00 +0200 Subject: [PATCH 03/10] Continue updating to Fast DDS 3.x Signed-off-by: Lucia Echevarria --- .../model/DataStreamer.hpp | 3 +- .../participant/SpyDdsParticipant.hpp | 21 ++-- .../src/cpp/model/DataStreamer.cpp | 7 +- .../src/cpp/participant/SpyDdsParticipant.cpp | 43 ++++---- .../src/cpp/testing/random_values.cpp | 2 +- .../test/unittest/model/DataStreamerTest.cpp | 99 +++++++++++-------- fastddsspy_tool/src/cpp/tool/Controller.cpp | 4 +- .../AdvancedConfigurationPublisher.cpp | 13 ++- .../AdvancedConfigurationSubscriber.cpp | 11 +-- .../AdvancedConfigurationSubscriber.h | 2 +- 10 files changed, 115 insertions(+), 90 deletions(-) diff --git a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp index 7b5f0ea3..59890369 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp @@ -60,7 +60,8 @@ class DataStreamer : public TopicRateCalculator FASTDDSSPY_PARTICIPANTS_DllAPI void add_schema( const fastdds::dds::DynamicType::_ref_type& dynamic_type, - const std::tuple& type_ids_tuple) override; + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id) override; FASTDDSSPY_PARTICIPANTS_DllAPI void add_data( diff --git a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp index 70d34028..f33e2e5a 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp @@ -47,19 +47,22 @@ class SpyDdsParticipant : public ddspipe::participants::DynTypesParticipant const ddspipe::core::ITopic& topic) override; FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void onParticipantDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ParticipantDiscoveryInfo&& info) override; + void onParticipantDiscovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ParticipantDiscoveryInfo&& info, + bool& should_be_ignored) override; FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void onReaderDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ReaderDiscoveryInfo&& info); + void onReaderDiscovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ReaderDiscoveryInfo&& info, + bool& should_be_ignored) override; FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void onWriterDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::WriterDiscoveryInfo&& info); + void onWriterDiscovery( + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::WriterDiscoveryInfo&& info, + bool& should_be_ignored) override; protected: diff --git a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp index d0fbbded..883af6ef 100644 --- a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp +++ b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp @@ -73,15 +73,16 @@ void DataStreamer::deactivate() void DataStreamer::add_schema( const fastdds::dds::DynamicType::_ref_type& dynamic_type, - const std::tuple& type_ids_tuple) + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id) { - static_cast(type_ids_tuple); + static_cast(type_id); std::unique_lock _(mutex_); // Add type to map if not yet // NOTE: it does not matter if it is already in set - types_discovered_[dynamic_type->get_name().to_string()] = dynamic_type; + types_discovered_[type_name] = dynamic_type; logInfo(FASTDDSSPY_DATASTREAMER, "\nAdding schema with name " << dynamic_type->get_name() << "."); } diff --git a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp index 0a544ab3..6f662ffa 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -60,10 +60,11 @@ std::shared_ptr SpyDdsParticipant::create_reader( } void SpyDdsParticipant::onParticipantDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ParticipantDiscoveryInfo&& discovery_info) + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ParticipantDiscoveryInfo&& discovery_info, + bool& should_be_ignored) { - fastrtps::rtps::ParticipantProxyData proxy_copy_info(discovery_info.info); + fastdds::rtps::ParticipantProxyData proxy_copy_info(discovery_info.info); // If comes from this participant is not interesting if (come_from_this_participant_(proxy_copy_info.m_guid)) @@ -72,21 +73,22 @@ void SpyDdsParticipant::onParticipantDiscovery( } ParticipantInfo info; - info.active = (discovery_info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT - || discovery_info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT); + info.active = (discovery_info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT + || discovery_info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT); info.name = std::string(proxy_copy_info.m_participantName); info.guid = proxy_copy_info.m_guid; - ddspipe::participants::rtps::CommonParticipant::onParticipantDiscovery(participant, std::move(discovery_info)); + ddspipe::participants::rtps::CommonParticipant::onParticipantDiscovery(participant, std::move(discovery_info), should_be_ignored); internal_notify_participant_discovered_(info); } void SpyDdsParticipant::onReaderDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::ReaderDiscoveryInfo&& info) + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::ReaderDiscoveryInfo&& info, + bool& should_be_ignored) { - fastrtps::rtps::ReaderProxyData proxy_copy(info.info); + fastdds::rtps::ReaderProxyData proxy_copy(info.info); // If comes from this participant is not interesting if (come_from_this_participant_(proxy_copy.guid())) @@ -97,18 +99,19 @@ void SpyDdsParticipant::onReaderDiscovery( EndpointInfo endpoint_info = ddspipe::participants::detail::create_endpoint_from_info_(info, id()); // If participant left or dropped, this notification arrives as well - endpoint_info.active = !(info.status == fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERY_STATUS::REMOVED_READER); + endpoint_info.active = !(info.status == fastdds::rtps::ReaderDiscoveryInfo::DISCOVERY_STATUS::REMOVED_READER); - ddspipe::participants::DynTypesParticipant::onReaderDiscovery(participant, std::move(info)); + ddspipe::participants::DynTypesParticipant::onReaderDiscovery(participant, std::move(info), should_be_ignored); internal_notify_endpoint_discovered_(endpoint_info); } void SpyDdsParticipant::onWriterDiscovery( - fastrtps::rtps::RTPSParticipant* participant, - fastrtps::rtps::WriterDiscoveryInfo&& info) + fastdds::rtps::RTPSParticipant* participant, + fastdds::rtps::WriterDiscoveryInfo&& info, + bool& should_be_ignored) { - fastrtps::rtps::WriterProxyData proxy_copy(info.info); + fastdds::rtps::WriterProxyData proxy_copy(info.info); // If comes from this participant is not interesting if (come_from_this_participant_(proxy_copy.guid())) @@ -119,9 +122,9 @@ void SpyDdsParticipant::onWriterDiscovery( EndpointInfo endpoint_info = ddspipe::participants::detail::create_endpoint_from_info_(info, id()); // If participant left or dropped, this notification arrives as well - endpoint_info.active = !(info.status == fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::REMOVED_WRITER); + endpoint_info.active = !(info.status == fastdds::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::REMOVED_WRITER); - ddspipe::participants::DynTypesParticipant::onWriterDiscovery(participant, std::move(info)); + ddspipe::participants::DynTypesParticipant::onWriterDiscovery(participant, std::move(info), should_be_ignored); internal_notify_endpoint_discovered_(endpoint_info); } diff --git a/fastddsspy_participants/src/cpp/testing/random_values.cpp b/fastddsspy_participants/src/cpp/testing/random_values.cpp index 13dc7029..81233b61 100644 --- a/fastddsspy_participants/src/cpp/testing/random_values.cpp +++ b/fastddsspy_participants/src/cpp/testing/random_values.cpp @@ -22,7 +22,7 @@ ddspipe::core::types::Guid random_guid_same_prefix( unsigned int seed /* = 1 */) { ddspipe::core::types::Guid guid; - guid.entityId.value[3] = static_cast(seed); + guid.entityId.value[3] = static_cast(seed); guid.guidPrefix.value[0] = 0x01; guid.guidPrefix.value[1] = 0x0f; return guid; diff --git a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp index 690f7f83..34f468be 100644 --- a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp +++ b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp @@ -15,24 +15,35 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include using namespace eprosima; -void create_schema( - ddspipe::core::types::DdsTopic& topic, - fastrtps::types::DynamicType_ptr& dynamic_type_topic) +fastdds::dds::DynamicType::_ref_type create_schema( + ddspipe::core::types::DdsTopic& topic) { - fastrtps::types::DynamicTypeBuilder_ptr dynamic_type_topic_builder; - dynamic_type_topic_builder = fastrtps::types::DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - - dynamic_type_topic_builder->set_name(topic.type_name); - dynamic_type_topic = dynamic_type_topic_builder->build(); + // // Opción 1: + // fastdds::dds::TypeSupport type(new DynamicPubSubType(dynamic_type_topic)); + // type->setName(topic.type_name); + + // Lo que había antes + // fastdds::dds::DynamicTypeBuilder:_ref_type dynamic_type_topic_builder; + // dynamic_type_topic_builder = fastrtps::types::DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); + + // dynamic_type_topic_builder->set_name(topic.type_name); + // dynamic_type_topic = dynamic_type_topic_builder->build(); + + // Opción 2: + fastdds::dds::TypeDescriptor::_ref_type type_descriptor {fastdds::dds::traits::make_shared()}; + type_descriptor->name(topic.type_name); + fastdds::dds::DynamicTypeBuilder::_ref_type struct_builder {fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)}; + fastdds::dds::DynamicType::_ref_type dynamic_type_topic {struct_builder->build()}; + return dynamic_type_topic; } TEST(DataStreamerTest, activate_false) @@ -58,10 +69,11 @@ TEST(DataStreamerTest, activate_true) std::shared_ptr cb = std::make_shared(); - fastrtps::types::DynamicType_ptr dynamic_type_topic; - create_schema(topic, dynamic_type_topic); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic; + dynamic_type_topic = create_schema(topic); - ds.add_schema(dynamic_type_topic); + fastdds::dds::xtypes::TypeIdentifier type_id; + ds.add_schema(dynamic_type_topic, topic.type_name, type_id); ASSERT_TRUE(ds.activate(topic, cb)); } @@ -77,19 +89,21 @@ TEST(DataStreamerTest, activate_twice) std::shared_ptr cb = std::make_shared(); - fastrtps::types::DynamicType_ptr dynamic_type_topic_1; - create_schema(topic_1, dynamic_type_topic_1); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic_1; + dynamic_type_topic_1 = create_schema(topic_1); - ds.add_schema(dynamic_type_topic_1); + fastdds::dds::xtypes::TypeIdentifier type_id_1; + ds.add_schema(dynamic_type_topic_1, topic_1.type_name, type_id_1); ddspipe::core::types::DdsTopic topic_2; topic_2.m_topic_name = "topic2"; topic_2.type_name = "type2"; - fastrtps::types::DynamicType_ptr dynamic_type_topic_2; - create_schema(topic_2, dynamic_type_topic_2); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic_2; + dynamic_type_topic_2 = create_schema(topic_2); - ds.add_schema(dynamic_type_topic_2); + fastdds::dds::xtypes::TypeIdentifier type_id_2; + ds.add_schema(dynamic_type_topic_2, topic_2.type_name, type_id_2); // is this the correct behaviour? ASSERT_TRUE(ds.activate(topic_1, cb)); @@ -110,10 +124,11 @@ TEST(DataStreamerTest, topic_type_discovered) topic_2.m_topic_name = "topic2"; topic_2.type_name = "type2"; - fastrtps::types::DynamicType_ptr dynamic_type_topic_2; - create_schema(topic_2, dynamic_type_topic_2); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic_2; + dynamic_type_topic_2 = create_schema(topic_2); - ds.add_schema(dynamic_type_topic_2); + fastdds::dds::xtypes::TypeIdentifier type_id; + ds.add_schema(dynamic_type_topic_2, topic_2.type_name, type_id); ASSERT_TRUE(ds.is_topic_type_discovered(topic_2)); } @@ -131,16 +146,17 @@ TEST(DataStreamerTest, deactivate) std::make_shared( [&data_sent] (const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& type, + const fastdds::dds::DynamicType::_ref_type& type, const ddspipe::core::types::RtpsPayloadData& data) { data_sent++; }); - fastrtps::types::DynamicType_ptr dynamic_type_topic; - create_schema(topic, dynamic_type_topic); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic; + dynamic_type_topic = create_schema(topic); - ds.add_schema(dynamic_type_topic); + fastdds::dds::xtypes::TypeIdentifier type_id; + ds.add_schema(dynamic_type_topic, topic.type_name, type_id); ds.activate(topic, cb); @@ -178,16 +194,17 @@ TEST(DataStreamerTest, add_data) std::make_shared( [&data_sent] (const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& type, + const fastdds::dds::DynamicType::_ref_type& type, const ddspipe::core::types::RtpsPayloadData& data) { data_sent++; }); - fastrtps::types::DynamicType_ptr dynamic_type_topic; - create_schema(topic, dynamic_type_topic); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic; + dynamic_type_topic = create_schema(topic); - ds.add_schema(dynamic_type_topic); + fastdds::dds::xtypes::TypeIdentifier type_id; + ds.add_schema(dynamic_type_topic, topic.type_name, type_id); ds.activate(topic, cb); @@ -217,16 +234,17 @@ TEST(DataStreamerTest, add_data_two_topics) std::make_shared( [&data_sent_1] (const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& type, + const fastdds::dds::DynamicType::_ref_type& type, const ddspipe::core::types::RtpsPayloadData& data) { data_sent_1++; }); - fastrtps::types::DynamicType_ptr dynamic_type_topic_1; - create_schema(topic_1, dynamic_type_topic_1); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic_1; + dynamic_type_topic_1 = create_schema(topic_1); - ds.add_schema(dynamic_type_topic_1); + fastdds::dds::xtypes::TypeIdentifier type_id_1; + ds.add_schema(dynamic_type_topic_1, topic_1.type_name, type_id_1); ds.activate(topic_1, cb_1); @@ -240,16 +258,17 @@ TEST(DataStreamerTest, add_data_two_topics) std::make_shared( [&data_sent_2] (const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& type, + const fastdds::dds::DynamicType::_ref_type& type, const ddspipe::core::types::RtpsPayloadData& data) { data_sent_2++; }); - fastrtps::types::DynamicType_ptr dynamic_type_topic_2; - create_schema(topic_2, dynamic_type_topic_2); + fastdds::dds::DynamicType::_ref_type dynamic_type_topic_2; + dynamic_type_topic_2 = create_schema(topic_2); - ds.add_schema(dynamic_type_topic_2); + fastdds::dds::xtypes::TypeIdentifier type_id_2; + ds.add_schema(dynamic_type_topic_2, topic_2.type_name, type_id_2); ds.activate(topic_2, cb_2); diff --git a/fastddsspy_tool/src/cpp/tool/Controller.cpp b/fastddsspy_tool/src/cpp/tool/Controller.cpp index 67c83e0c..4c4dd8a9 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.cpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.cpp @@ -144,7 +144,7 @@ void Controller::data_stream_callback_( view_.show("---"); std::stringstream ss; ss << std::setw(4); - auto ret = fastdds::dds::json_serialize(dyn_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + auto ret = fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss); std::cout << ss.str() << std::endl; view_.show("---\n"); } @@ -176,7 +176,7 @@ void Controller::data_stream_callback_verbose_( view_.show("data:\n---"); std::stringstream ss; ss << std::setw(4); - auto ret = fastdds::dds::json_serialize(dyn_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + auto ret = fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss); std::cout << ss.str() << std::endl; view_.show("---\n"); } diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp index 9698ed8e..9f744d73 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp @@ -26,11 +26,10 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include "AdvancedConfigurationPublisher.h" @@ -235,8 +234,8 @@ bool HelloWorldPublisher::init( wqos.ownership_strength().value = ownership_strength; } - wqos.liveliness().lease_duration = eprosima::fastrtps::Duration_t(2, 0); - wqos.liveliness().announcement_period = eprosima::fastrtps::Duration_t(1, 0); + wqos.liveliness().lease_duration = eprosima::fastdds::Duration_t(2, 0); + wqos.liveliness().announcement_period = eprosima::fastdds::Duration_t(1, 0); writer_ = publisher_->create_datawriter(topic_, wqos, &listener_); diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp index f8d544b1..825d62f8 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.cpp @@ -24,11 +24,10 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include "AdvancedConfigurationSubscriber.h" @@ -282,7 +281,7 @@ void HelloWorldSubscriber::SubListener::on_data_available( DataReader* reader) { SampleInfo info; - while ((reader->take_next_sample(&hello_, &info) == ReturnCode_t::RETCODE_OK) && !is_stopped()) + while ((reader->take_next_sample(&hello_, &info) == RETCODE_OK) && !is_stopped()) { if (info.instance_state == ALIVE_INSTANCE_STATE) { diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h index 786f78f5..efad213f 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h @@ -28,7 +28,7 @@ #include #include -"types/HelloWorldPubSubTypes.hpp" +#include "types/HelloWorldPubSubTypes.hpp" #include "types.hpp" From 3f442136d055797d8f3ec836555168d1d9bf6de8 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Mon, 2 Sep 2024 09:50:23 +0200 Subject: [PATCH 04/10] Update to new changes in FastDDS Signed-off-by: Lucia Echevarria --- .../model/DataStreamer.hpp | 3 +- .../participant/SpyDdsParticipant.hpp | 23 ++- .../src/cpp/model/DataStreamer.cpp | 8 +- .../src/cpp/participant/SpyDdsParticipant.cpp | 54 +++---- .../src/cpp/participant/SpyParticipant.cpp | 4 +- .../test/unittest/model/DataStreamerTest.cpp | 32 ++-- fastddsspy_tool/src/cpp/tool/Controller.cpp | 3 +- .../AdvancedConfigurationPublisher.cpp | 4 +- .../types/HelloWorldCdrAux.ipp | 5 + .../types/HelloWorldPubSubTypes.cxx | 140 ++++++++---------- .../types/HelloWorldPubSubTypes.hpp | 46 +++--- .../test_cases/one_shot_topics_name_dds.py | 2 +- .../test_cases/one_shot_topics_verbose_dds.py | 2 +- 13 files changed, 155 insertions(+), 171 deletions(-) diff --git a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp index 59890369..312e4339 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp @@ -60,8 +60,7 @@ class DataStreamer : public TopicRateCalculator FASTDDSSPY_PARTICIPANTS_DllAPI void add_schema( const fastdds::dds::DynamicType::_ref_type& dynamic_type, - const std::string& type_name, - const fastdds::dds::xtypes::TypeIdentifier& type_id) override; + const fastdds::dds::xtypes::TypeIdentifier& type_identifier) override; FASTDDSSPY_PARTICIPANTS_DllAPI void add_data( diff --git a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp index f33e2e5a..6effe30b 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp @@ -14,6 +14,14 @@ #pragma once +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -47,21 +55,24 @@ class SpyDdsParticipant : public ddspipe::participants::DynTypesParticipant const ddspipe::core::ITopic& topic) override; FASTDDSSPY_PARTICIPANTS_DllAPI - void onParticipantDiscovery( + void on_participant_discovery( fastdds::rtps::RTPSParticipant* participant, - fastdds::rtps::ParticipantDiscoveryInfo&& info, + fastdds::rtps::ParticipantDiscoveryStatus reason, + const fastdds::rtps::ParticipantBuiltinTopicData& info, bool& should_be_ignored) override; FASTDDSSPY_PARTICIPANTS_DllAPI - void onReaderDiscovery( + void on_reader_discovery( fastdds::rtps::RTPSParticipant* participant, - fastdds::rtps::ReaderDiscoveryInfo&& info, + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::rtps::SubscriptionBuiltinTopicData& info, bool& should_be_ignored) override; FASTDDSSPY_PARTICIPANTS_DllAPI - void onWriterDiscovery( + void on_writer_discovery( fastdds::rtps::RTPSParticipant* participant, - fastdds::rtps::WriterDiscoveryInfo&& info, + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::rtps::PublicationBuiltinTopicData& info, bool& should_be_ignored) override; protected: diff --git a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp index 883af6ef..0e6e0d54 100644 --- a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp +++ b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp @@ -73,18 +73,18 @@ void DataStreamer::deactivate() void DataStreamer::add_schema( const fastdds::dds::DynamicType::_ref_type& dynamic_type, - const std::string& type_name, - const fastdds::dds::xtypes::TypeIdentifier& type_id) + const fastdds::dds::xtypes::TypeIdentifier& type_identifier) { - static_cast(type_id); + static_cast(type_identifier); std::unique_lock _(mutex_); // Add type to map if not yet // NOTE: it does not matter if it is already in set + auto const type_name = dynamic_type->get_name().to_string(); types_discovered_[type_name] = dynamic_type; - logInfo(FASTDDSSPY_DATASTREAMER, "\nAdding schema with name " << dynamic_type->get_name() << "."); + logInfo(FASTDDSSPY_DATASTREAMER, "\nAdding schema with name " << type_name << "."); } void DataStreamer::add_data( diff --git a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp index 6f662ffa..5995cbe3 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp @@ -12,11 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include - #include #include @@ -59,39 +54,37 @@ std::shared_ptr SpyDdsParticipant::create_reader( return ddspipe::participants::DynTypesParticipant::create_reader(topic); } -void SpyDdsParticipant::onParticipantDiscovery( +void SpyDdsParticipant::on_participant_discovery( fastdds::rtps::RTPSParticipant* participant, - fastdds::rtps::ParticipantDiscoveryInfo&& discovery_info, + fastdds::rtps::ParticipantDiscoveryStatus reason, + const fastdds::rtps::ParticipantBuiltinTopicData& info, bool& should_be_ignored) { - fastdds::rtps::ParticipantProxyData proxy_copy_info(discovery_info.info); - // If comes from this participant is not interesting - if (come_from_this_participant_(proxy_copy_info.m_guid)) + if (come_from_this_participant_(info.guid)) { return; } - ParticipantInfo info; - info.active = (discovery_info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT - || discovery_info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT); - info.name = std::string(proxy_copy_info.m_participantName); - info.guid = proxy_copy_info.m_guid; + ParticipantInfo participant_info; + participant_info.active = (reason == fastdds::rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT + || reason == fastdds::rtps::ParticipantDiscoveryStatus::CHANGED_QOS_PARTICIPANT); + participant_info.name = std::string(info.participant_name); + participant_info.guid = info.guid; - ddspipe::participants::rtps::CommonParticipant::onParticipantDiscovery(participant, std::move(discovery_info), should_be_ignored); + ddspipe::participants::rtps::CommonParticipant::on_participant_discovery(participant, reason, info, should_be_ignored); - internal_notify_participant_discovered_(info); + internal_notify_participant_discovered_(participant_info); } -void SpyDdsParticipant::onReaderDiscovery( +void SpyDdsParticipant::on_reader_discovery( fastdds::rtps::RTPSParticipant* participant, - fastdds::rtps::ReaderDiscoveryInfo&& info, + fastdds::rtps::ReaderDiscoveryStatus reason, + const fastdds::rtps::SubscriptionBuiltinTopicData& info, bool& should_be_ignored) { - fastdds::rtps::ReaderProxyData proxy_copy(info.info); - // If comes from this participant is not interesting - if (come_from_this_participant_(proxy_copy.guid())) + if (come_from_this_participant_(info.guid)) { return; } @@ -99,22 +92,21 @@ void SpyDdsParticipant::onReaderDiscovery( EndpointInfo endpoint_info = ddspipe::participants::detail::create_endpoint_from_info_(info, id()); // If participant left or dropped, this notification arrives as well - endpoint_info.active = !(info.status == fastdds::rtps::ReaderDiscoveryInfo::DISCOVERY_STATUS::REMOVED_READER); + endpoint_info.active = !(reason == fastdds::rtps::ReaderDiscoveryStatus::REMOVED_READER); - ddspipe::participants::DynTypesParticipant::onReaderDiscovery(participant, std::move(info), should_be_ignored); + ddspipe::participants::DynTypesParticipant::on_reader_discovery(participant, reason, info, should_be_ignored); internal_notify_endpoint_discovered_(endpoint_info); } -void SpyDdsParticipant::onWriterDiscovery( +void SpyDdsParticipant::on_writer_discovery( fastdds::rtps::RTPSParticipant* participant, - fastdds::rtps::WriterDiscoveryInfo&& info, + fastdds::rtps::WriterDiscoveryStatus reason, + const fastdds::rtps::PublicationBuiltinTopicData& info, bool& should_be_ignored) { - fastdds::rtps::WriterProxyData proxy_copy(info.info); - // If comes from this participant is not interesting - if (come_from_this_participant_(proxy_copy.guid())) + if (come_from_this_participant_(info.guid)) { return; } @@ -122,9 +114,9 @@ void SpyDdsParticipant::onWriterDiscovery( EndpointInfo endpoint_info = ddspipe::participants::detail::create_endpoint_from_info_(info, id()); // If participant left or dropped, this notification arrives as well - endpoint_info.active = !(info.status == fastdds::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::REMOVED_WRITER); + endpoint_info.active = !(reason == fastdds::rtps::WriterDiscoveryStatus::REMOVED_WRITER); - ddspipe::participants::DynTypesParticipant::onWriterDiscovery(participant, std::move(info), should_be_ignored); + ddspipe::participants::DynTypesParticipant::on_writer_discovery(participant, reason, info, should_be_ignored); internal_notify_endpoint_discovered_(endpoint_info); } diff --git a/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp index 22edf344..ad7ac427 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp @@ -75,7 +75,7 @@ utils::ReturnCode SpyParticipant::new_participant_info_( ParticipantInfo info = participant_info.info; ddspipe::core::types::Guid guid = info.guid; model_->participant_database_.add_or_modify(std::move(guid), std::move(info)); - return utils::ReturnCode::OK; + return utils::ReturnCode::RETCODE_OK; } utils::ReturnCode SpyParticipant::new_endpoint_info_( @@ -86,7 +86,7 @@ utils::ReturnCode SpyParticipant::new_endpoint_info_( EndpointInfo info = endpoint_info.info; ddspipe::core::types::Guid guid = info.guid; model_->endpoint_database_.add_or_modify(std::move(guid), std::move(info)); - return utils::ReturnCode::OK; + return utils::ReturnCode::RETCODE_OK; } } /* namespace participants */ diff --git a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp index 34f468be..a201aede 100644 --- a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp +++ b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp @@ -72,8 +72,8 @@ TEST(DataStreamerTest, activate_true) fastdds::dds::DynamicType::_ref_type dynamic_type_topic; dynamic_type_topic = create_schema(topic); - fastdds::dds::xtypes::TypeIdentifier type_id; - ds.add_schema(dynamic_type_topic, topic.type_name, type_id); + fastdds::dds::xtypes::TypeIdentifier type_identifier; + ds.add_schema(dynamic_type_topic, type_identifier); ASSERT_TRUE(ds.activate(topic, cb)); } @@ -92,8 +92,8 @@ TEST(DataStreamerTest, activate_twice) fastdds::dds::DynamicType::_ref_type dynamic_type_topic_1; dynamic_type_topic_1 = create_schema(topic_1); - fastdds::dds::xtypes::TypeIdentifier type_id_1; - ds.add_schema(dynamic_type_topic_1, topic_1.type_name, type_id_1); + fastdds::dds::xtypes::TypeIdentifier type_identifier_1; + ds.add_schema(dynamic_type_topic_1, type_identifier_1); ddspipe::core::types::DdsTopic topic_2; topic_2.m_topic_name = "topic2"; @@ -102,8 +102,8 @@ TEST(DataStreamerTest, activate_twice) fastdds::dds::DynamicType::_ref_type dynamic_type_topic_2; dynamic_type_topic_2 = create_schema(topic_2); - fastdds::dds::xtypes::TypeIdentifier type_id_2; - ds.add_schema(dynamic_type_topic_2, topic_2.type_name, type_id_2); + fastdds::dds::xtypes::TypeIdentifier type_identifier_2; + ds.add_schema(dynamic_type_topic_2, type_identifier_2); // is this the correct behaviour? ASSERT_TRUE(ds.activate(topic_1, cb)); @@ -127,8 +127,8 @@ TEST(DataStreamerTest, topic_type_discovered) fastdds::dds::DynamicType::_ref_type dynamic_type_topic_2; dynamic_type_topic_2 = create_schema(topic_2); - fastdds::dds::xtypes::TypeIdentifier type_id; - ds.add_schema(dynamic_type_topic_2, topic_2.type_name, type_id); + fastdds::dds::xtypes::TypeIdentifier type_identifier; + ds.add_schema(dynamic_type_topic_2, type_identifier); ASSERT_TRUE(ds.is_topic_type_discovered(topic_2)); } @@ -155,8 +155,8 @@ TEST(DataStreamerTest, deactivate) fastdds::dds::DynamicType::_ref_type dynamic_type_topic; dynamic_type_topic = create_schema(topic); - fastdds::dds::xtypes::TypeIdentifier type_id; - ds.add_schema(dynamic_type_topic, topic.type_name, type_id); + fastdds::dds::xtypes::TypeIdentifier type_identifier; + ds.add_schema(dynamic_type_topic, type_identifier); ds.activate(topic, cb); @@ -203,8 +203,8 @@ TEST(DataStreamerTest, add_data) fastdds::dds::DynamicType::_ref_type dynamic_type_topic; dynamic_type_topic = create_schema(topic); - fastdds::dds::xtypes::TypeIdentifier type_id; - ds.add_schema(dynamic_type_topic, topic.type_name, type_id); + fastdds::dds::xtypes::TypeIdentifier type_identifier; + ds.add_schema(dynamic_type_topic, type_identifier); ds.activate(topic, cb); @@ -243,8 +243,8 @@ TEST(DataStreamerTest, add_data_two_topics) fastdds::dds::DynamicType::_ref_type dynamic_type_topic_1; dynamic_type_topic_1 = create_schema(topic_1); - fastdds::dds::xtypes::TypeIdentifier type_id_1; - ds.add_schema(dynamic_type_topic_1, topic_1.type_name, type_id_1); + fastdds::dds::xtypes::TypeIdentifier type_identifier_1; + ds.add_schema(dynamic_type_topic_1, type_identifier_1); ds.activate(topic_1, cb_1); @@ -267,8 +267,8 @@ TEST(DataStreamerTest, add_data_two_topics) fastdds::dds::DynamicType::_ref_type dynamic_type_topic_2; dynamic_type_topic_2 = create_schema(topic_2); - fastdds::dds::xtypes::TypeIdentifier type_id_2; - ds.add_schema(dynamic_type_topic_2, topic_2.type_name, type_id_2); + fastdds::dds::xtypes::TypeIdentifier type_identifier_2; + ds.add_schema(dynamic_type_topic_2, type_identifier_2); ds.activate(topic_2, cb_2); diff --git a/fastddsspy_tool/src/cpp/tool/Controller.cpp b/fastddsspy_tool/src/cpp/tool/Controller.cpp index 4c4dd8a9..a4a9e7b8 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.cpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.cpp @@ -122,8 +122,7 @@ fastdds::dds::DynamicData::_ref_type Controller::get_dynamic_data_( fastdds::dds::DynamicPubSubType pubsub_type(dyn_type); fastdds::dds::DynamicData::_ref_type dyn_data(fastdds::dds::DynamicDataFactory::get_instance()->create_data(dyn_type)); - // pubsub_type.deserialize(&data_no_const.payload, dyn_data.get()); - pubsub_type.deserialize(&data_no_const.payload, &dyn_data); + pubsub_type.deserialize(data_no_const.payload, &dyn_data); return dyn_data; } diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp index 9f744d73..4b11ee8a 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.cpp @@ -234,8 +234,8 @@ bool HelloWorldPublisher::init( wqos.ownership_strength().value = ownership_strength; } - wqos.liveliness().lease_duration = eprosima::fastdds::Duration_t(2, 0); - wqos.liveliness().announcement_period = eprosima::fastdds::Duration_t(1, 0); + wqos.liveliness().lease_duration = eprosima::fastdds::dds::Duration_t(2, 0); + wqos.liveliness().announcement_period = eprosima::fastdds::dds::Duration_t(1, 0); writer_ = publisher_->create_datawriter(topic_, wqos, &listener_); diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.ipp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.ipp index 19316df7..30f135e3 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.ipp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldCdrAux.ipp @@ -113,8 +113,13 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data) { + static_cast(scdr); static_cast(data); + scdr << data.index(); + + scdr << data.message(); + } diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.cxx b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.cxx index 38393dbf..865410fd 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.cxx +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.cxx @@ -33,49 +33,42 @@ 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 + set_name("HelloWorld"); + uint32_t type_size = HelloWorld_max_cdr_typesize; 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); + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; + uint32_t key_length = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; + key_buffer_ = reinterpret_cast(malloc(key_length)); + memset(key_buffer_, 0, key_length); } HelloWorldPubSubType::~HelloWorldPubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } bool HelloWorldPubSubType::serialize( const void* const data, - SerializedPayload_t* payload, + SerializedPayload_t& payload, DataRepresentationId_t data_representation) { const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + 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 + payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; 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 { @@ -90,16 +83,12 @@ bool HelloWorldPubSubType::serialize( } // 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 + payload.length = static_cast(ser.get_serialized_data_length()); return true; } bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, + SerializedPayload_t& payload, void* data) { try @@ -108,18 +97,14 @@ bool HelloWorldPubSubType::deserialize( HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + 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 - ); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); // Deserialize encapsulation. deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize the object. deser >> *p_type; @@ -132,52 +117,62 @@ bool HelloWorldPubSubType::deserialize( return true; } -std::function HelloWorldPubSubType::getSerializedSizeProvider( +uint32_t HelloWorldPubSubType::calculate_serialized_size( const void* const 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 - }; + 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; + } } -void* HelloWorldPubSubType::createData() +void* HelloWorldPubSubType::create_data() { return reinterpret_cast(new HelloWorld()); } -void HelloWorldPubSubType::deleteData( +void HelloWorldPubSubType::delete_data( void* data) { delete(reinterpret_cast(data)); } -bool HelloWorldPubSubType::getKey( +bool HelloWorldPubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + if (!is_compute_key_provided) + { + return false; + } + + HelloWorld data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + + return false; +} + +bool HelloWorldPubSubType::compute_key( const void* const data, - InstanceHandle_t* handle, + InstanceHandle_t& handle, bool force_md5) { - if (!m_isGetKeyDefined) + if (!is_compute_key_provided) { return false; } @@ -185,35 +180,28 @@ bool HelloWorldPubSubType::getKey( const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), 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::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); 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(); + md5_.init(); + md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); + md5_.finalize(); for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_md5.digest[i]; + handle.value[i] = md5_.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle.value[i] = key_buffer_[i]; } } return true; diff --git a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.hpp b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.hpp index 75830b9c..8937b288 100644 --- a/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.hpp +++ b/fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/types/HelloWorldPubSubTypes.hpp @@ -32,10 +32,10 @@ #include "HelloWorld.hpp" -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #error \ Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER +#endif // FASTDDS_GEN_API_VER /*! @@ -54,38 +54,30 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport bool serialize( const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t& payload, void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( + eProsima_user_DllExport uint32_t calculate_serialized_size( const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport bool compute_key( const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t* ihandle, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void deleteData( + eProsima_user_DllExport void delete_data( void* data) override; //Register TypeObject representation in Fast DDS TypeObjectRegistry @@ -100,10 +92,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #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 @@ -124,8 +112,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + eprosima::fastdds::MD5 md5_; + unsigned char* key_buffer_; }; diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py index a019c48a..a4a2f557 100644 --- a/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_name_dds.py @@ -44,5 +44,5 @@ def __init__(self): datawriters:\n\ - %%guid%%\n\ rate: %%rate%%\n\ -dynamic_type_discovered: false\n""" +dynamic_type_discovered: true\n""" ) diff --git a/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py index b3af2276..9837d190 100644 --- a/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py +++ b/fastddsspy_tool/test/application/test_cases/one_shot_topics_verbose_dds.py @@ -44,5 +44,5 @@ def __init__(self): datawriters:\n\ - %%guid%%\n\ rate: %%rate%%\n\ - dynamic_type_discovered: false\n""" + dynamic_type_discovered: true\n""" ) From 98cd1bc32a9a19d8b5fd15c3bef0a6566db91484 Mon Sep 17 00:00:00 2001 From: juanlofer-eprosima <88179026+juanlofer-eprosima@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:55:20 +0200 Subject: [PATCH 05/10] Accept v6 interfaces and interface names in whitelist (#93) Signed-off-by: Juan Lopez Fernandez --- fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp b/fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp index dc13a66c..9ba0a87b 100644 --- a/fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp +++ b/fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp @@ -177,7 +177,7 @@ void Configuration::load_dds_configuration_( // Get optional whitelist interfaces if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG)) { - simple_configuration->whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, + simple_configuration->whitelist = YamlReader::get_set(yml, WHITELIST_INTERFACES_TAG, version); } From c2e07b7019ade2d5862fb5466eb54addd62a8360 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Sun, 15 Sep 2024 20:40:53 +0200 Subject: [PATCH 06/10] Remove tool_show_topic_dds test Signed-off-by: Lucia Echevarria --- .../test_cases/tool_show_topic_dds.py | 45 ------------- fastddsspy_tool/test/labels/XTSAN.list | 66 +++++++++++++++++++ 2 files changed, 66 insertions(+), 45 deletions(-) delete mode 100644 fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py diff --git a/fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py b/fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py deleted file mode 100644 index 02b46779..00000000 --- a/fastddsspy_tool/test/application/test_cases/tool_show_topic_dds.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2023 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. - -"""Tests for the fastddsspy executable.""" - -import test_class - - -class TestCase_instance (test_class.TestCase): - """@brief A subclass of `test_class.TestCase` representing a specific test case.""" - - def __init__(self): - """ - @brief Initialize the TestCase_instance object. - - This test launch: - fastddsspy --config-path fastddsspy_tool/test/application/configuration/\ - configuration_discovery_time.yaml - >> show HelloWorldTopic - AdvancedConfigurationExample publisher - """ - super().__init__( - name='ToolShowTopicDDSCommand', - one_shot=False, - command=[], - dds=True, - config='fastddsspy_tool/test/application/configuration/\ -configuration_discovery_time.yaml', - arguments_dds=[], - arguments_spy=['--config-path', 'configuration'], - commands_spy=['show HelloWorldTopic'], - output=""">> \x1b[0m\x1b[1;31mTopic Type has not \ -been discovered, and thus cannot print its data.\x1b[0m\n\n\n""" - ) diff --git a/fastddsspy_tool/test/labels/XTSAN.list b/fastddsspy_tool/test/labels/XTSAN.list index e69de29b..17a9d5bd 100644 --- a/fastddsspy_tool/test/labels/XTSAN.list +++ b/fastddsspy_tool/test/labels/XTSAN.list @@ -0,0 +1,66 @@ +<<<<<<< Updated upstream +======= +tool.application.fastddsspy.test.test_cases.one_shot_help_dds +tool.application.fastddsspy.test.test_cases.one_shot_datareader_dds +tool.application.fastddsspy.test.test_cases.one_shot_datareader_guid_dds +tool.application.fastddsspy.test.test_cases.one_shot_datareader_verbose_dds +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_dds +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose_dds_qos +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_guid_dds_fail +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose_dds +tool.application.fastddsspy.test.test_cases.one_shot_participants_dds +tool.application.fastddsspy.test.test_cases.one_shot_participants_guid_dds +tool.application.fastddsspy.test.test_cases.one_shot_participants_verbose_dds +tool.application.fastddsspy.test.test_cases.one_shot_quit_dds +tool.application.fastddsspy.test.test_cases.one_shot_topics_dds +tool.application.fastddsspy.test.test_cases.one_shot_topics_dds_no_config +tool.application.fastddsspy.test.test_cases.one_shot_topics_name_dds +tool.application.fastddsspy.test.test_cases.one_shot_topics_verbose_dds +tool.application.fastddsspy.test.test_cases.tool_datareader_dds +tool.application.fastddsspy.test.test_cases.tool_datawriter_dds +tool.application.fastddsspy.test.test_cases.tool_help_dds +tool.application.fastddsspy.test.test_cases.tool_participants_dds +tool.application.fastddsspy.test.test_cases.tool_topics_dds +tool.application.fastddsspy.test.test_cases.tool_topics_dds_no_config +tool.application.fastddsspy.test.test_cases.one_shot__config +tool.application.fastddsspy.test.test_cases.one_shot__config_fail_file +tool.application.fastddsspy.test.test_cases.one_shot__config_fail_type +tool.application.fastddsspy.test.test_cases.one_shot__config_fail_empty_arg +tool.application.fastddsspy.test.test_cases.one_shot__log_filter +tool.application.fastddsspy.test.test_cases.one_shot__log_filter_fail +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_fail +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_info +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_warning +tool.application.fastddsspy.test.test_cases.one_shot__log_verb_error +tool.application.fastddsspy.test.test_cases.one_shot__reload_time +tool.application.fastddsspy.test.test_cases.one_shot__reload_time_fail +tool.application.fastddsspy.test.test_cases.one_shot__debug +tool.application.fastddsspy.test.test_cases.one_shot_help +tool.application.fastddsspy.test.test_cases.one_shot__help +tool.application.fastddsspy.test.test_cases.one_shot_null +tool.application.fastddsspy.test.test_cases.one_shot__null +tool.application.fastddsspy.test.test_cases.one_shot__version +tool.application.fastddsspy.test.test_cases.one_shot_datareader +tool.application.fastddsspy.test.test_cases.one_shot_datareader_verbose +tool.application.fastddsspy.test.test_cases.one_shot_datawriter +tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose +tool.application.fastddsspy.test.test_cases.one_shot_participants +tool.application.fastddsspy.test.test_cases.one_shot_participants_verbose +tool.application.fastddsspy.test.test_cases.one_shot_quit +tool.application.fastddsspy.test.test_cases.one_shot_show_all +tool.application.fastddsspy.test.test_cases.one_shot_show_fail +tool.application.fastddsspy.test.test_cases.one_shot_show_topic +tool.application.fastddsspy.test.test_cases.one_shot_show_topic_verbose +tool.application.fastddsspy.test.test_cases.one_shot_topics +tool.application.fastddsspy.test.test_cases.one_shot_topics_name +tool.application.fastddsspy.test.test_cases.one_shot_topics_verbose +tool.application.fastddsspy.test.test_cases.tool_datareader +tool.application.fastddsspy.test.test_cases.tool_datawriter +tool.application.fastddsspy.test.test_cases.tool_help +tool.application.fastddsspy.test.test_cases.tool_null +tool.application.fastddsspy.test.test_cases.tool_participants +tool.application.fastddsspy.test.test_cases.tool_show_all +tool.application.fastddsspy.test.test_cases.tool_show_topic +tool.application.fastddsspy.test.test_cases.tool_topics +tool.application.fastddsspy.test.test_cases.tool_version +>>>>>>> Stashed changes From 373bd9f62a8cb66b210e3ea7b441ac496e0dff63 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Sun, 15 Sep 2024 20:52:55 +0200 Subject: [PATCH 07/10] Apply suggested changes Signed-off-by: Lucia Echevarria --- .../model/NetworkDatabase.hpp | 2 -- .../test/unittest/model/DataStreamerTest.cpp | 12 ------------ fastddsspy_tool/src/cpp/tool/Controller.cpp | 14 ++++++++++++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp b/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp index 2cf1dd20..e0267fbd 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp @@ -14,8 +14,6 @@ #pragma once -#include - #include #include diff --git a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp index a201aede..2f028285 100644 --- a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp +++ b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp @@ -27,18 +27,6 @@ using namespace eprosima; fastdds::dds::DynamicType::_ref_type create_schema( ddspipe::core::types::DdsTopic& topic) { - // // Opción 1: - // fastdds::dds::TypeSupport type(new DynamicPubSubType(dynamic_type_topic)); - // type->setName(topic.type_name); - - // Lo que había antes - // fastdds::dds::DynamicTypeBuilder:_ref_type dynamic_type_topic_builder; - // dynamic_type_topic_builder = fastrtps::types::DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - - // dynamic_type_topic_builder->set_name(topic.type_name); - // dynamic_type_topic = dynamic_type_topic_builder->build(); - - // Opción 2: fastdds::dds::TypeDescriptor::_ref_type type_descriptor {fastdds::dds::traits::make_shared()}; type_descriptor->name(topic.type_name); fastdds::dds::DynamicTypeBuilder::_ref_type struct_builder {fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)}; diff --git a/fastddsspy_tool/src/cpp/tool/Controller.cpp b/fastddsspy_tool/src/cpp/tool/Controller.cpp index a4a9e7b8..e3e2bbb6 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.cpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.cpp @@ -143,7 +143,12 @@ void Controller::data_stream_callback_( view_.show("---"); std::stringstream ss; ss << std::setw(4); - auto ret = fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss); + if (fastdds::dds::RETCODE_OK != fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss)) + { + EPROSIMA_LOG_WARNING(FASTDDSSPY_CONTROLLER, + "Not able to serialize data of topic " << topic.topic_name() << " into JSON format."); + return; + } std::cout << ss.str() << std::endl; view_.show("---\n"); } @@ -175,7 +180,12 @@ void Controller::data_stream_callback_verbose_( view_.show("data:\n---"); std::stringstream ss; ss << std::setw(4); - auto ret = fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss); + if (fastdds::dds::RETCODE_OK != fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss)) + { + EPROSIMA_LOG_WARNING(FASTDDSSPY_CONTROLLER, + "Not able to serialize data of topic " << topic.topic_name() << " into JSON format."); + return; + } std::cout << ss.str() << std::endl; view_.show("---\n"); } From 45c60d0105f79b88e7dd3e2c680c2306a18f23dc Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Mon, 16 Sep 2024 12:59:01 +0200 Subject: [PATCH 08/10] Update log macro and fix XTSAN list Signed-off-by: Lucia Echevarria --- .../src/cpp/model/DataStreamer.cpp | 10 +-- fastddsspy_tool/src/cpp/main.cpp | 18 ++--- .../arguments_configuration.cpp | 18 ++--- fastddsspy_tool/test/labels/XTSAN.list | 66 ------------------- 4 files changed, 23 insertions(+), 89 deletions(-) diff --git a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp index 0e6e0d54..af34a7af 100644 --- a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp +++ b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp @@ -47,7 +47,7 @@ bool DataStreamer::activate( { if (!is_topic_type_discovered(topic_to_activate)) { - logWarning(FASTDDSSPY_DATASTREAMER, + EPROSIMA_LOG_WARNING(FASTDDSSPY_DATASTREAMER, "Type <" << topic_to_activate.type_name << "> for topic <" << topic_to_activate.topic_name() << "> is not discovered."); return false; @@ -84,7 +84,7 @@ void DataStreamer::add_schema( auto const type_name = dynamic_type->get_name().to_string(); types_discovered_[type_name] = dynamic_type; - logInfo(FASTDDSSPY_DATASTREAMER, "\nAdding schema with name " << type_name << "."); + EPROSIMA_LOG_INFO(FASTDDSSPY_DATASTREAMER, "\nAdding schema with name " << type_name << "."); } void DataStreamer::add_data( @@ -109,7 +109,7 @@ void DataStreamer::add_data( if (!is_topic_type_discovered_nts_(topic)) { // If all activated, add it only if schema is available, otherwise skip - logWarning( + EPROSIMA_LOG_WARNING( FASTDDSSPY_DATASTREAMER, "All activated but schema not is available."); return; @@ -120,14 +120,14 @@ void DataStreamer::add_data( if (!(activated_topic_ == topic)) { // If not all activated, and this is not the activated topic skip - logWarning( + EPROSIMA_LOG_WARNING( FASTDDSSPY_DATASTREAMER, "Not all activated, and this is not the activated topic."); return; } } - logInfo( + EPROSIMA_LOG_INFO( FASTDDSSPY_DATASTREAMER, "Adding data in topic " << topic); diff --git a/fastddsspy_tool/src/cpp/main.cpp b/fastddsspy_tool/src/cpp/main.cpp index 841ca0a2..13054971 100644 --- a/fastddsspy_tool/src/cpp/main.cpp +++ b/fastddsspy_tool/src/cpp/main.cpp @@ -76,7 +76,7 @@ int main( { commandline_args.file_path = eprosima::spy::DEFAULT_CONFIGURATION_FILE_NAME; - logInfo( + EPROSIMA_LOG_INFO( FASTDDSSPY_TOOL, "Not configuration file given, try to use default file " << commandline_args.file_path << "."); } @@ -85,7 +85,7 @@ int main( // NOTE: this check is redundant with option parse arg check if (!is_file_accessible(commandline_args.file_path.c_str(), eprosima::utils::FileAccessMode::read)) { - logInfo( + EPROSIMA_LOG_INFO( FASTDDSSPY_TOOL, "File '" << commandline_args.file_path << "' does not exist or it is not accessible. Using default configuration."); @@ -101,7 +101,7 @@ int main( // Default configuration. Load it from file if file exists if (commandline_args.file_path != "") { - logInfo( + EPROSIMA_LOG_INFO( FASTDDSSPY_TOOL, "Loading configuration from file '" << commandline_args.file_path << "' ."); } @@ -152,7 +152,7 @@ int main( [&spy, commandline_args] (std::string file_name) { - logInfo( + EPROSIMA_LOG_INFO( FASTDDSSPY_TOOL, "FileWatcher notified changes in file " << file_name << ". Reloading configuration"); @@ -163,7 +163,7 @@ int main( } catch (const std::exception& e) { - logWarning(FASTDDSSPY_TOOL, + EPROSIMA_LOG_WARNING(FASTDDSSPY_TOOL, "Error reloading configuration file " << file_name << " with error: " << e.what()); } }; @@ -187,7 +187,7 @@ int main( [&spy, commandline_args] () { - logInfo( + EPROSIMA_LOG_INFO( FASTDDSSPY_TOOL, "Periodic Timer raised. Reloading configuration from file " << commandline_args.file_path << "."); @@ -199,7 +199,7 @@ int main( } catch (const std::exception& e) { - logWarning(FASTDDSSPY_TOOL, + EPROSIMA_LOG_WARNING(FASTDDSSPY_TOOL, "Error reloading configuration file " << commandline_args.file_path << " with error: " << e.what()); } @@ -232,7 +232,7 @@ int main( } catch (const eprosima::utils::ConfigurationException& e) { - logError(FASTDDSSPY_TOOL, + EPROSIMA_LOG_ERROR(FASTDDSSPY_TOOL, "Error Loading Fast DDS Spy Configuration from file " << commandline_args.file_path << ". Error message:\n " << e.what()); @@ -240,7 +240,7 @@ int main( } catch (const eprosima::utils::InitializationException& e) { - logError(FASTDDSSPY_TOOL, + EPROSIMA_LOG_ERROR(FASTDDSSPY_TOOL, "Error Initializing Fast DDS Spy. Error message:\n " << e.what()); return static_cast(eprosima::spy::ProcessReturnCode::execution_failed); diff --git a/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp b/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp index 5b84faf5..d771a1e7 100644 --- a/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp +++ b/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp @@ -264,7 +264,7 @@ ProcessReturnCode parse_arguments( break; case optionIndex::UNKNOWN_OPT: - logError(FASTDDSSPY_ARGS, opt << " is not a valid argument."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, opt << " is not a valid argument."); option::printUsage(fwrite, stdout, usage, columns); return ProcessReturnCode::incorrect_argument; break; @@ -283,7 +283,7 @@ option::ArgStatus Arg::Unknown( { if (msg) { - logError( + EPROSIMA_LOG_ERROR( FASTDDSSPY_ARGS, "Unknown option '" << option << "'. Use -h to see this executable possible arguments."); } @@ -301,7 +301,7 @@ option::ArgStatus Arg::Required( if (msg) { - logError(FASTDDSSPY_ARGS, "Option '" << option << "' required."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, "Option '" << option << "' required."); } return option::ARG_ILLEGAL; } @@ -321,7 +321,7 @@ option::ArgStatus Arg::Numeric( if (msg) { - logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires a numeric argument."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, "Option '" << option << "' requires a numeric argument."); } return option::ARG_ILLEGAL; } @@ -341,7 +341,7 @@ option::ArgStatus Arg::Float( if (msg) { - logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires a float argument."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, "Option '" << option << "' requires a float argument."); } return option::ARG_ILLEGAL; } @@ -356,7 +356,7 @@ option::ArgStatus Arg::String( } if (msg) { - logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires a text argument."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, "Option '" << option << "' requires a text argument."); } return option::ARG_ILLEGAL; } @@ -375,7 +375,7 @@ option::ArgStatus Arg::Readable_File( } if (msg) { - logError(FASTDDSSPY_ARGS, "Option '" << option << "' requires an existing readable file as argument."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, "Option '" << option << "' requires an existing readable file as argument."); } return option::ARG_ILLEGAL; } @@ -396,7 +396,7 @@ option::ArgStatus Arg::Valid_Options( { if (msg) { - logError(FASTDDSSPY_ARGS, "Option '" << option.name << "' requires a text argument."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, "Option '" << option.name << "' requires a text argument."); } return option::ARG_ILLEGAL; } @@ -415,7 +415,7 @@ option::ArgStatus Arg::Valid_Options( } error_msg << "}."; - logError(FASTDDSSPY_ARGS, error_msg); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, error_msg); } return option::ARG_ILLEGAL; diff --git a/fastddsspy_tool/test/labels/XTSAN.list b/fastddsspy_tool/test/labels/XTSAN.list index 17a9d5bd..e69de29b 100644 --- a/fastddsspy_tool/test/labels/XTSAN.list +++ b/fastddsspy_tool/test/labels/XTSAN.list @@ -1,66 +0,0 @@ -<<<<<<< Updated upstream -======= -tool.application.fastddsspy.test.test_cases.one_shot_help_dds -tool.application.fastddsspy.test.test_cases.one_shot_datareader_dds -tool.application.fastddsspy.test.test_cases.one_shot_datareader_guid_dds -tool.application.fastddsspy.test.test_cases.one_shot_datareader_verbose_dds -tool.application.fastddsspy.test.test_cases.one_shot_datawriter_dds -tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose_dds_qos -tool.application.fastddsspy.test.test_cases.one_shot_datawriter_guid_dds_fail -tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose_dds -tool.application.fastddsspy.test.test_cases.one_shot_participants_dds -tool.application.fastddsspy.test.test_cases.one_shot_participants_guid_dds -tool.application.fastddsspy.test.test_cases.one_shot_participants_verbose_dds -tool.application.fastddsspy.test.test_cases.one_shot_quit_dds -tool.application.fastddsspy.test.test_cases.one_shot_topics_dds -tool.application.fastddsspy.test.test_cases.one_shot_topics_dds_no_config -tool.application.fastddsspy.test.test_cases.one_shot_topics_name_dds -tool.application.fastddsspy.test.test_cases.one_shot_topics_verbose_dds -tool.application.fastddsspy.test.test_cases.tool_datareader_dds -tool.application.fastddsspy.test.test_cases.tool_datawriter_dds -tool.application.fastddsspy.test.test_cases.tool_help_dds -tool.application.fastddsspy.test.test_cases.tool_participants_dds -tool.application.fastddsspy.test.test_cases.tool_topics_dds -tool.application.fastddsspy.test.test_cases.tool_topics_dds_no_config -tool.application.fastddsspy.test.test_cases.one_shot__config -tool.application.fastddsspy.test.test_cases.one_shot__config_fail_file -tool.application.fastddsspy.test.test_cases.one_shot__config_fail_type -tool.application.fastddsspy.test.test_cases.one_shot__config_fail_empty_arg -tool.application.fastddsspy.test.test_cases.one_shot__log_filter -tool.application.fastddsspy.test.test_cases.one_shot__log_filter_fail -tool.application.fastddsspy.test.test_cases.one_shot__log_verb_fail -tool.application.fastddsspy.test.test_cases.one_shot__log_verb_info -tool.application.fastddsspy.test.test_cases.one_shot__log_verb_warning -tool.application.fastddsspy.test.test_cases.one_shot__log_verb_error -tool.application.fastddsspy.test.test_cases.one_shot__reload_time -tool.application.fastddsspy.test.test_cases.one_shot__reload_time_fail -tool.application.fastddsspy.test.test_cases.one_shot__debug -tool.application.fastddsspy.test.test_cases.one_shot_help -tool.application.fastddsspy.test.test_cases.one_shot__help -tool.application.fastddsspy.test.test_cases.one_shot_null -tool.application.fastddsspy.test.test_cases.one_shot__null -tool.application.fastddsspy.test.test_cases.one_shot__version -tool.application.fastddsspy.test.test_cases.one_shot_datareader -tool.application.fastddsspy.test.test_cases.one_shot_datareader_verbose -tool.application.fastddsspy.test.test_cases.one_shot_datawriter -tool.application.fastddsspy.test.test_cases.one_shot_datawriter_verbose -tool.application.fastddsspy.test.test_cases.one_shot_participants -tool.application.fastddsspy.test.test_cases.one_shot_participants_verbose -tool.application.fastddsspy.test.test_cases.one_shot_quit -tool.application.fastddsspy.test.test_cases.one_shot_show_all -tool.application.fastddsspy.test.test_cases.one_shot_show_fail -tool.application.fastddsspy.test.test_cases.one_shot_show_topic -tool.application.fastddsspy.test.test_cases.one_shot_show_topic_verbose -tool.application.fastddsspy.test.test_cases.one_shot_topics -tool.application.fastddsspy.test.test_cases.one_shot_topics_name -tool.application.fastddsspy.test.test_cases.one_shot_topics_verbose -tool.application.fastddsspy.test.test_cases.tool_datareader -tool.application.fastddsspy.test.test_cases.tool_datawriter -tool.application.fastddsspy.test.test_cases.tool_help -tool.application.fastddsspy.test.test_cases.tool_null -tool.application.fastddsspy.test.test_cases.tool_participants -tool.application.fastddsspy.test.test_cases.tool_show_all -tool.application.fastddsspy.test.test_cases.tool_show_topic -tool.application.fastddsspy.test.test_cases.tool_topics -tool.application.fastddsspy.test.test_cases.tool_version ->>>>>>> Stashed changes From d8a87ac6337dbd82777c1b2ac3c4a6f3ef8deb08 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Mon, 16 Sep 2024 12:59:31 +0200 Subject: [PATCH 09/10] Update documentation Signed-off-by: Lucia Echevarria --- docs/rst/developer_manual/installation/sources/linux.rst | 2 +- docs/rst/user_manual/configuration.rst | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/rst/developer_manual/installation/sources/linux.rst b/docs/rst/developer_manual/installation/sources/linux.rst index cc9ae9e0..25afe9bf 100644 --- a/docs/rst/developer_manual/installation/sources/linux.rst +++ b/docs/rst/developer_manual/installation/sources/linux.rst @@ -93,7 +93,7 @@ Use the following command to download the code: .. code-block:: bash - git clone --branch release-1.11.0 https://github.com/google/googletest src/googletest-distribution + git clone --branch release-1.12.0 https://github.com/google/googletest src/googletest-distribution .. _dependencies: diff --git a/docs/rst/user_manual/configuration.rst b/docs/rst/user_manual/configuration.rst index bf209531..b1135be6 100644 --- a/docs/rst/user_manual/configuration.rst +++ b/docs/rst/user_manual/configuration.rst @@ -364,10 +364,6 @@ The type of the logs published is defined as follows: string timestamp; }; -.. note:: - - The type of the logs can be published by setting ``publish-type: true``. - **Example of usage** .. code-block:: yaml From 2463e9422d4b9dff31c167ea04e73ad920d6db6d Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Mon, 16 Sep 2024 14:09:15 +0200 Subject: [PATCH 10/10] Uncrustify Signed-off-by: Lucia Echevarria --- .../src/cpp/participant/SpyDdsParticipant.cpp | 3 ++- .../test/unittest/model/DataStreamerTest.cpp | 6 ++++-- fastddsspy_tool/src/cpp/tool/Controller.cpp | 13 ++++++++----- .../cpp/user_interface/arguments_configuration.cpp | 3 ++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp index 5995cbe3..bc9f77f6 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp @@ -72,7 +72,8 @@ void SpyDdsParticipant::on_participant_discovery( participant_info.name = std::string(info.participant_name); participant_info.guid = info.guid; - ddspipe::participants::rtps::CommonParticipant::on_participant_discovery(participant, reason, info, should_be_ignored); + ddspipe::participants::rtps::CommonParticipant::on_participant_discovery(participant, reason, info, + should_be_ignored); internal_notify_participant_discovered_(participant_info); } diff --git a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp index 2f028285..190ac385 100644 --- a/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp +++ b/fastddsspy_participants/test/unittest/model/DataStreamerTest.cpp @@ -27,9 +27,11 @@ using namespace eprosima; fastdds::dds::DynamicType::_ref_type create_schema( ddspipe::core::types::DdsTopic& topic) { - fastdds::dds::TypeDescriptor::_ref_type type_descriptor {fastdds::dds::traits::make_shared()}; + fastdds::dds::TypeDescriptor::_ref_type type_descriptor {fastdds::dds::traits:: + make_shared()}; type_descriptor->name(topic.type_name); - fastdds::dds::DynamicTypeBuilder::_ref_type struct_builder {fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)}; + fastdds::dds::DynamicTypeBuilder::_ref_type struct_builder {fastdds::dds::DynamicTypeBuilderFactory::get_instance() + ->create_type(type_descriptor)}; fastdds::dds::DynamicType::_ref_type dynamic_type_topic {struct_builder->build()}; return dynamic_type_topic; } diff --git a/fastddsspy_tool/src/cpp/tool/Controller.cpp b/fastddsspy_tool/src/cpp/tool/Controller.cpp index e3e2bbb6..06f9fd58 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.cpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.cpp @@ -120,7 +120,8 @@ fastdds::dds::DynamicData::_ref_type Controller::get_dynamic_data_( // Create PubSub Type fastdds::dds::DynamicPubSubType pubsub_type(dyn_type); - fastdds::dds::DynamicData::_ref_type dyn_data(fastdds::dds::DynamicDataFactory::get_instance()->create_data(dyn_type)); + fastdds::dds::DynamicData::_ref_type dyn_data(fastdds::dds::DynamicDataFactory::get_instance()->create_data( + dyn_type)); pubsub_type.deserialize(data_no_const.payload, &dyn_data); @@ -143,10 +144,11 @@ void Controller::data_stream_callback_( view_.show("---"); std::stringstream ss; ss << std::setw(4); - if (fastdds::dds::RETCODE_OK != fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss)) + if (fastdds::dds::RETCODE_OK != + fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss)) { EPROSIMA_LOG_WARNING(FASTDDSSPY_CONTROLLER, - "Not able to serialize data of topic " << topic.topic_name() << " into JSON format."); + "Not able to serialize data of topic " << topic.topic_name() << " into JSON format."); return; } std::cout << ss.str() << std::endl; @@ -180,10 +182,11 @@ void Controller::data_stream_callback_verbose_( view_.show("data:\n---"); std::stringstream ss; ss << std::setw(4); - if (fastdds::dds::RETCODE_OK != fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss)) + if (fastdds::dds::RETCODE_OK != + fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss)) { EPROSIMA_LOG_WARNING(FASTDDSSPY_CONTROLLER, - "Not able to serialize data of topic " << topic.topic_name() << " into JSON format."); + "Not able to serialize data of topic " << topic.topic_name() << " into JSON format."); return; } std::cout << ss.str() << std::endl; diff --git a/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp b/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp index d771a1e7..d907f9b7 100644 --- a/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp +++ b/fastddsspy_tool/src/cpp/user_interface/arguments_configuration.cpp @@ -375,7 +375,8 @@ option::ArgStatus Arg::Readable_File( } if (msg) { - EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, "Option '" << option << "' requires an existing readable file as argument."); + EPROSIMA_LOG_ERROR(FASTDDSSPY_ARGS, + "Option '" << option << "' requires an existing readable file as argument."); } return option::ARG_ILLEGAL; }