Skip to content

Commit

Permalink
Make the DdsPipeConfiguration required
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate committed Oct 16, 2023
1 parent d9c9753 commit 4c906f4
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,23 @@ std::shared_ptr<DdsPipe> create_pipe(
dds_participant
);

// Create allowed topics list
std::set<utils::Heritable<types::IFilterTopic>> lists = {};
std::shared_ptr<AllowedTopicList> allowed_topics =
std::make_shared<AllowedTopicList>(
lists,
lists);

// Create Thread Pool
unsigned int n_threads = 12;
std::shared_ptr<utils::SlotThreadPool> thread_pool =
std::make_shared<utils::SlotThreadPool>(n_threads);

// Create DDS Pipe
std::set<utils::Heritable<types::DistributedTopic>> builtin_topics = {};
DdsPipeConfiguration ddspipe_configuration;
ddspipe_configuration.init_enabled = true;

std::shared_ptr<DdsPipe> pipe =
std::make_unique<DdsPipe>(
allowed_topics,
ddspipe_configuration,
discovery_database,
payload_pool,
participant_database,
thread_pool,
builtin_topics,
true
);
thread_pool);

return pipe;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,23 @@ std::shared_ptr<DdsPipe> create_pipe(
dds_participant
);

// Create allowed topics list
std::set<utils::Heritable<types::IFilterTopic>> lists = {};
std::shared_ptr<AllowedTopicList> allowed_topics =
std::make_shared<AllowedTopicList>(
lists,
lists);

// Create Thread Pool
unsigned int n_threads = 12;
std::shared_ptr<utils::SlotThreadPool> thread_pool =
std::make_shared<utils::SlotThreadPool>(n_threads);

// Create DDS Pipe
std::set<utils::Heritable<types::DistributedTopic>> builtin_topics = {};
DdsPipeConfiguration ddspipe_configuration;
ddspipe_configuration.init_enabled = true;

std::shared_ptr<DdsPipe> pipe =
std::make_unique<DdsPipe>(
allowed_topics,
ddspipe_configuration,
discovery_database,
payload_pool,
participant_database,
thread_pool,
builtin_topics,
true
);
thread_pool);

return pipe;
}

