Skip to content

Commit aa80b72

Browse files
Participant discovery structures refactor (#5042)
* Refs #21295: changing the name of the callback from onParticipantDiscovery to on_participant_discovery Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Change listener signature and DISCOVERY_STATUS to PARTICIPANT_DISCOVERY_STATUS Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Move PARTICIPANT_DISCOVERY_STATUS out of ParticipantDiscoveryInfo Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Substitute ParticipantDiscoveryInfo with ParticipantProxyData Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Remove ParticiapntDiscoveryInfo Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Extend ParticipantBuiltinTopicData Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Create ParticipantBuiltinTopicData in rtps namespace Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Create from_proxy_to_builtin method for participant Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Substitute ParticipantProxyData with ParticipantBuiltinTopicData Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Make ParticipantProxyData private Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Update version.md Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Uncrustify Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Fix compilation error after rebase Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Change name in camel case ParticipantDiscoveryStatus Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Change signature of fill_discovery_data_from_cdr_message Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Apply changes to new example Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Apply suggestions Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Apply suggestions Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295. Fix communication test build. Signed-off-by: Miguel Company <miguelcompany@eprosima.com> * Refs #21295. Fix include order. Signed-off-by: Miguel Company <miguelcompany@eprosima.com> * Refs #21295. Additional change on versions.md. Signed-off-by: Miguel Company <miguelcompany@eprosima.com> * Refs #21295: Add missing guid conversion in the converter Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> * Refs #21295: Adjust after rebase Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> --------- Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com> Signed-off-by: Miguel Company <miguelcompany@eprosima.com> Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
1 parent c2dc6d2 commit aa80b72

103 files changed

Lines changed: 546 additions & 441 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/cpp/discovery_server/ServerApp.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,20 @@ ServerApp::~ServerApp()
210210

211211
void ServerApp::on_participant_discovery(
212212
DomainParticipant*,
213-
fastdds::rtps::ParticipantDiscoveryInfo&& info,
213+
fastdds::rtps::ParticipantDiscoveryStatus status,
214+
const ParticipantBuiltinTopicData& info,
214215
bool& should_be_ignored)
215216
{
216217
static_cast<void>(should_be_ignored);
217-
if (info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT)
218+
if (status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
218219
{
219-
std::cout << "Discovered Participant with GUID " << info.info.m_guid << std::endl;
220+
std::cout << "Discovered Participant with GUID " << info.guid << std::endl;
220221
++matched_;
221222
}
222-
else if (info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DROPPED_PARTICIPANT ||
223-
info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT)
223+
else if (status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT ||
224+
status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT)
224225
{
225-
std::cout << "Dropped Participant with GUID " << info.info.m_guid << std::endl;
226+
std::cout << "Dropped Participant with GUID " << info.guid << std::endl;
226227
--matched_;
227228
}
228229
}

examples/cpp/discovery_server/ServerApp.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <condition_variable>
2424

25+
#include <fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp>
2526
#include <fastdds/dds/domain/DomainParticipant.hpp>
2627
#include <fastdds/dds/domain/DomainParticipantListener.hpp>
2728
#include <fastdds/dds/topic/TypeSupport.hpp>
@@ -49,7 +50,8 @@ class ServerApp : public Application, public DomainParticipantListener
4950
//! Publisher matched method
5051
void on_participant_discovery(
5152
DomainParticipant* participant,
52-
fastdds::rtps::ParticipantDiscoveryInfo&& info,
53+
fastdds::rtps::ParticipantDiscoveryStatus status,
54+
const fastdds::rtps::ParticipantBuiltinTopicData& info,
5355
bool& should_be_ignored) override;
5456

5557
//! Run publisher

examples/cpp/request_reply/ClientApp.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,18 @@ void ClientApp::stop()
143143

144144
void ClientApp::on_participant_discovery(
145145
DomainParticipant* /* participant */,
146-
rtps::ParticipantDiscoveryInfo&& info,
146+
rtps::ParticipantDiscoveryStatus status,
147+
const ParticipantBuiltinTopicData& info,
147148
bool& should_be_ignored)
148149
{
149150
std::lock_guard<std::mutex> lock(mtx_);
150151

151152
should_be_ignored = false;
152153

153-
rtps::GuidPrefix_t remote_participant_guid_prefix = info.info.m_guid.guidPrefix;
154-
std::string status_str = TypeConverter::to_string(info.status);
154+
rtps::GuidPrefix_t remote_participant_guid_prefix = info.guid.guidPrefix;
155+
std::string status_str = TypeConverter::to_string(status);
155156

156-
if (info.info.m_userData.data_vec().size() != 1)
157+
if (info.user_data.data_vec().size() != 1)
157158
{
158159
should_be_ignored = true;
159160
request_reply_debug("ClientApp", "Ignoring participant with invalid user data: "
@@ -162,7 +163,7 @@ void ClientApp::on_participant_discovery(
162163

163164
if (!should_be_ignored)
164165
{
165-
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.info.m_userData.data_vec()[0]);
166+
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.user_data.data_vec()[0]);
166167
if (CLIParser::EntityKind::SERVER != entity_kind)
167168
{
168169
should_be_ignored = true;
@@ -176,12 +177,12 @@ void ClientApp::on_participant_discovery(
176177
{
177178
std::string server_str = CLIParser::parse_entity_kind(CLIParser::EntityKind::SERVER);
178179

179-
if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT)
180+
if (status == rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
180181
{
181182
request_reply_debug("ClientApp", server_str << " " << status_str << ": " << remote_participant_guid_prefix);
182183
}
183-
else if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT ||
184-
info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT)
184+
else if (status == rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT ||
185+
status == rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT)
185186
{
186187
request_reply_debug("ClientApp", server_str << " " << status_str << ": " << remote_participant_guid_prefix);
187188
}

examples/cpp/request_reply/ClientApp.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class ClientApp : public Application, public DomainParticipantListener
7171
//! Participant discovery method
7272
void on_participant_discovery(
7373
DomainParticipant* participant,
74-
rtps::ParticipantDiscoveryInfo&& info,
74+
rtps::ParticipantDiscoveryStatus status,
75+
const ParticipantBuiltinTopicData& info,
7576
bool& should_be_ignored) override;
7677

7778
//! Publication matched method

examples/cpp/request_reply/ServerApp.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,18 @@ void ServerApp::stop()
130130

131131
void ServerApp::on_participant_discovery(
132132
DomainParticipant* /* participant */,
133-
rtps::ParticipantDiscoveryInfo&& info,
133+
rtps::ParticipantDiscoveryStatus status,
134+
const ParticipantBuiltinTopicData& info,
134135
bool& should_be_ignored)
135136
{
136137
std::lock_guard<std::mutex> lock(mtx_);
137138

138139
should_be_ignored = false;
139140

140-
rtps::GuidPrefix_t remote_participant_guid_prefix = info.info.m_guid.guidPrefix;
141-
std::string status_str = TypeConverter::to_string(info.status);
141+
rtps::GuidPrefix_t remote_participant_guid_prefix = info.guid.guidPrefix;
142+
std::string status_str = TypeConverter::to_string(status);
142143

143-
if (info.info.m_userData.data_vec().size() != 1)
144+
if (info.user_data.data_vec().size() != 1)
144145
{
145146
should_be_ignored = true;
146147
request_reply_debug("ServerApp", "Ignoring participant with invalid user data: "
@@ -149,7 +150,7 @@ void ServerApp::on_participant_discovery(
149150

150151
if (!should_be_ignored)
151152
{
152-
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.info.m_userData.data_vec()[0]);
153+
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.user_data.data_vec()[0]);
153154
if (CLIParser::EntityKind::CLIENT != entity_kind)
154155
{
155156
should_be_ignored = true;
@@ -163,12 +164,12 @@ void ServerApp::on_participant_discovery(
163164
{
164165
std::string client_str = CLIParser::parse_entity_kind(CLIParser::EntityKind::CLIENT);
165166

166-
if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT)
167+
if (status == rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
167168
{
168169
request_reply_debug("ServerApp", client_str << " " << status_str << ": " << remote_participant_guid_prefix);
169170
}
170-
else if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT ||
171-
info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT)
171+
else if (status == rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT ||
172+
status == rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT)
172173
{
173174
client_matched_status_.match_reply_reader(remote_participant_guid_prefix, false);
174175
client_matched_status_.match_request_writer(remote_participant_guid_prefix, false);

examples/cpp/request_reply/ServerApp.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class ServerApp : public Application, public DomainParticipantListener
6868
//! Participant discovery method
6969
void on_participant_discovery(
7070
DomainParticipant* participant,
71-
rtps::ParticipantDiscoveryInfo&& info,
71+
rtps::ParticipantDiscoveryStatus status,
72+
const ParticipantBuiltinTopicData& info,
7273
bool& should_be_ignored) override;
7374

7475
//! Publication matched method

examples/cpp/request_reply/app_utils.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,25 +225,25 @@ struct TypeConverter
225225
}
226226

227227
static std::string to_string(
228-
const rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS& info)
228+
const rtps::ParticipantDiscoveryStatus& info)
229229
{
230230
std::string info_str = "Unknown";
231231

232232
switch (info)
233233
{
234-
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT:
234+
case rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT:
235235
info_str = "discovered";
236236
break;
237-
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::CHANGED_QOS_PARTICIPANT:
237+
case rtps::ParticipantDiscoveryStatus::CHANGED_QOS_PARTICIPANT:
238238
info_str = "changed QoS";
239239
break;
240-
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT:
240+
case rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT:
241241
info_str = "removed";
242242
break;
243-
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT:
243+
case rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT:
244244
info_str = "dropped";
245245
break;
246-
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::IGNORED_PARTICIPANT:
246+
case rtps::ParticipantDiscoveryStatus::IGNORED_PARTICIPANT:
247247
info_str = "ignored";
248248
break;
249249
default:

include/fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,14 @@
2020
#ifndef FASTDDS_DDS_BUILTIN_TOPIC__PARTICIPANTBUILTINTOPICDATA_HPP
2121
#define FASTDDS_DDS_BUILTIN_TOPIC__PARTICIPANTBUILTINTOPICDATA_HPP
2222

23-
#include <fastdds/dds/builtin/topic/BuiltinTopicKey.hpp>
24-
#include <fastdds/dds/core/policy/QosPolicies.hpp>
23+
#include <fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp>
2524

2625
namespace eprosima {
2726
namespace fastdds {
2827
namespace dds {
29-
namespace builtin {
3028

31-
struct ParticipantBuiltinTopicData
32-
{
33-
//! Builtin topic Key
34-
BuiltinTopicKey_t key;
29+
using ParticipantBuiltinTopicData = rtps::ParticipantBuiltinTopicData;
3530

36-
//! UserData QoS
37-
UserDataQosPolicy user_data;
38-
};
39-
40-
} // builtin
4131
} // dds
4232
} // fastdds
4333
} // eprosima

include/fastdds/dds/domain/DomainParticipant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ class DomainParticipant : public Entity
698698
* @warning Not supported yet. Currently returns RETCODE_UNSUPPORTED
699699
*/
700700
FASTDDS_EXPORTED_API ReturnCode_t get_discovered_participant_data(
701-
builtin::ParticipantBuiltinTopicData& participant_data,
701+
ParticipantBuiltinTopicData& participant_data,
702702
const InstanceHandle_t& participant_handle) const;
703703

704704
/**

include/fastdds/dds/domain/DomainParticipantListener.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <fastdds/dds/publisher/PublisherListener.hpp>
2626
#include <fastdds/dds/subscriber/SubscriberListener.hpp>
2727
#include <fastdds/dds/topic/TopicListener.hpp>
28+
#include <fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp>
2829
#include <fastdds/rtps/participant/ParticipantDiscoveryInfo.hpp>
2930
#include <fastdds/rtps/reader/ReaderDiscoveryStatus.hpp>
3031
#include <fastdds/rtps/writer/WriterDiscoveryStatus.hpp>
@@ -34,6 +35,7 @@ namespace fastdds {
3435
namespace dds {
3536

3637
class DomainParticipant;
38+
class ParticipantProxyData;
3739

3840
/**
3941
* Class DomainParticipantListener, overrides behaviour towards certain events.
@@ -66,16 +68,20 @@ class DomainParticipantListener :
6668
* its QOS or is removed.
6769
*
6870
* @param [out] participant Pointer to the Participant which discovered the remote participant.
71+
* @param [out] reason Reason of the change in the status of the discovered participant.
6972
* @param [out] info Remote participant information. User can take ownership of the object.
7073
* @param [out] should_be_ignored Flag to indicate the library to automatically ignore the discovered Participant.
7174
*/
7275
virtual void on_participant_discovery(
7376
DomainParticipant* participant,
74-
rtps::ParticipantDiscoveryInfo&& info,
77+
fastdds::rtps::ParticipantDiscoveryStatus reason,
78+
const ParticipantBuiltinTopicData& info,
7579
bool& should_be_ignored)
7680
{
7781
static_cast<void>(participant);
82+
static_cast<void>(reason);
7883
static_cast<void>(info);
84+
7985
should_be_ignored = false;
8086
}
8187

0 commit comments

Comments
 (0)