Fast DDS  Version 3.1.2
Fast DDS
Loading...
Searching...
No Matches
SenderResource.hpp
1// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
20#ifndef FASTDDS_RTPS_TRANSPORT__SENDERRESOURCE_HPP
21#define FASTDDS_RTPS_TRANSPORT__SENDERRESOURCE_HPP
22
23#include <fastdds/rtps/common/Types.hpp>
24
25#include <functional>
26#include <vector>
27#include <list>
28#include <chrono>
29
30#include <fastdds/rtps/common/LocatorList.hpp>
31#include <fastdds/rtps/common/LocatorsIterator.hpp>
32#include <fastdds/rtps/transport/NetworkBuffer.hpp>
33
34namespace eprosima {
35namespace fastdds {
36namespace rtps {
37
38class RTPSParticipantImpl;
39class MessageReceiver;
40
49{
50public:
51
53
64 bool send(
65 const std::vector<NetworkBuffer>& buffers,
66 const uint32_t& total_bytes,
67 LocatorsIterator* destination_locators_begin,
68 LocatorsIterator* destination_locators_end,
69 const std::chrono::steady_clock::time_point& max_blocking_time_point)
70 {
71 return send_buffers_lambda_(buffers, total_bytes, destination_locators_begin, destination_locators_end,
72 max_blocking_time_point);
73 }
74
80 SenderResource&& rValueResource)
81 {
82 clean_up.swap(rValueResource.clean_up);
83 send_buffers_lambda_.swap(rValueResource.send_buffers_lambda_);
84 }
85
86 virtual ~SenderResource() = default;
87
88 int32_t kind() const
89 {
90 return transport_kind_;
91 }
92
99 LocatorList_t& locators) const
100 {
101 (void)locators;
102 }
103
104protected:
105
107 int32_t transport_kind)
108 : transport_kind_(transport_kind)
109 {
110 }
111
113
114 std::function<void()> clean_up;
115
116 std::function<bool(
117 const std::vector<NetworkBuffer>&,
118 uint32_t,
119 LocatorsIterator* destination_locators_begin,
120 LocatorsIterator* destination_locators_end,
121 const std::chrono::steady_clock::time_point&)> send_buffers_lambda_;
122
123private:
124
125 SenderResource() = delete;
127 const SenderResource&) = delete;
128 SenderResource& operator =(
129 const SenderResource&) = delete;
130};
131
132} // namespace rtps
133} // namespace fastdds
134} // namespace eprosima
135
136#endif // FASTDDS_RTPS_TRANSPORT__SENDERRESOURCE_HPP
Class LocatorList, a Locator vector that doesn't allow duplicates.
Definition LocatorList.hpp:97
RAII object that encapsulates the Send operation over one chanel in an unknown transport.
Definition SenderResource.hpp:49
int32_t transport_kind_
Definition SenderResource.hpp:112
std::function< bool(const std::vector< NetworkBuffer > &, uint32_t, LocatorsIterator *destination_locators_begin, LocatorsIterator *destination_locators_end, const std::chrono::steady_clock::time_point &)> send_buffers_lambda_
Definition SenderResource.hpp:121
int32_t kind() const
Definition SenderResource.hpp:88
SenderResource(SenderResource &&rValueResource)
Resources can only be transfered through move semantics.
Definition SenderResource.hpp:79
SenderResource(int32_t transport_kind)
Definition SenderResource.hpp:106
std::function< void()> clean_up
Definition SenderResource.hpp:114
bool send(const std::vector< NetworkBuffer > &buffers, const uint32_t &total_bytes, LocatorsIterator *destination_locators_begin, LocatorsIterator *destination_locators_end, const std::chrono::steady_clock::time_point &max_blocking_time_point)
Sends to a destination locator, through the channel managed by this resource.
Definition SenderResource.hpp:64
virtual void add_locators_to_list(LocatorList_t &locators) const
Add locators representing the local endpoints managed by this sender resource.
Definition SenderResource.hpp:98
eProsima namespace.
Provides a Locator's iterator interface that can be used by different Locator's containers.
Definition LocatorsIterator.hpp:33
A slice of data to be sent to one or more transports.
Definition NetworkBuffer.hpp:38