-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the trigger of the DDS Pipe callbacks configurable #67
Changes from all commits
952d207
13c1126
e9b69f1
412105a
3dee011
b92a08b
83339d5
8197b79
2b89a35
8975877
8d8ded7
af12bb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
#include <cpp_utils/exception/InitializationException.hpp> | ||
#include <cpp_utils/exception/InconsistencyException.hpp> | ||
#include <cpp_utils/Log.hpp> | ||
#include <cpp_utils/utils.hpp> | ||
|
||
#include <ddspipe_core/core/DdsPipe.hpp> | ||
|
||
|
@@ -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_kind_relevant_(endpoint) && endpoint.is_server_endpoint()) | ||
{ | ||
// Service server discovered | ||
discovered_service_nts_(RpcTopic( | ||
|
@@ -347,18 +345,41 @@ void DdsPipe::updated_endpoint_nts_( | |
} | ||
} | ||
|
||
bool DdsPipe::is_endpoint_kind_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 | ||
jepemi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (!endpoint.is_reader()) | ||
if (!is_endpoint_kind_relevant_(endpoint)) | ||
{ | ||
return false; | ||
} | ||
|
||
auto is_endpoint_relevant = [endpoint](const Endpoint& entity) | ||
auto is_endpoint_relevant = [&](const Endpoint& entity) | ||
{ | ||
return entity.active && | ||
entity.is_reader() && | ||
is_endpoint_kind_relevant_(entity) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes little sense to me, as this logic specific to the remove unused entities feature is not supported for a discovery trigger value other than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related suggestion, although does not tackle the previous comment (cannot hold it back): I suggest having an if-else with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is more appropriate to address that change in a new branch, since it changes the dynamic of the DdsPipe at it should be thoroughly thought about and tested. I will also take the liberty to change other things which I think would improve the DdsPipe readability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Write an error trace in is_valid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Different to" is apparently colloquial, use "from" or "than". |
||
entity.topic == endpoint.topic && | ||
entity.discoverer_participant_id == endpoint.discoverer_participant_id; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lower case to simplify your life (and reviewer's).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Example is not another way to teach, it's the only way." — Albert Einstein
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides, it wouldn't simplify anything. We would have to rename the enum and all its occurrences to avoid copying an int. And in the future
to_uppercase
andto_lowercase
would return the string in uppercase or lowercase anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The fool knows after he's suffered." — Hesiod