Skip to content

Commit

Permalink
Refs #20181: Move direct_send() functions to utils
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
  • Loading branch information
Mario-DL committed Jul 16, 2024
1 parent 404d686 commit 55b7e1e
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 31 deletions.
30 changes: 2 additions & 28 deletions src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,25 @@

#include <rtps/builtin/BuiltinProtocols.h>
#include <rtps/builtin/discovery/endpoint/EDPClient.h>
#include <rtps/builtin/discovery/participant/DirectMessageSender.hpp>
#include <rtps/builtin/discovery/participant/DS/FakeWriter.hpp>
#include <rtps/builtin/discovery/participant/DS/PDPSecurityInitiatorListener.hpp>
#include <rtps/builtin/discovery/participant/PDPListener.h>
#include <rtps/builtin/discovery/participant/timedevent/DSClientEvent.h>
#include <rtps/builtin/liveliness/WLP.hpp>
#include <rtps/common/GuidUtils.hpp>
#include <rtps/participant/RTPSParticipantImpl.h>
#include <rtps/reader/BaseReader.hpp>
#include <rtps/reader/StatefulReader.hpp>
#include <rtps/writer/ReaderProxy.hpp>
#include <rtps/writer/StatefulWriter.hpp>
#include <utils/DirectSend.hpp>
#include <utils/shared_mutex.hpp>
#include <rtps/common/GuidUtils.hpp>
#include <utils/SystemInfo.hpp>
#include <utils/TimeConversion.hpp>

namespace eprosima {
namespace fastdds {
namespace rtps {

static void direct_send(
RTPSParticipantImpl* participant,
LocatorList& locators,
std::vector<GUID_t>& remote_readers,
CacheChange_t& change,
fastdds::rtps::Endpoint& sender_endpt)
{
DirectMessageSender sender(participant, &remote_readers, &locators);
RTPSMessageGroup group(participant, &sender_endpt, &sender);
if (!group.add_data(change, false))
{
EPROSIMA_LOG_ERROR(RTPS_PDP, "Error sending announcement from client to servers");
}
}

static void direct_send(
RTPSParticipantImpl* participant,
LocatorList& locators,
CacheChange_t& change)
{
FakeWriter writer(participant, c_EntityId_SPDPWriter);
std::vector<GUID_t> remote_readers;
direct_send(participant, locators, remote_readers, change, writer);
}

PDPClient::PDPClient(
BuiltinProtocols* builtin,
const RTPSParticipantAllocationAttributes& allocation,
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <mutex>
#include <set>

#include <fastdds/builtin/type_lookup_service/TypeLookupManager.hpp>
#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/rtps/history/History.hpp>
Expand All @@ -30,7 +31,6 @@
#include <fastdds/rtps/participant/RTPSParticipantListener.hpp>
#include <fastdds/utils/TimedMutex.hpp>

#include <fastdds/builtin/type_lookup_service/TypeLookupManager.hpp>
#include <rtps/builtin/BuiltinProtocols.h>
#include <rtps/builtin/discovery/database/backup/SharedBackupFunctions.hpp>
#include <rtps/builtin/discovery/endpoint/EDPServer.hpp>
Expand Down
6 changes: 4 additions & 2 deletions src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* @file PDPSimple.cpp
*
*/

#include <rtps/builtin/discovery/participant/PDPSimple.h>

#include <mutex>

#include <fastdds/builtin/type_lookup_service/TypeLookupManager.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/rtps/builtin/data/BuiltinEndpoints.hpp>
#include <fastdds/rtps/builtin/data/ParticipantProxyData.hpp>
Expand All @@ -28,9 +30,8 @@
#include <fastdds/rtps/history/ReaderHistory.hpp>
#include <fastdds/rtps/history/WriterHistory.hpp>
#include <fastdds/rtps/participant/RTPSParticipantListener.hpp>

#include <fastdds/builtin/type_lookup_service/TypeLookupManager.hpp>
#include <fastdds/utils/IPLocator.hpp>

#include <rtps/builtin/BuiltinProtocols.h>
#include <rtps/builtin/data/NetworkConfiguration.hpp>
#include <rtps/builtin/discovery/endpoint/EDPSimple.h>
Expand All @@ -46,6 +47,7 @@
#include <rtps/reader/StatelessReader.hpp>
#include <rtps/resources/TimedEvent.h>
#include <rtps/writer/StatelessWriter.hpp>
#include <utils/DirectSend.hpp>

namespace eprosima {
namespace fastdds {
Expand Down
66 changes: 66 additions & 0 deletions src/cpp/utils/DirectSend.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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.


#ifndef UTILS__DIRECTSEND_HPP
#define UTILS__DIRECTSEND_HPP

#include <fastdds/rtps/common/Guid.hpp>
#include <fastdds/rtps/common/LocatorList.hpp>
#include <fastdds/rtps/Endpoint.hpp>

#include <rtps/builtin/discovery/participant/DirectMessageSender.hpp>
#include <rtps/builtin/discovery/participant/FakeWriter.hpp>
#include <rtps/messages/RTPSMessageGroup.hpp>


namespace eprosima {
namespace fastdds {
namespace rtps {

class Endpoint;
class RTPSParticipantImpl;
struct CacheChange_t;


inline void direct_send(
RTPSParticipantImpl* participant,
LocatorList& locators,
std::vector<GUID_t>& remote_readers,
CacheChange_t& change,
fastdds::rtps::Endpoint& sender_endpt)
{
DirectMessageSender sender(participant, &remote_readers, &locators);
RTPSMessageGroup group(participant, &sender_endpt, &sender);
if (!group.add_data(change, false))
{
EPROSIMA_LOG_ERROR(RTPS_PDP, "Error sending announcement from client to servers");
}
}

inline void direct_send(
RTPSParticipantImpl* participant,
LocatorList& locators,
CacheChange_t& change)
{
FakeWriter writer(participant, c_EntityId_SPDPWriter);
std::vector<GUID_t> remote_readers;
direct_send(participant, locators, remote_readers, change, writer);
}

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

#endif // UTILS__DIRECTSEND_HPP

0 comments on commit 55b7e1e

Please sign in to comment.