Coverage Report

Created: 2022-08-24 06:18

/src/Fast-DDS/include/fastdds/rtps/Endpoint.h
Line
Count
Source (jump to first uncovered line)
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
15
/**
16
 * @file Endpoint.h
17
 */
18
19
#ifndef _FASTDDS_RTPS_ENDPOINT_H_
20
#define _FASTDDS_RTPS_ENDPOINT_H_
21
22
#include <fastdds/rtps/attributes/EndpointAttributes.h>
23
24
#include <fastdds/rtps/common/Guid.h>
25
#include <fastdds/rtps/common/Locator.h>
26
#include <fastdds/rtps/common/Types.h>
27
28
#include <fastdds/rtps/history/IChangePool.h>
29
#include <fastdds/rtps/history/IPayloadPool.h>
30
31
#include <fastrtps/utils/TimedMutex.hpp>
32
33
namespace eprosima {
34
namespace fastrtps {
35
namespace rtps {
36
37
class RTPSParticipantImpl;
38
class ResourceEvent;
39
40
41
/**
42
 * Class Endpoint, all entities of the RTPS network derive from this class.
43
 * Although the RTPSParticipant is also defined as an endpoint in the RTPS specification, in this implementation
44
 * the RTPSParticipant class **does not** inherit from the endpoint class. Each Endpoint object owns a pointer to the
45
 * RTPSParticipant it belongs to.
46
 * @ingroup COMMON_MODULE
47
 */
48
class Endpoint
49
{
50
    friend class RTPSParticipantImpl;
51
52
protected:
53
54
    Endpoint() = default;
55
56
    Endpoint(
57
            RTPSParticipantImpl* pimpl,
58
            const GUID_t& guid,
59
            const EndpointAttributes& att)
60
        : mp_RTPSParticipant(pimpl)
61
        , m_guid(guid)
62
        , m_att(att)
63
0
    {
64
0
    }
65
66
    virtual ~Endpoint()
67
0
    {
68
        // As releasing the change pool will delete the cache changes it owns,
69
        // the payload pool may be called to release their payloads, so we should
70
        // ensure that the payload pool is destroyed after the change pool.
71
0
        change_pool_.reset();
72
0
        payload_pool_.reset();
73
0
    }
74
75
public:
76
77
    /**
78
     * Get associated GUID
79
     * @return Associated GUID
80
     */
81
    RTPS_DllAPI inline const GUID_t& getGuid() const
82
0
    {
83
0
        return m_guid;
84
0
    }
85
86
    /**
87
     * Get mutex
88
     * @return Associated Mutex
89
     */
90
    RTPS_DllAPI inline RecursiveTimedMutex& getMutex()
91
0
    {
92
0
        return mp_mutex;
93
0
    }
94
95
    /**
96
     * Get associated attributes
97
     * @return Endpoint attributes
98
     */
99
    RTPS_DllAPI inline EndpointAttributes& getAttributes()
100
0
    {
101
0
        return m_att;
102
0
    }
103
104
#if HAVE_SECURITY
105
    bool supports_rtps_protection()
106
    {
107
        return supports_rtps_protection_;
108
    }
109
110
#endif // if HAVE_SECURITY
111
112
protected:
113
114
    //!Pointer to the RTPSParticipant containing this endpoint.
115
    RTPSParticipantImpl* mp_RTPSParticipant;
116
117
    //!Endpoint GUID
118
    const GUID_t m_guid;
119
120
    //!Endpoint Attributes
121
    EndpointAttributes m_att;
122
123
    //!Endpoint Mutex
124
    mutable RecursiveTimedMutex mp_mutex;
125
126
    //!Pool of serialized payloads.
127
    std::shared_ptr<IPayloadPool> payload_pool_;
128
129
    //!Pool of cache changes.
130
    std::shared_ptr<IChangePool> change_pool_;
131
132
    //!Fixed size of payloads
133
    uint32_t fixed_payload_size_ = 0;
134
135
private:
136
137
    Endpoint& operator =(
138
            const Endpoint&) = delete;
139
140
#if HAVE_SECURITY
141
    bool supports_rtps_protection_ = true;
142
#endif // if HAVE_SECURITY
143
};
144
145
146
} // namespace rtps
147
} /* namespace rtps */
148
} /* namespace eprosima */
149
150
#endif //_FASTDDS_RTPS_ENDPOINT_H_