Fast DDS  Version 3.6.1.0
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
19
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
54 FASTDDS_DEPRECATED_UNTIL(4, send, "Use send with transport_priority instead")
55 bool send(
56 const std::vector<NetworkBuffer>& buffers,
57 const uint32_t& total_bytes,
58 LocatorsIterator* destination_locators_begin,
59 LocatorsIterator* destination_locators_end,
60 const std::chrono::steady_clock::time_point& max_blocking_time_point)
61 {
62 return send(buffers, total_bytes, destination_locators_begin, destination_locators_end,
63 max_blocking_time_point, 0);
64 }
65
77 bool send(
78 const std::vector<NetworkBuffer>& buffers,
79 const uint32_t& total_bytes,
80 LocatorsIterator* destination_locators_begin,
81 LocatorsIterator* destination_locators_end,
82 const std::chrono::steady_clock::time_point& max_blocking_time_point,
83 int32_t transport_priority)
84 {
85 if (send_lambda_)
86 {
87 return send_lambda_(buffers, total_bytes, destination_locators_begin, destination_locators_end,
88 max_blocking_time_point, transport_priority);
89 }
90 return send_buffers_lambda_(buffers, total_bytes, destination_locators_begin, destination_locators_end,
91 max_blocking_time_point);
92 }
93
99 SenderResource&& rValueResource) = default;
100
101 virtual ~SenderResource() = default;
102
103 int32_t kind() const
104 {
105 return transport_kind_;
106 }
107
114 LocatorList_t& locators) const
115 {
116 (void)locators;
117 }
118
119protected:
120
122 int32_t transport_kind)
123 : transport_kind_(transport_kind)
124 {
125 }
126
128
129 std::function<void()> clean_up;
130
131 std::function<bool(
132 const std::vector<NetworkBuffer>&,
133 uint32_t,
134 LocatorsIterator* destination_locators_begin,
135 LocatorsIterator* destination_locators_end,
136 const std::chrono::steady_clock::time_point&)> send_buffers_lambda_;
137
138 std::function<bool(
139 const std::vector<NetworkBuffer>&,
140 uint32_t,
141 LocatorsIterator* destination_locators_begin,
142 LocatorsIterator* destination_locators_end,
143 const std::chrono::steady_clock::time_point&,
144 int32_t transport_priority)> send_lambda_;
145
146private:
147
148 SenderResource() = delete;
150 const SenderResource&) = delete;
151 SenderResource& operator =(
152 const SenderResource&) = delete;
153};
154
155} // namespace rtps
156} // namespace fastdds
157} // namespace eprosima
158
159#endif // FASTDDS_RTPS_TRANSPORT__SENDERRESOURCE_HPP
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, int32_t transport_priority)
Sends to a destination locator, through the channel managed by this resource.
Definition SenderResource.hpp:77
eprosima::fastdds::rtps::NetworkBuffer NetworkBuffer
Definition SenderResource.hpp:52
std::function< bool(const std::vector< NetworkBuffer > &, uint32_t, LocatorsIterator *destination_locators_begin, LocatorsIterator *destination_locators_end, const std::chrono::steady_clock::time_point &, int32_t transport_priority)> send_lambda_
Definition SenderResource.hpp:144
int32_t transport_kind_
Definition SenderResource.hpp:127
SenderResource(SenderResource &&rValueResource)=default
Resources can only be transfered through move semantics.
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:136
int32_t kind() const
Definition SenderResource.hpp:103
SenderResource(int32_t transport_kind)
Definition SenderResource.hpp:121
std::function< void()> clean_up
Definition SenderResource.hpp:129
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)
Definition SenderResource.hpp:55
virtual void add_locators_to_list(LocatorList_t &locators) const
Add locators representing the local endpoints managed by this sender resource.
Definition SenderResource.hpp:113
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::LocatorList LocatorList_t
Definition LocatorList.hpp:478
eProsima namespace.
Definition EntityId_t.hpp:388
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