Coverage Report

Created: 2026-04-01 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Fast-DDS/src/cpp/rtps/transport/ChainingSenderResource.hpp
Line
Count
Source
1
// Copyright 2021 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
15
#ifndef _RTPS_TRANSPORT_CHAININGSENDERRESOURCE_HPP_
16
#define _RTPS_TRANSPORT_CHAININGSENDERRESOURCE_HPP_
17
18
#include <fastdds/rtps/transport/ChainingTransport.hpp>
19
#include <fastdds/rtps/transport/SenderResource.hpp>
20
21
namespace eprosima {
22
namespace fastdds {
23
namespace rtps {
24
25
class ChainingSenderResource : public SenderResource
26
{
27
public:
28
29
    ChainingSenderResource(
30
            ChainingTransport& transport,
31
            std::unique_ptr<SenderResource>& low_sender_resource)
32
        : SenderResource(transport.kind())
33
        , low_sender_resource_(std::move(low_sender_resource))
34
0
    {
35
0
        // Implementation functions are bound to the right transport parameters
36
0
        clean_up = []()
37
0
                {
38
0
                    // No cleanup is required.
39
0
                    // low_sender_resources_ makes its clean up on destruction.
40
0
                };
41
0
42
0
        send_lambda_ = [this, &transport](
43
0
            const std::vector<NetworkBuffer>& buffers,
44
0
            uint32_t total_bytes,
45
0
            LocatorsIterator* destination_locators_begin,
46
0
            LocatorsIterator* destination_locators_end,
47
0
            const std::chrono::steady_clock::time_point& timeout,
48
0
            int32_t transport_priority) -> bool
49
0
                {
50
0
                    if (low_sender_resource_)
51
0
                    {
52
0
                        return transport.send_w_priority(low_sender_resource_.get(), buffers, total_bytes,
53
0
                                       destination_locators_begin, destination_locators_end, timeout,
54
0
                                       transport_priority);
55
0
                    }
56
0
57
0
                    return false;
58
0
                };
59
0
    }
60
61
    SenderResource* lower_sender_cast()
62
0
    {
63
0
        SenderResource* lower_sender_cast = nullptr;
64
65
0
        if (low_sender_resource_)
66
0
        {
67
0
            lower_sender_cast = static_cast<SenderResource*>(low_sender_resource_.get());
68
0
        }
69
70
0
        return lower_sender_cast;
71
0
    }
72
73
    virtual ~ChainingSenderResource()
74
0
    {
75
0
        if (clean_up)
76
0
        {
77
0
            clean_up();
78
0
        }
79
0
    }
80
81
private:
82
83
    ChainingSenderResource() = delete;
84
85
    ChainingSenderResource(
86
            const SenderResource&) = delete;
87
88
    ChainingSenderResource& operator =(
89
            const SenderResource&) = delete;
90
91
    std::unique_ptr<SenderResource> low_sender_resource_;
92
};
93
94
} // namespace rtps
95
} // namespace fastdds
96
} // namespace eprosima
97
98
#endif // _RTPS_TRANSPORT_CHAININGSENDERRESOURCE_HPP_