Expand Down
14 changes: 2 additions & 12 deletions fastddsspy_tool/src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,7 @@ int main(
try
{
eprosima::spy::yaml::Configuration new_configuration(file_path);
spy.reload_allowed_topics(
std::make_shared<eprosima::ddspipe::core::AllowedTopicList>(
new_configuration.allowlist,
new_configuration.blocklist
)
);
spy.reload_configuration(new_configuration);
}
catch (const std::exception& e)
{
Expand Down Expand Up @@ -199,12 +194,7 @@ int main(
try
{
eprosima::spy::yaml::Configuration new_configuration(file_path);
spy.reload_allowed_topics(
std::make_shared<eprosima::ddspipe::core::AllowedTopicList>(
new_configuration.allowlist,
new_configuration.blocklist
)
);
spy.reload_configuration(new_configuration);
}
catch (const std::exception& e)
{
Expand Down
16 changes: 5 additions & 11 deletions fastddsspy_tool/src/cpp/tool/Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ Backend::Backend(
: configuration_(configuration)
, payload_pool_(std::make_shared<ddspipe::core::FastPayloadPool>())
, discovery_database_(std::make_shared<ddspipe::core::DiscoveryDatabase>())
, allowed_topics_(
std::make_shared<ddspipe::core::AllowedTopicList>(
configuration.allowlist,
configuration.blocklist))
, thread_pool_(
std::make_shared<utils::SlotThreadPool>(
configuration.n_threads))
Expand Down Expand Up @@ -66,13 +62,11 @@ Backend::Backend(

// Create and initialize Pipe
pipe_ = std::make_unique<ddspipe::core::DdsPipe>(
allowed_topics_,
configuration.ddspipe_configuration,
discovery_database_,
payload_pool_,
participant_database_,
thread_pool_,
configuration.builtin_topics
);
thread_pool_);

pipe_->enable();
}
Expand All @@ -82,10 +76,10 @@ Backend::~Backend()
pipe_->disable();
}

utils::ReturnCode Backend::reload_allowed_topics(
const std::shared_ptr<ddspipe::core::AllowedTopicList>& allowed_topics)
utils::ReturnCode Backend::reload_configuration(
const yaml::Configuration& new_configuration)
{
return pipe_->reload_allowed_topics(allowed_topics);
return pipe_->reload_configuration(new_configuration.ddspipe_configuration);
}

std::shared_ptr<eprosima::spy::participants::SpyModel> Backend::model() const noexcept
Expand Down
7 changes: 2 additions & 5 deletions fastddsspy_tool/src/cpp/tool/Backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Backend

~Backend();

utils::ReturnCode reload_allowed_topics(
const std::shared_ptr<ddspipe::core::AllowedTopicList>& allowed_topics);
utils::ReturnCode reload_configuration(
const yaml::Configuration& new_configuration);

std::shared_ptr<eprosima::spy::participants::SpyModel> model() const noexcept;

Expand All @@ -62,9 +62,6 @@ class Backend
//! TODO comment
std::shared_ptr<ddspipe::core::DiscoveryDatabase> discovery_database_;

//! TODO comment
std::shared_ptr<ddspipe::core::AllowedTopicList> allowed_topics_;

//! TODO comment
std::shared_ptr<eprosima::utils::SlotThreadPool> thread_pool_;

Expand Down
6 changes: 3 additions & 3 deletions fastddsspy_tool/src/cpp/tool/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void Controller::one_shot_run(
run_command_(input_.parse_as_command(args));
}

utils::ReturnCode Controller::reload_allowed_topics(
const std::shared_ptr<ddspipe::core::AllowedTopicList>& allowed_topics)
utils::ReturnCode Controller::reload_configuration(
const yaml::Configuration& new_configuration)
{
return backend_.reload_allowed_topics(allowed_topics);
return backend_.reload_configuration(new_configuration);
}

void Controller::run_command_(
Expand Down
4 changes: 2 additions & 2 deletions fastddsspy_tool/src/cpp/tool/Controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class Controller
void one_shot_run(
const std::vector<std::string>& args);

utils::ReturnCode reload_allowed_topics(
const std::shared_ptr<ddspipe::core::AllowedTopicList>& allowed_topics);
utils::ReturnCode reload_configuration(
const yaml::Configuration& new_configuration);

protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#include <cpp_utils/memory/Heritable.hpp>
#include <cpp_utils/time/time_utils.hpp>

#include <ddspipe_core/configuration/DdsPipeConfiguration.hpp>
#include <ddspipe_core/configuration/IConfiguration.hpp>
#include <ddspipe_core/types/topic/filter/IFilterTopic.hpp>
#include <ddspipe_core/types/topic/dds/DistributedTopic.hpp>
#include <ddspipe_core/configuration/IConfiguration.hpp>

#include <ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp>
#include <ddspipe_participants/configuration/ParticipantConfiguration.hpp>
Expand All @@ -28,6 +29,8 @@
#include <ddspipe_yaml/YamlReader.hpp>

#include <fastddsspy_participants/configuration/SpyParticipantConfiguration.hpp>
#include <fastddsspy_participants/types/EndpointInfo.hpp>
#include <fastddsspy_participants/types/ParticipantInfo.hpp>

#include <fastddsspy_yaml/library/library_dll.h>

Expand Down Expand Up @@ -57,15 +60,13 @@ class Configuration : ddspipe::core::IConfiguration
virtual bool is_valid(
utils::Formatter& error_msg) const noexcept override;

// DDS Pipe Configuration
ddspipe::core::DdsPipeConfiguration ddspipe_configuration;

// Participants configurations
std::shared_ptr<ddspipe::participants::SimpleParticipantConfiguration> simple_configuration;
std::shared_ptr<participants::SpyParticipantConfiguration> spy_configuration;

// Topic filtering
std::set<utils::Heritable<ddspipe::core::types::IFilterTopic>> allowlist {};
std::set<utils::Heritable<ddspipe::core::types::IFilterTopic>> blocklist {};
std::set<utils::Heritable<ddspipe::core::types::DistributedTopic>> builtin_topics {};

// Specs
unsigned int n_threads = 12;
utils::Duration_ms one_shot_wait_time_ms = 1000;
Expand Down
12 changes: 6 additions & 6 deletions fastddsspy_yaml/src/cpp/YamlReaderConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ void Configuration::load_configuration_(
WildcardDdsFilterTopic rpc_request_topic, rpc_response_topic;
rpc_request_topic.topic_name.set_value("rq/*");
rpc_response_topic.topic_name.set_value("rr/*");
blocklist.insert(
ddspipe_configuration.blocklist.insert(
utils::Heritable<WildcardDdsFilterTopic>::make_heritable(rpc_request_topic));
blocklist.insert(
ddspipe_configuration.blocklist.insert(
utils::Heritable<WildcardDdsFilterTopic>::make_heritable(rpc_response_topic));

}
Expand All @@ -117,21 +117,21 @@ void Configuration::load_dds_configuration_(
// Get optional allowlist
if (YamlReader::is_tag_present(yml, ALLOWLIST_TAG))
{
allowlist = YamlReader::get_set<utils::Heritable<IFilterTopic>>(yml, ALLOWLIST_TAG,
ddspipe_configuration.allowlist = YamlReader::get_set<utils::Heritable<IFilterTopic>>(yml, ALLOWLIST_TAG,
version);

// Add to allowlist always the type object topic
WildcardDdsFilterTopic internal_topic;
internal_topic.topic_name.set_value(TYPE_OBJECT_TOPIC_NAME);
allowlist.insert(
ddspipe_configuration.allowlist.insert(
utils::Heritable<WildcardDdsFilterTopic>::make_heritable(internal_topic));
}

/////
// Get optional blocklist
if (YamlReader::is_tag_present(yml, BLOCKLIST_TAG))
{
blocklist = YamlReader::get_set<utils::Heritable<IFilterTopic>>(yml, BLOCKLIST_TAG,
ddspipe_configuration.blocklist = YamlReader::get_set<utils::Heritable<IFilterTopic>>(yml, BLOCKLIST_TAG,
version);
}

Expand All @@ -140,7 +140,7 @@ void Configuration::load_dds_configuration_(
if (YamlReader::is_tag_present(yml, BUILTIN_TAG))
{
// WARNING: Parse builtin topics AFTER specs, as some topic-specific default values are set there
builtin_topics = YamlReader::get_set<utils::Heritable<DistributedTopic>>(yml, BUILTIN_TAG,
ddspipe_configuration.builtin_topics = YamlReader::get_set<utils::Heritable<DistributedTopic>>(yml, BUILTIN_TAG,
version);
}

Expand Down

0 comments on commit 4c906f4

Please sign in to comment.