Skip to content

Commit

Permalink
Simplify the DdsPipe's constructor
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate committed Oct 10, 2023
1 parent 7d2a2d2 commit 69e25e8
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <ddspipe_participants/configuration/ParticipantConfiguration.hpp>
#include <ddspipe_participants/xml/XmlHandlerConfiguration.hpp>

#include <ddsrouter_core/configuration/DdsRouterReloadConfiguration.hpp>
#include <ddsrouter_core/configuration/SpecsConfiguration.hpp>
#include <ddsrouter_core/types/ParticipantKind.hpp>

Expand All @@ -39,7 +38,7 @@ namespace core {
* - Participant configurations.
* - Advanced configurations.
*/
struct DdsRouterConfiguration : public DdsRouterReloadConfiguration
struct DdsRouterConfiguration : public ddspipe::core::IConfiguration
{

/////////////////////////
Expand All @@ -53,10 +52,6 @@ struct DdsRouterConfiguration : public DdsRouterReloadConfiguration
// METHODS
/////////////////////////

//! Set internal values with the values reloaded
DDSROUTER_CORE_DllAPI void reload(
const DdsRouterReloadConfiguration& new_configuration);

//! Override \c is_valid method.
DDSROUTER_CORE_DllAPI bool is_valid(
utils::Formatter& error_msg) const noexcept override;
Expand All @@ -65,9 +60,6 @@ struct DdsRouterConfiguration : public DdsRouterReloadConfiguration
// VARIABLES
/////////////////////////

//! Builtin topics to create at the beggining of the execution
std::set<utils::Heritable<ddspipe::core::types::DistributedTopic>> builtin_topics {};

//! Participant configurations
std::set<
std::pair<
Expand Down

This file was deleted.

10 changes: 1 addition & 9 deletions ddsrouter_core/include/ddsrouter_core/core/DdsRouter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include <ddsrouter_core/core/ParticipantFactory.hpp>
#include <ddsrouter_core/configuration/DdsRouterConfiguration.hpp>
#include <ddsrouter_core/configuration/DdsRouterReloadConfiguration.hpp>
#include <ddsrouter_core/library/library_dll.h>

namespace eprosima {
Expand Down Expand Up @@ -78,7 +77,7 @@ class DdsRouter
* @throw \c ConfigurationException in case the new yaml is not well-formed
*/
DDSROUTER_CORE_DllAPI utils::ReturnCode reload_configuration(
const DdsRouterReloadConfiguration& configuration);
const DdsRouterConfiguration& configuration);

/**
* @brief Start communication in DDS Router
Expand All @@ -104,13 +103,6 @@ class DdsRouter

protected:

/**
* @brief Load allowed topics from configuration
*
* @throw \c ConfigurationException in case the yaml inside allowlist is not well-formed
*/
void init_allowed_topics_();

/**
* @brief Create participants and add them to the participants database
*
Expand Down
14 changes: 0 additions & 14 deletions ddsrouter_core/src/cpp/configuration/DdsRouterConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,15 @@
#include <ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp>

#include <ddsrouter_core/configuration/DdsRouterConfiguration.hpp>
#include <ddsrouter_core/configuration/DdsRouterReloadConfiguration.hpp>
#include <ddsrouter_core/types/ParticipantKind.hpp>

namespace eprosima {
namespace ddsrouter {
namespace core {

void DdsRouterConfiguration::reload(
const DdsRouterReloadConfiguration& new_configuration)
{
this->allowlist = new_configuration.allowlist;
this->blocklist = new_configuration.blocklist;
}

bool DdsRouterConfiguration::is_valid(
utils::Formatter& error_msg) const noexcept
{
// Check Allow list topics
if (!DdsRouterReloadConfiguration::is_valid(error_msg))
{
return false;
}

// Check there are at least two participants
if (participants_configurations.size() < 1)
{
Expand Down

This file was deleted.

30 changes: 3 additions & 27 deletions ddsrouter_core/src/cpp/core/DdsRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <ddspipe_core/types/dds/TopicQoS.hpp>

#include <ddsrouter_core/configuration/DdsRouterConfiguration.hpp>
#include <ddsrouter_core/configuration/DdsRouterReloadConfiguration.hpp>
#include <ddsrouter_core/core/DdsRouter.hpp>

namespace eprosima {
Expand All @@ -53,39 +52,20 @@ DdsRouter::DdsRouter(
"Configuration for DDS Router is invalid: " << error_msg);
}

// Set default value for history
ddspipe::core::types::TopicQoS::default_history_depth.store(
configuration_.advanced_options.max_history_depth);

// Init topic allowed
init_allowed_topics_();

// Load Participants
init_participants_();

// Initialize the DdsPipe
ddspipe_ = std::unique_ptr<ddspipe::core::DdsPipe>(new ddspipe::core::DdsPipe(
configuration_.ddspipe_configuration,
allowed_topics_,
discovery_database_,
payload_pool_,
participants_database_,
thread_pool_,
configuration_.builtin_topics,
false));
thread_pool_));

logDebug(DDSROUTER, "DDS Router created.");
}

void DdsRouter::init_allowed_topics_()
{
allowed_topics_ = std::make_shared<ddspipe::core::AllowedTopicList>(
configuration_.allowlist,
configuration_.blocklist);

logInfo(DDSROUTER, "DDS Router configured with allowed topics: " << *allowed_topics_);
}

void DdsRouter::init_participants_()
{
for (std::pair<types::ParticipantKind,
Expand Down Expand Up @@ -126,7 +106,7 @@ void DdsRouter::init_participants_()
}

utils::ReturnCode DdsRouter::reload_configuration(
const DdsRouterReloadConfiguration& new_configuration)
const DdsRouterConfiguration& new_configuration)
{
// Check that the configuration is correct
utils::Formatter error_msg;
Expand All @@ -137,11 +117,7 @@ utils::ReturnCode DdsRouter::reload_configuration(
"Configuration for Reload DDS Router is invalid: " << error_msg);
}

allowed_topics_ = std::make_shared<ddspipe::core::AllowedTopicList>(
new_configuration.allowlist,
new_configuration.blocklist);

return ddspipe_->reload_allowed_topics(allowed_topics_);
return ddspipe_->reload_configuration(new_configuration.ddspipe_configuration);
}

utils::ReturnCode DdsRouter::start() noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ DdsRouterConfiguration router_configuration(
// One topic
core::types::WildcardDdsFilterTopic topic;
topic.topic_name.set_value(TOPIC_NAME);
conf.allowlist.insert(
conf.ddspipe_configuration.allowlist.insert(
utils::Heritable<core::types::WildcardDdsFilterTopic>::make_heritable(topic));

// Two participants, one custom and other simple. If server, simple will work in 0, if not in 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ DdsRouterConfiguration dds_test_simple_configuration(
// Always filter the test topics by topic name
core::types::WildcardDdsFilterTopic topic;
topic.topic_name.set_value(TOPIC_NAME);
conf.allowlist.insert(
conf.ddspipe_configuration.allowlist.insert(
utils::Heritable<core::types::WildcardDdsFilterTopic>::make_heritable(topic));

if (disable_dynamic_discovery)
Expand All @@ -81,8 +81,8 @@ DdsRouterConfiguration dds_test_simple_configuration(
topic_keyed.type_name = "HelloWorldKeyed";
topic_keyed.topic_qos.keyed = true;

conf.builtin_topics.insert(utils::Heritable<core::types::DdsTopic>::make_heritable(topic));
conf.builtin_topics.insert(utils::Heritable<core::types::DdsTopic>::make_heritable(topic_keyed));
conf.ddspipe_configuration.builtin_topics.insert(utils::Heritable<core::types::DdsTopic>::make_heritable(topic));
conf.ddspipe_configuration.builtin_topics.insert(utils::Heritable<core::types::DdsTopic>::make_heritable(topic_keyed));
}

// Two simple participants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ DdsRouterConfiguration dds_test_simple_configuration()
// Always filter the test topics by topic name
core::types::WildcardDdsFilterTopic topic;
topic.topic_name.set_value(TOPIC_NAME);
conf.allowlist.insert(
conf.ddspipe_configuration.allowlist.insert(
utils::Heritable<core::types::WildcardDdsFilterTopic>::make_heritable(topic));

// Two simple participants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ DdsRouterConfiguration router_configuration(
// One topic
core::types::WildcardDdsFilterTopic topic;
topic.topic_name.set_value(TOPIC_NAME);
conf.allowlist.insert(
conf.ddspipe_configuration.allowlist.insert(
utils::Heritable<core::types::WildcardDdsFilterTopic>::make_heritable(topic));

// Two participants, one custom and other simple. If server, simple will work in 0, if not in 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ TEST(ImplementationsTest, pair_implementation_with_topic)
eprosima::ddspipe::core::types::DdsTopic topic;
topic.m_topic_name = "rt/chatter";
topic.type_name = "std_msgs::msg::dds_::String_";
configuration.builtin_topics.insert(
configuration.ddspipe_configuration.builtin_topics.insert(
utils::Heritable<eprosima::ddspipe::core::types::DdsTopic>::make_heritable(topic));

// Create DdsRouter entity
Expand Down
Loading

0 comments on commit 69e25e8

Please sign in to comment.