Skip to content

Commit

Permalink
Refs #21295: Refactor of Participant Discovery Structes
Browse files Browse the repository at this point in the history
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
  • Loading branch information
elianalf committed Jul 23, 2024
1 parent 5108bae commit 8398bc5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 105 deletions.
33 changes: 18 additions & 15 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <fastcdr/Cdr.h>

#include <fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp>
#include <fastdds/dds/core/condition/GuardCondition.hpp>
#include <fastdds/dds/core/condition/WaitSet.hpp>
#include <fastdds/dds/domain/DomainParticipant.hpp>
Expand Down Expand Up @@ -169,11 +170,12 @@ class CustomDomainParticipantListener : public DomainParticipantListener

void on_participant_discovery(
DomainParticipant* participant,
eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info,
eprosima::fastdds::rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored) override
{
should_be_ignored = false;
if (info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT)
if (status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
{
std::cout << "New participant discovered" << std::endl;
// The following line can be modified to evaluate whether the discovered participant should be ignored
Expand All @@ -184,8 +186,8 @@ class CustomDomainParticipantListener : public DomainParticipantListener
should_be_ignored = true; // Request the ignoring of the discovered participant
}
}
else if (info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT ||
info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DROPPED_PARTICIPANT)
else if (status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT ||
status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT)
{
std::cout << "Participant lost" << std::endl;
}
Expand Down Expand Up @@ -960,18 +962,19 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener
/* Custom Callback on_participant_discovery */
void on_participant_discovery(
DomainParticipant* participant,
eprosima::fastdds::rtps::ParticipantDiscoveryInfo&& info,
eprosima::fastdds::rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored) override
{
should_be_ignored = false;
static_cast<void>(participant);
switch (info.status){
case eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT:
switch (status){
case eprosima::fastdds::rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT:
{
/* Process the case when a new DomainParticipant was found in the domain */
std::cout << "New DomainParticipant '" << info.info.m_participantName <<
"' with ID '" << info.info.m_guid.entityId << "' and GuidPrefix '" <<
info.info.m_guid.guidPrefix << "' discovered." << std::endl;
std::cout << "New DomainParticipant '" << info.participant_name <<
"' with ID '" << info.guid.entityId << "' and GuidPrefix '" <<
info.guid.guidPrefix << "' discovered." << std::endl;
/* The following line can be substituted to evaluate whether the discovered participant should be ignored */
bool ignoring_condition = false;
if (ignoring_condition)
Expand All @@ -980,14 +983,14 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener
}
}
break;
case eprosima::fastdds::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT:
case eprosima::fastdds::rtps::ParticipantDiscoveryStatus::CHANGED_QOS_PARTICIPANT:
/* Process the case when a DomainParticipant changed its QOS */
break;
case eprosima::fastdds::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT:
case eprosima::fastdds::rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT:
/* Process the case when a DomainParticipant was removed from the domain */
std::cout << "DomainParticipant '" << info.info.m_participantName <<
"' with ID '" << info.info.m_guid.entityId << "' and GuidPrefix '" <<
info.info.m_guid.guidPrefix << "' left the domain." << std::endl;
std::cout << "DomainParticipant '" << info.participant_name <<
"' with ID '" << info.guid.entityId << "' and GuidPrefix '" <<
info.guid.guidPrefix << "' left the domain." << std::endl;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _api_rtps_builtin_data_participantbuiltintopicdata:

.. rst-class:: api-ref

ParticipantBuiltinTopicData
---------------------------

.. doxygenstruct:: eprosima::fastdds::rtps::ParticipantBuiltinTopicData
:project: FastDDS
:members:
1 change: 1 addition & 0 deletions docs/fastdds/api_reference/rtps/builtin/data/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ Builtin data
:titlesonly:

/fastdds/api_reference/rtps/builtin/data/ContentFilterProperty
/fastdds/api_reference/rtps/builtin/data/ParticipantBuiltinTopicData
/fastdds/api_reference/rtps/builtin/data/PublicationBuiltinTopicData
/fastdds/api_reference/rtps/builtin/data/SubscriptionBuiltinTopicData

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. rst-class:: api-ref

ParticipantDiscoveryStatus
----------------------------

.. doxygenenum:: eprosima::fastdds::rtps::ParticipantDiscoveryStatus
:project: FastDDS

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ParticipantDiscoveryInfo
:titlesonly:

/fastdds/api_reference/rtps/participant/participantdiscoveryinfo/ParticipantAuthenticationInfo
/fastdds/api_reference/rtps/participant/participantdiscoveryinfo/ParticipantDiscoveryInfo_class
/fastdds/api_reference/rtps/participant/participantdiscoveryinfo/ParticipantProxyData
/fastdds/api_reference/rtps/participant/participantdiscoveryinfo/ParticipantDiscoveryStatus
/fastdds/api_reference/rtps/participant/participantdiscoveryinfo/ReaderDiscoveryStatus
/fastdds/api_reference/rtps/participant/participantdiscoveryinfo/WriterDiscoveryStatus

0 comments on commit 8398bc5

Please sign in to comment.