Skip to content
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

[21295] Participant discovery structures refactor #5042

Merged
merged 23 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2845bb5
Refs #21295: changing the name of the callback from onParticipantDisc…
elianalf Jul 5, 2024
2abf514
Refs #21295: Change listener signature and DISCOVERY_STATUS to PARTIC…
elianalf Jul 5, 2024
250e4de
Refs #21295: Move PARTICIPANT_DISCOVERY_STATUS out of ParticipantDisc…
elianalf Jul 5, 2024
ecd6d07
Refs #21295: Substitute ParticipantDiscoveryInfo with ParticipantProx…
elianalf Jul 8, 2024
92af3ae
Refs #21295: Remove ParticiapntDiscoveryInfo
elianalf Jul 8, 2024
835e9fe
Refs #21295: Extend ParticipantBuiltinTopicData
elianalf Jul 8, 2024
8c94e64
Refs #21295: Create ParticipantBuiltinTopicData in rtps namespace
elianalf Jul 8, 2024
250fd1f
Refs #21295: Create from_proxy_to_builtin method for participant
elianalf Jul 8, 2024
3809fcc
Refs #21295: Substitute ParticipantProxyData with ParticipantBuiltinT…
elianalf Jul 9, 2024
2e58bd7
Refs #21295: Make ParticipantProxyData private
elianalf Jul 9, 2024
cb24187
Refs #21295: Update version.md
elianalf Jul 9, 2024
2f68fe4
Refs #21295: Uncrustify
elianalf Jul 9, 2024
3d0918e
Refs #21295: Fix compilation error after rebase
elianalf Jul 12, 2024
4047e7f
Refs #21295: Change name in camel case ParticipantDiscoveryStatus
elianalf Jul 16, 2024
a771a46
Refs #21295: Change signature of fill_discovery_data_from_cdr_message
elianalf Jul 16, 2024
29a9a64
Refs #21295: Apply changes to new example
elianalf Jul 17, 2024
270a979
Refs #21295: Apply suggestions
elianalf Jul 18, 2024
ca29ad0
Refs #21295: Apply suggestions
elianalf Jul 18, 2024
4355e4e
Refs #21295. Fix communication test build.
MiguelCompany Jul 19, 2024
b96554b
Refs #21295. Fix include order.
MiguelCompany Jul 19, 2024
890eca0
Refs #21295. Additional change on versions.md.
MiguelCompany Jul 19, 2024
2da7756
Refs #21295: Add missing guid conversion in the converter
elianalf Jul 23, 2024
2c4d7f5
Refs #21295: Adjust after rebase
elianalf Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions examples/cpp/discovery_server/ServerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,20 @@ ServerApp::~ServerApp()

