| Fast DDS Version 3.3.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
34 namespace eprosima {
35 namespace fastdds {
36 namespace rtps {
37
38 class RTPSParticipantImpl;
39 class MessageReceiver;
40
48 class SenderResource
49{
50 public:
51
52 using NetworkBuffer = eprosima::fastdds::rtps::NetworkBuffer;
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
79 SenderResource(
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
98 virtual void add_locators_to_list(
99 LocatorList_t& locators) const
100 {
101 (void)locators;
102 }
103
104 protected:
105
106 SenderResource(
107 int32_t transport_kind)
108 : transport_kind_(transport_kind)
109 {
110 }
111
112 int32_t transport_kind_;
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
123 private:
124
125 SenderResource() = delete;
126 SenderResource(
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
eprosima::fastdds::rtps::SenderResource::NetworkBuffer
eprosima::fastdds::rtps::NetworkBuffer NetworkBuffer
Definition SenderResource.hpp:52
eprosima::fastdds::rtps::SenderResource::transport_kind_
int32_t transport_kind_
Definition SenderResource.hpp:112
eprosima::fastdds::rtps::SenderResource::~SenderResource
virtual ~SenderResource()=default
eprosima::fastdds::rtps::SenderResource::send_buffers_lambda_
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
eprosima::fastdds::rtps::SenderResource::kind
int32_t kind() const
Definition SenderResource.hpp:88
eprosima::fastdds::rtps::SenderResource::SenderResource
SenderResource(SenderResource &&rValueResource)
Resources can only be transfered through move semantics.
Definition SenderResource.hpp:79
eprosima::fastdds::rtps::SenderResource::SenderResource
SenderResource(int32_t transport_kind)
Definition SenderResource.hpp:106
eprosima::fastdds::rtps::SenderResource::clean_up
std::function< void()> clean_up
Definition SenderResource.hpp:114
eprosima::fastdds::rtps::SenderResource::send
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
eprosima::fastdds::rtps::SenderResource::add_locators_to_list
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::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::LocatorList_t
eprosima::fastdds::rtps::LocatorList LocatorList_t
Definition LocatorList.hpp:478
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::LocatorsIterator
Provides a Locator's iterator interface that can be used by different Locator's containers.
Definition LocatorsIterator.hpp:33
eprosima::fastdds::rtps::NetworkBuffer
A slice of data to be sent to one or more transports.
Definition NetworkBuffer.hpp:38