From 952d2074276477a4a6754e7529187f192649721b Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 9 Oct 2023 09:54:15 +0200 Subject: [PATCH 01/12] Dynamically trigger the creation of entities Signed-off-by: tempate --- .../configuration/DdsPipeConfiguration.hpp | 10 +++++++ ddspipe_core/src/cpp/core/DdsPipe.cpp | 29 +++++++++++++++---- .../dynamic_types/SchemaParticipant.cpp | 15 ---------- .../ddspipe_yaml/yaml_configuration_tags.hpp | 1 + 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp index fe8bfb56..e9bcac40 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp @@ -32,6 +32,13 @@ namespace eprosima { namespace ddspipe { namespace core { +enum EntityCreationTrigger +{ + ANY = 0, //! The discovery of both readers and writers triggers the creation of entities. + READER = 1, //! The discovery of readers triggers the creation of entities. + WRITER = 2 //! The discovery of writers triggers the creation of entities. +}; + /** * Configuration structure encapsulating the configuration of a \c DdsPipe instance. */ @@ -108,6 +115,9 @@ struct DdsPipeConfiguration : public IConfiguration //! Whether the DDS Pipe should be initialized enabled. bool init_enabled = false; + + //! The entity type whose discovery should trigger the creation of entities. + EntityCreationTrigger entity_creation_trigger = EntityCreationTrigger::READER; }; } /* namespace core */ diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 87bf0b42..786301ac 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -350,19 +350,36 @@ void DdsPipe::updated_endpoint_nts_( bool DdsPipe::is_endpoint_relevant_( const Endpoint& endpoint) noexcept { - if (!endpoint.is_reader()) - { - return false; - } + const auto entity_creation_trigger = ddspipe_config_.entity_creation_trigger; + + auto is_endpoint_type_relevant = [entity_creation_trigger](const Endpoint& endpoint) + { + switch (entity_creation_trigger) + { + case EntityCreationTrigger::READER: + return endpoint.is_reader(); + case EntityCreationTrigger::WRITER: + return endpoint.is_writer(); + case EntityCreationTrigger::ANY: + return true; + default: + return false; + } + }; - auto is_endpoint_relevant = [endpoint](const Endpoint& entity) + auto is_endpoint_relevant = [endpoint, is_endpoint_type_relevant](const Endpoint& entity) { return entity.active && - entity.is_reader() && + is_endpoint_type_relevant(entity) && entity.topic == endpoint.topic && entity.discoverer_participant_id == endpoint.discoverer_participant_id; }; + if (!is_endpoint_type_relevant(endpoint)) + { + return false; + } + const auto& relevant_endpoints = discovery_database_->get_endpoints(is_endpoint_relevant); if (endpoint.active) diff --git a/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp b/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp index 26b0d6c2..f7ec7e28 100644 --- a/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp @@ -51,21 +51,6 @@ SchemaParticipant::SchemaParticipant( discovery_database_->add_endpoint( rtps::CommonParticipant::simulate_endpoint(type_object_topic(), this->id()) ); - - // Force for every topic found to create track by creating simulated readers - // NOTE: this could change for: in DDS Pipe change that only readers create track - discovery_database_->add_endpoint_discovered_callback( - [this](Endpoint endpoint_discovered) - { - if (endpoint_discovered.is_writer() && endpoint_discovered.discoverer_participant_id != this->id()) - { - discovery_database_->add_endpoint( - rtps::CommonParticipant::simulate_endpoint(endpoint_discovered.topic, - endpoint_discovered.discoverer_participant_id) - ); - } - } - ); } ParticipantId SchemaParticipant::id() const noexcept diff --git a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp index 29702841..a0fffc3d 100644 --- a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp +++ b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp @@ -141,6 +141,7 @@ constexpr const char* SPECS_QOS_TAG("qos"); //! Global Topic QoS constexpr const char* NUMBER_THREADS_TAG("threads"); //! Number of threads to configure the thread pool constexpr const char* WAIT_ALL_ACKED_TIMEOUT_TAG("wait-all-acked-timeout"); //! Wait for a maximum of *wait-all-acked-timeout* ms until all msgs sent by reliable writers are acknowledged by their matched readers constexpr const char* REMOVE_UNUSED_ENTITIES_TAG("remove-unused-entities"); //! Dynamically create and delete entities and tracks. +constexpr const char* ENTITY_CREATION_TRIGGER_TAG("entity-creation-trigger"); //! Dynamically create entities when the trigger is set off. // XML configuration tags constexpr const char* XML_TAG("xml"); //! Tag to read xml configuration From 13c11260e85fc583c43a24b3d4fe44a13593dd85 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 13 Oct 2023 09:52:24 +0200 Subject: [PATCH 02/12] Rebase fix Signed-off-by: tempate --- ddspipe_core/src/cpp/core/DdsPipe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 786301ac..21b5fe3f 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -350,7 +350,7 @@ void DdsPipe::updated_endpoint_nts_( bool DdsPipe::is_endpoint_relevant_( const Endpoint& endpoint) noexcept { - const auto entity_creation_trigger = ddspipe_config_.entity_creation_trigger; + const auto entity_creation_trigger = configuration_.entity_creation_trigger; auto is_endpoint_type_relevant = [entity_creation_trigger](const Endpoint& endpoint) { From e9b69f1e4ef320e91a12ca5e04cf8d9ec90be83c Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 13 Oct 2023 13:30:20 +0200 Subject: [PATCH 03/12] Add none entity-creation-trigger Signed-off-by: tempate --- .../ddspipe_core/configuration/DdsPipeConfiguration.hpp | 9 +++++---- ddspipe_core/src/cpp/core/DdsPipe.cpp | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp index e9bcac40..6668f076 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp @@ -34,9 +34,10 @@ namespace core { enum EntityCreationTrigger { - ANY = 0, //! The discovery of both readers and writers triggers the creation of entities. - READER = 1, //! The discovery of readers triggers the creation of entities. - WRITER = 2 //! The discovery of writers triggers the creation of entities. + READER = 0, //! The discovery of readers triggers the creation of entities. + WRITER = 1, //! The discovery of writers triggers the creation of entities. + NONE = 2, //! The discovery of either readers and writers doesn't trigger the creation of entities. + ANY = 3 //! The discovery of both readers and writers triggers the creation of entities. }; /** @@ -115,7 +116,7 @@ struct DdsPipeConfiguration : public IConfiguration //! Whether the DDS Pipe should be initialized enabled. bool init_enabled = false; - + //! The entity type whose discovery should trigger the creation of entities. EntityCreationTrigger entity_creation_trigger = EntityCreationTrigger::READER; }; diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 21b5fe3f..086fe8ad 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -362,6 +362,8 @@ bool DdsPipe::is_endpoint_relevant_( return endpoint.is_writer(); case EntityCreationTrigger::ANY: return true; + case EntityCreationTrigger::NONE: + return false; default: return false; } From 412105afa83bf893990cfca155db1f930e82cba5 Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 16 Oct 2023 10:10:08 +0200 Subject: [PATCH 04/12] Avoid adding endpoints in the SchemaParticipant Signed-off-by: tempate --- .../src/cpp/participant/dynamic_types/SchemaParticipant.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp b/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp index f7ec7e28..5fbb30e7 100644 --- a/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp +++ b/ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp @@ -47,10 +47,6 @@ SchemaParticipant::SchemaParticipant( , discovery_database_(discovery_database) , schema_handler_(schema_handler) { - // Simulate that there is a reader of type object to force this track creation - discovery_database_->add_endpoint( - rtps::CommonParticipant::simulate_endpoint(type_object_topic(), this->id()) - ); } ParticipantId SchemaParticipant::id() const noexcept From 3dee0119979e63d885e1a939efeefa7f6a59f3fb Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 24 Oct 2023 15:16:51 +0200 Subject: [PATCH 05/12] Rename entity_creation_trigger to discovery_trigger Signed-off-by: tempate --- .../configuration/DdsPipeConfiguration.hpp | 14 +++++++------- ddspipe_core/src/cpp/core/DdsPipe.cpp | 14 +++++++------- .../ddspipe_yaml/yaml_configuration_tags.hpp | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp index 6668f076..5bbb0d51 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp @@ -32,12 +32,12 @@ namespace eprosima { namespace ddspipe { namespace core { -enum EntityCreationTrigger +enum DiscoveryTrigger { - READER = 0, //! The discovery of readers triggers the creation of entities. - WRITER = 1, //! The discovery of writers triggers the creation of entities. - NONE = 2, //! The discovery of either readers and writers doesn't trigger the creation of entities. - ANY = 3 //! The discovery of both readers and writers triggers the creation of entities. + READER = 0, //! The discovery callbacks get triggered by the discovery of a reader. + WRITER = 1, //! The discovery callbacks get triggered by the discovery of a writer. + NONE = 2, //! The discovery callbacks don't get triggered by the discovery of readers or writers. + ANY = 3 //! The discovery callbacks get triggered by the discovery of either a reader or a writer. }; /** @@ -117,8 +117,8 @@ struct DdsPipeConfiguration : public IConfiguration //! Whether the DDS Pipe should be initialized enabled. bool init_enabled = false; - //! The entity type whose discovery should trigger the creation of entities. - EntityCreationTrigger entity_creation_trigger = EntityCreationTrigger::READER; + //! The type of the entity whose discovery should trigger the discovery callbacks. + DiscoveryTrigger discovery_trigger = DiscoveryTrigger::READER; }; } /* namespace core */ diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 086fe8ad..355cb7d4 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -350,19 +350,19 @@ void DdsPipe::updated_endpoint_nts_( bool DdsPipe::is_endpoint_relevant_( const Endpoint& endpoint) noexcept { - const auto entity_creation_trigger = configuration_.entity_creation_trigger; + const auto discovery_trigger = configuration_.discovery_trigger; - auto is_endpoint_type_relevant = [entity_creation_trigger](const Endpoint& endpoint) + auto is_endpoint_type_relevant = [discovery_trigger](const Endpoint& endpoint) { - switch (entity_creation_trigger) + switch (discovery_trigger) { - case EntityCreationTrigger::READER: + case DiscoveryTrigger::READER: return endpoint.is_reader(); - case EntityCreationTrigger::WRITER: + case DiscoveryTrigger::WRITER: return endpoint.is_writer(); - case EntityCreationTrigger::ANY: + case DiscoveryTrigger::ANY: return true; - case EntityCreationTrigger::NONE: + case DiscoveryTrigger::NONE: return false; default: return false; diff --git a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp index a0fffc3d..2b9752de 100644 --- a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp +++ b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp @@ -141,7 +141,7 @@ constexpr const char* SPECS_QOS_TAG("qos"); //! Global Topic QoS constexpr const char* NUMBER_THREADS_TAG("threads"); //! Number of threads to configure the thread pool constexpr const char* WAIT_ALL_ACKED_TIMEOUT_TAG("wait-all-acked-timeout"); //! Wait for a maximum of *wait-all-acked-timeout* ms until all msgs sent by reliable writers are acknowledged by their matched readers constexpr const char* REMOVE_UNUSED_ENTITIES_TAG("remove-unused-entities"); //! Dynamically create and delete entities and tracks. -constexpr const char* ENTITY_CREATION_TRIGGER_TAG("entity-creation-trigger"); //! Dynamically create entities when the trigger is set off. +constexpr const char* DISCOVERY_TRIGGER_TAG("discovery-trigger"); //! Dynamically trigger the discovery of entities. // XML configuration tags constexpr const char* XML_TAG("xml"); //! Tag to read xml configuration From b92a08b28717f01ef4d6f5898f0d44d4f48057d1 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 14 Nov 2023 14:58:56 +0100 Subject: [PATCH 06/12] Apply suggestions Signed-off-by: tempate --- ddspipe_core/src/cpp/core/DdsPipe.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 355cb7d4..2fc1b509 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -350,16 +350,14 @@ void DdsPipe::updated_endpoint_nts_( bool DdsPipe::is_endpoint_relevant_( const Endpoint& endpoint) noexcept { - const auto discovery_trigger = configuration_.discovery_trigger; - - auto is_endpoint_type_relevant = [discovery_trigger](const Endpoint& endpoint) + auto is_endpoint_type_relevant = [&](const Endpoint& entity) { - switch (discovery_trigger) + switch (configuration_.discovery_trigger) { case DiscoveryTrigger::READER: - return endpoint.is_reader(); + return entity.is_reader(); case DiscoveryTrigger::WRITER: - return endpoint.is_writer(); + return entity.is_writer(); case DiscoveryTrigger::ANY: return true; case DiscoveryTrigger::NONE: From 83339d594e31a03dd969a3decc0451f2bb460aa8 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 16 Nov 2023 16:59:27 +0100 Subject: [PATCH 07/12] Check discovery trigger in services Signed-off-by: tempate --- .../include/ddspipe_core/core/DdsPipe.hpp | 8 +++ ddspipe_core/src/cpp/core/DdsPipe.cpp | 58 ++++++++++--------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp b/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp index ef61ad51..d6b33940 100644 --- a/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp +++ b/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp @@ -212,6 +212,14 @@ class DdsPipe void updated_endpoint_nts_( const types::Endpoint& endpoint) noexcept; + /** + * @brief Method called every time a new endpoint has been discovered, removed, or updated. + * + * @param [in] endpoint : endpoint discovered, removed, or updated. + */ + bool is_endpoint_type_relevant_( + const types::Endpoint& endpoint) noexcept; + /** * @brief Method called every time a new endpoint has been discovered, removed, or updated. * diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 2fc1b509..7b831f29 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -80,9 +81,6 @@ DdsPipe::DdsPipe( } // Init discovery database - // The entities should not be added to the Discovery Database until the builtin topics have been created. - // This is due to the fact that the Participants endpoints start discovering topics with different configuration - // than the one specified in the yaml configuration file. discovery_database_->start(); logDebug(DDSPIPE, "DDS Pipe created."); @@ -284,7 +282,7 @@ void DdsPipe::discovered_endpoint_nts_( if (RpcTopic::is_service_topic(endpoint.topic)) { - if (endpoint.is_reader() && endpoint.is_server_endpoint()) + if (is_endpoint_type_relevant_(endpoint) && endpoint.is_server_endpoint()) { // Service server discovered discovered_service_nts_(RpcTopic( @@ -347,39 +345,45 @@ void DdsPipe::updated_endpoint_nts_( } } +bool DdsPipe::is_endpoint_type_relevant_( + const Endpoint& endpoint) noexcept +{ + switch (configuration_.discovery_trigger) + { + case DiscoveryTrigger::READER: + return endpoint.is_reader(); + + case DiscoveryTrigger::WRITER: + return endpoint.is_writer(); + + case DiscoveryTrigger::ANY: + return true; + + case DiscoveryTrigger::NONE: + return false; + + default: + utils::tsnh(utils::Formatter() << "Invalid Discovery Trigger."); + return false; + } +} + bool DdsPipe::is_endpoint_relevant_( const Endpoint& endpoint) noexcept { - auto is_endpoint_type_relevant = [&](const Endpoint& entity) - { - switch (configuration_.discovery_trigger) - { - case DiscoveryTrigger::READER: - return entity.is_reader(); - case DiscoveryTrigger::WRITER: - return entity.is_writer(); - case DiscoveryTrigger::ANY: - return true; - case DiscoveryTrigger::NONE: - return false; - default: - return false; - } - }; + if (!is_endpoint_type_relevant_(endpoint)) + { + return false; + } - auto is_endpoint_relevant = [endpoint, is_endpoint_type_relevant](const Endpoint& entity) + auto is_endpoint_relevant = [&, endpoint](const Endpoint& entity) { return entity.active && - is_endpoint_type_relevant(entity) && + is_endpoint_type_relevant_(entity) && entity.topic == endpoint.topic && entity.discoverer_participant_id == endpoint.discoverer_participant_id; }; - if (!is_endpoint_type_relevant(endpoint)) - { - return false; - } - const auto& relevant_endpoints = discovery_database_->get_endpoints(is_endpoint_relevant); if (endpoint.active) From 8197b798b52ad7a5447b256db0baf4ec6854e8fc Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 17 Nov 2023 08:37:24 +0100 Subject: [PATCH 08/12] Apply suggestions Signed-off-by: tempate --- ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp | 6 +++++- ddspipe_core/src/cpp/core/DdsPipe.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp b/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp index d6b33940..7792805a 100644 --- a/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp +++ b/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp @@ -216,14 +216,18 @@ class DdsPipe * @brief Method called every time a new endpoint has been discovered, removed, or updated. * * @param [in] endpoint : endpoint discovered, removed, or updated. + * + * @return Whether the endpoint's kind matches the discovery trigger. */ - bool is_endpoint_type_relevant_( + bool is_endpoint_kind_relevant_( const types::Endpoint& endpoint) noexcept; /** * @brief Method called every time a new endpoint has been discovered, removed, or updated. * * @param [in] endpoint : endpoint discovered, removed, or updated. + * + * @return Whether the DdsPipe's discovery callbacks need to process the endpoint. */ bool is_endpoint_relevant_( const types::Endpoint& endpoint) noexcept; diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 7b831f29..070ebbc1 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -282,7 +282,7 @@ void DdsPipe::discovered_endpoint_nts_( if (RpcTopic::is_service_topic(endpoint.topic)) { - if (is_endpoint_type_relevant_(endpoint) && endpoint.is_server_endpoint()) + if (is_endpoint_kind_relevant_(endpoint) && endpoint.is_server_endpoint()) { // Service server discovered discovered_service_nts_(RpcTopic( @@ -345,7 +345,7 @@ void DdsPipe::updated_endpoint_nts_( } } -bool DdsPipe::is_endpoint_type_relevant_( +bool DdsPipe::is_endpoint_kind_relevant_( const Endpoint& endpoint) noexcept { switch (configuration_.discovery_trigger) @@ -371,7 +371,7 @@ bool DdsPipe::is_endpoint_type_relevant_( bool DdsPipe::is_endpoint_relevant_( const Endpoint& endpoint) noexcept { - if (!is_endpoint_type_relevant_(endpoint)) + if (!is_endpoint_kind_relevant_(endpoint)) { return false; } @@ -379,7 +379,7 @@ bool DdsPipe::is_endpoint_relevant_( auto is_endpoint_relevant = [&, endpoint](const Endpoint& entity) { return entity.active && - is_endpoint_type_relevant_(entity) && + is_endpoint_kind_relevant_(entity) && entity.topic == endpoint.topic && entity.discoverer_participant_id == endpoint.discoverer_participant_id; }; From 2b89a3514a477f8ac7e0567b2b7cc819a3bab9af Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 21 Nov 2023 08:09:27 +0100 Subject: [PATCH 09/12] Apply suggestions Signed-off-by: tempate --- ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp | 5 +++++ ddspipe_core/src/cpp/core/DdsPipe.cpp | 2 +- .../include/ddspipe_yaml/yaml_configuration_tags.hpp | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp b/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp index 39d30008..8e09ed85 100644 --- a/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp +++ b/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp @@ -29,6 +29,11 @@ namespace core { bool DdsPipeConfiguration::is_valid( utils::Formatter& error_msg) const noexcept { + if (remove_unused_entities && discovery_trigger != DiscoveryTrigger::READER) + { + return false; + } + return routes.is_valid(error_msg) && topic_routes.is_valid(error_msg); } diff --git a/ddspipe_core/src/cpp/core/DdsPipe.cpp b/ddspipe_core/src/cpp/core/DdsPipe.cpp index 070ebbc1..af966a6f 100644 --- a/ddspipe_core/src/cpp/core/DdsPipe.cpp +++ b/ddspipe_core/src/cpp/core/DdsPipe.cpp @@ -376,7 +376,7 @@ bool DdsPipe::is_endpoint_relevant_( return false; } - auto is_endpoint_relevant = [&, endpoint](const Endpoint& entity) + auto is_endpoint_relevant = [&](const Endpoint& entity) { return entity.active && is_endpoint_kind_relevant_(entity) && diff --git a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp index 2b9752de..c5191f82 100644 --- a/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp +++ b/ddspipe_yaml/include/ddspipe_yaml/yaml_configuration_tags.hpp @@ -141,7 +141,7 @@ constexpr const char* SPECS_QOS_TAG("qos"); //! Global Topic QoS constexpr const char* NUMBER_THREADS_TAG("threads"); //! Number of threads to configure the thread pool constexpr const char* WAIT_ALL_ACKED_TIMEOUT_TAG("wait-all-acked-timeout"); //! Wait for a maximum of *wait-all-acked-timeout* ms until all msgs sent by reliable writers are acknowledged by their matched readers constexpr const char* REMOVE_UNUSED_ENTITIES_TAG("remove-unused-entities"); //! Dynamically create and delete entities and tracks. -constexpr const char* DISCOVERY_TRIGGER_TAG("discovery-trigger"); //! Dynamically trigger the discovery of entities. +constexpr const char* DISCOVERY_TRIGGER_TAG("discovery-trigger"); //! Make the trigger of the DDS Pipe callbacks configurable. // XML configuration tags constexpr const char* XML_TAG("xml"); //! Tag to read xml configuration From 89758773f4b64ad635ac971be809fc5017d56a74 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 21 Nov 2023 12:38:57 +0100 Subject: [PATCH 10/12] Apply suggestions Signed-off-by: tempate --- .../configuration/DdsPipeConfiguration.hpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp index 5bbb0d51..493fff3d 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -32,13 +33,14 @@ namespace eprosima { namespace ddspipe { namespace core { -enum DiscoveryTrigger -{ - READER = 0, //! The discovery callbacks get triggered by the discovery of a reader. - WRITER = 1, //! The discovery callbacks get triggered by the discovery of a writer. - NONE = 2, //! The discovery callbacks don't get triggered by the discovery of readers or writers. - ANY = 3 //! The discovery callbacks get triggered by the discovery of either a reader or a writer. -}; +//! Possible kinds of the endpoint +ENUMERATION_BUILDER( + DiscoveryTrigger, + READER, //! The discovery callbacks get triggered by the discovery of a reader. + WRITER, //! The discovery callbacks get triggered by the discovery of a writer. + NONE, //! The discovery callbacks don't get triggered by the discovery of readers or writers. + ANY //! The discovery callbacks get triggered by the discovery of either a reader or a writer. + ); /** * Configuration structure encapsulating the configuration of a \c DdsPipe instance. From 8d8ded798666340f0399291112a8ff91f2ab526c Mon Sep 17 00:00:00 2001 From: tempate Date: Wed, 22 Nov 2023 08:58:48 +0100 Subject: [PATCH 11/12] Apply suggestions Signed-off-by: tempate --- .../ddspipe_core/configuration/DdsPipeConfiguration.hpp | 2 +- ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp | 9 +++++++-- .../src/cpp/configuration/DdsPipeConfiguration.cpp | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp index 493fff3d..8420a2a1 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/DdsPipeConfiguration.hpp @@ -33,7 +33,7 @@ namespace eprosima { namespace ddspipe { namespace core { -//! Possible kinds of the endpoint +//! Possible kinds of discovery triggers ENUMERATION_BUILDER( DiscoveryTrigger, READER, //! The discovery callbacks get triggered by the discovery of a reader. diff --git a/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp b/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp index 7792805a..57687b03 100644 --- a/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp +++ b/ddspipe_core/include/ddspipe_core/core/DdsPipe.hpp @@ -213,7 +213,9 @@ class DdsPipe const types::Endpoint& endpoint) noexcept; /** - * @brief Method called every time a new endpoint has been discovered, removed, or updated. + * @brief Check whether the kind of an endpoint matches the discovery trigger kind. + * + * Method called every time a new endpoint has been discovered, removed, or updated. * * @param [in] endpoint : endpoint discovered, removed, or updated. * @@ -223,7 +225,10 @@ class DdsPipe const types::Endpoint& endpoint) noexcept; /** - * @brief Method called every time a new endpoint has been discovered, removed, or updated. + * @brief Check whether an endpoint is the first endpoint discovered or the last removed. + * + * Method called every time a new endpoint has been discovered, removed, or updated. + * This method calls \c is_endpoint_kind_relevant_ * * @param [in] endpoint : endpoint discovered, removed, or updated. * diff --git a/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp b/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp index 8e09ed85..099c7bb2 100644 --- a/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp +++ b/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp @@ -31,6 +31,7 @@ bool DdsPipeConfiguration::is_valid( { if (remove_unused_entities && discovery_trigger != DiscoveryTrigger::READER) { + error_msg << "A discovery-trigger different to reader is incompatible with remove-unused-entities."; return false; } From af12bb6118748a2994ef1bea57cdcdffeaa495da Mon Sep 17 00:00:00 2001 From: tempate Date: Wed, 22 Nov 2023 09:57:54 +0100 Subject: [PATCH 12/12] Apply suggestions Signed-off-by: tempate --- ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp b/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp index 099c7bb2..5e3f8561 100644 --- a/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp +++ b/ddspipe_core/src/cpp/configuration/DdsPipeConfiguration.cpp @@ -31,7 +31,7 @@ bool DdsPipeConfiguration::is_valid( { if (remove_unused_entities && discovery_trigger != DiscoveryTrigger::READER) { - error_msg << "A discovery-trigger different to reader is incompatible with remove-unused-entities."; + error_msg << "A discovery-trigger different from reader is incompatible with remove-unused-entities."; return false; }