void ServerApp::on_participant_discovery(
DomainParticipant*,
fastdds::rtps::ParticipantDiscoveryInfo&& info,
fastdds::rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored)
{
static_cast<void>(should_be_ignored);
if (info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT)
if (status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
{
std::cout << "Discovered Participant with GUID " << info.info.m_guid << std::endl;
std::cout << "Discovered Participant with GUID " << info.guid << std::endl;
++matched_;
}
else if (info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::DROPPED_PARTICIPANT ||
info.status == eprosima::fastdds::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT)
else if (status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT ||
status == eprosima::fastdds::rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT)
{
std::cout << "Dropped Participant with GUID " << info.info.m_guid << std::endl;
std::cout << "Dropped Participant with GUID " << info.guid << std::endl;
--matched_;
}
}
Expand Down
4 changes: 3 additions & 1 deletion examples/cpp/discovery_server/ServerApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <condition_variable>

#include <fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
Expand Down Expand Up @@ -49,7 +50,8 @@ class ServerApp : public Application, public DomainParticipantListener
//! Publisher matched method
void on_participant_discovery(
DomainParticipant* participant,
fastdds::rtps::ParticipantDiscoveryInfo&& info,
fastdds::rtps::ParticipantDiscoveryStatus status,
const fastdds::rtps::ParticipantBuiltinTopicData& info,
bool& should_be_ignored) override;

//! Run publisher
Expand Down
17 changes: 9 additions & 8 deletions examples/cpp/request_reply/ClientApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,18 @@ void ClientApp::stop()

void ClientApp::on_participant_discovery(
DomainParticipant* /* participant */,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored)
{
std::lock_guard<std::mutex> lock(mtx_);

should_be_ignored = false;

rtps::GuidPrefix_t remote_participant_guid_prefix = info.info.m_guid.guidPrefix;
std::string status_str = TypeConverter::to_string(info.status);
rtps::GuidPrefix_t remote_participant_guid_prefix = info.guid.guidPrefix;
std::string status_str = TypeConverter::to_string(status);

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

if (!should_be_ignored)
{
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.info.m_userData.data_vec()[0]);
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.user_data.data_vec()[0]);
if (CLIParser::EntityKind::SERVER != entity_kind)
{
should_be_ignored = true;
Expand All @@ -176,12 +177,12 @@ void ClientApp::on_participant_discovery(
{
std::string server_str = CLIParser::parse_entity_kind(CLIParser::EntityKind::SERVER);

if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT)
if (status == rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
{
request_reply_debug("ClientApp", server_str << " " << status_str << ": " << remote_participant_guid_prefix);
}
else if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT ||
info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT)
else if (status == rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT ||
status == rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT)
{
request_reply_debug("ClientApp", server_str << " " << status_str << ": " << remote_participant_guid_prefix);
}
Expand Down
3 changes: 2 additions & 1 deletion examples/cpp/request_reply/ClientApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class ClientApp : public Application, public DomainParticipantListener
//! Participant discovery method
void on_participant_discovery(
DomainParticipant* participant,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored) override;

//! Publication matched method
Expand Down
17 changes: 9 additions & 8 deletions examples/cpp/request_reply/ServerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,18 @@ void ServerApp::stop()

void ServerApp::on_participant_discovery(
DomainParticipant* /* participant */,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored)
{
std::lock_guard<std::mutex> lock(mtx_);

should_be_ignored = false;

rtps::GuidPrefix_t remote_participant_guid_prefix = info.info.m_guid.guidPrefix;
std::string status_str = TypeConverter::to_string(info.status);
rtps::GuidPrefix_t remote_participant_guid_prefix = info.guid.guidPrefix;
std::string status_str = TypeConverter::to_string(status);

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

if (!should_be_ignored)
{
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.info.m_userData.data_vec()[0]);
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.user_data.data_vec()[0]);
if (CLIParser::EntityKind::CLIENT != entity_kind)
{
should_be_ignored = true;
Expand All @@ -163,12 +164,12 @@ void ServerApp::on_participant_discovery(
{
std::string client_str = CLIParser::parse_entity_kind(CLIParser::EntityKind::CLIENT);

if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT)
if (status == rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
{
request_reply_debug("ServerApp", client_str << " " << status_str << ": " << remote_participant_guid_prefix);
}
else if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT ||
info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT)
else if (status == rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT ||
status == rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT)
{
client_matched_status_.match_reply_reader(remote_participant_guid_prefix, false);
client_matched_status_.match_request_writer(remote_participant_guid_prefix, false);
Expand Down
3 changes: 2 additions & 1 deletion examples/cpp/request_reply/ServerApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class ServerApp : public Application, public DomainParticipantListener
//! Participant discovery method
void on_participant_discovery(
DomainParticipant* participant,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored) override;

//! Publication matched method
Expand Down
12 changes: 6 additions & 6 deletions examples/cpp/request_reply/app_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,25 @@ struct TypeConverter
}

static std::string to_string(
const rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS& info)
const rtps::ParticipantDiscoveryStatus& info)
{
std::string info_str = "Unknown";

switch (info)
{
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT:
info_str = "discovered";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::CHANGED_QOS_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::CHANGED_QOS_PARTICIPANT:
info_str = "changed QoS";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT:
info_str = "removed";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT:
info_str = "dropped";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::IGNORED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::IGNORED_PARTICIPANT:
info_str = "ignored";
break;
default:
Expand Down
14 changes: 2 additions & 12 deletions include/fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,14 @@
#ifndef FASTDDS_DDS_BUILTIN_TOPIC__PARTICIPANTBUILTINTOPICDATA_HPP
#define FASTDDS_DDS_BUILTIN_TOPIC__PARTICIPANTBUILTINTOPICDATA_HPP

#include <fastdds/dds/builtin/topic/BuiltinTopicKey.hpp>
#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp>

namespace eprosima {
namespace fastdds {
namespace dds {
namespace builtin {

struct ParticipantBuiltinTopicData
{
//! Builtin topic Key
BuiltinTopicKey_t key;
using ParticipantBuiltinTopicData = rtps::ParticipantBuiltinTopicData;

//! UserData QoS
UserDataQosPolicy user_data;
};

} // builtin
} // dds
} // fastdds
} // eprosima
Expand Down
2 changes: 1 addition & 1 deletion include/fastdds/dds/domain/DomainParticipant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ class DomainParticipant : public Entity
* @warning Not supported yet. Currently returns RETCODE_UNSUPPORTED
*/
FASTDDS_EXPORTED_API ReturnCode_t get_discovered_participant_data(
builtin::ParticipantBuiltinTopicData& participant_data,
ParticipantBuiltinTopicData& participant_data,
const InstanceHandle_t& participant_handle) const;

/**
Expand Down
8 changes: 7 additions & 1 deletion include/fastdds/dds/domain/DomainParticipantListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <fastdds/dds/publisher/PublisherListener.hpp>
#include <fastdds/dds/subscriber/SubscriberListener.hpp>
#include <fastdds/dds/topic/TopicListener.hpp>
#include <fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp>
#include <fastdds/rtps/participant/ParticipantDiscoveryInfo.hpp>
#include <fastdds/rtps/reader/ReaderDiscoveryStatus.hpp>
#include <fastdds/rtps/writer/WriterDiscoveryStatus.hpp>
Expand All @@ -34,6 +35,7 @@ namespace fastdds {
namespace dds {

class DomainParticipant;
class ParticipantProxyData;

/**
* Class DomainParticipantListener, overrides behaviour towards certain events.
Expand Down Expand Up @@ -66,16 +68,20 @@ class DomainParticipantListener :
* its QOS or is removed.
*
* @param [out] participant Pointer to the Participant which discovered the remote participant.
* @param [out] reason Reason of the change in the status of the discovered participant.
* @param [out] info Remote participant information. User can take ownership of the object.
* @param [out] should_be_ignored Flag to indicate the library to automatically ignore the discovered Participant.
*/
virtual void on_participant_discovery(
DomainParticipant* participant,
rtps::ParticipantDiscoveryInfo&& info,
fastdds::rtps::ParticipantDiscoveryStatus reason,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored)
{
static_cast<void>(participant);
static_cast<void>(reason);
static_cast<void>(info);

should_be_ignored = false;
}

Expand Down
68 changes: 68 additions & 0 deletions include/fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file ParticipantBuiltinTopicData.hpp
*
*/

#ifndef FASTDDS_RTPS_BUILTIN_DATA__PARTICIPANTBUILTINTOPICDATA_HPP
#define FASTDDS_RTPS_BUILTIN_DATA__PARTICIPANTBUILTINTOPICDATA_HPP

#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/rtps/builtin/data/BuiltinTopicKey.hpp>
#include <fastdds/rtps/common/RemoteLocators.hpp>

namespace eprosima {
namespace fastdds {
namespace rtps {

struct ParticipantBuiltinTopicData
{
/// Builtin topic Key
BuiltinTopicKey_t key;

/// UserData QoS
dds::UserDataQosPolicy user_data;

/// Participant GUID
GUID_t guid;

/// Properties
dds::ParameterPropertyList_t properties;

/// Participant name
fastcdr::string_255 participant_name;

/// Metatraffic locators
RemoteLocatorList metatraffic_locators;

/// Default locators
RemoteLocatorList default_locators;

/// Lease Duration
dds::Duration_t lease_duration;

/// Vendor id
VendorId_t vendor_id;

/// Participant domain id
dds::DomainId_t domain_id;
};

} // rtps
} // fastdds
} // eprosima

#endif // FASTDDS_RTPS_BUILTIN_DATA__PARTICIPANTBUILTINTOPICDATA_HPP
Loading
Loading