Coverage Report

Created: 2026-07-25 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Fast-DDS/src/cpp/rtps/builtin/data/ParticipantProxyData.hpp
Line
Count
Source
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 ParticipantProxyData.hpp
17
 *
18
 */
19
20
#ifndef RTPS_BUILTIN_DATA__PARTICIPANTPROXYDATA_HPP
21
#define RTPS_BUILTIN_DATA__PARTICIPANTPROXYDATA_HPP
22
23
#include <chrono>
24
25
#include <fastdds/dds/core/policy/QosPolicies.hpp>
26
#include <fastdds/dds/core/Types.hpp>
27
#include <fastdds/rtps/attributes/ReaderAttributes.hpp>
28
#include <fastdds/rtps/attributes/RTPSParticipantAllocationAttributes.hpp>
29
#include <fastdds/rtps/attributes/WriterAttributes.hpp>
30
#include <fastdds/rtps/builtin/data/BuiltinEndpoints.hpp>
31
#include <fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp>
32
#include <fastdds/rtps/common/ProductVersion_t.hpp>
33
#include <fastdds/rtps/common/RemoteLocators.hpp>
34
#include <fastdds/rtps/common/Token.hpp>
35
#include <fastdds/rtps/common/VendorId_t.hpp>
36
37
#include <rtps/network/NetworkFactory.hpp>
38
39
namespace eprosima {
40
namespace fastdds {
41
namespace rtps {
42
43
struct CDRMessage_t;
44
class PDPSimple;
45
class TimedEvent;
46
class RTPSParticipantImpl;
47
class ReaderProxyData;
48
class WriterProxyData;
49
class NetworkFactory;
50
51
#if HAVE_SECURITY
52
namespace security {
53
struct ParticipantSecurityAttributes;
54
} // namespace security
55
#endif // if HAVE_SECURITY
56
57
// proxy specific declarations
58
template<class Proxy>
59
class ProxyHashTable;
60
61
/**
62
 * ParticipantProxyData class is used to store and convert the information Participants send to each other during the PDP phase.
63
 *@ingroup BUILTIN_MODULE
64
 */
65
class ParticipantProxyData : public ParticipantBuiltinTopicData
66
{
67
public:
68
69
    ParticipantProxyData(
70
            const RTPSParticipantAllocationAttributes& allocation);
71
72
    ParticipantProxyData(
73
            const ParticipantProxyData& pdata);
74
75
    virtual ~ParticipantProxyData();
76
77
    //!Protocol version
78
    ProtocolVersion_t m_protocol_version;
79
    //!Machine ID
80
    fastcdr::string_255 machine_id;
81
    //!Expects Inline QOS.
82
    bool m_expects_inline_qos;
83
    //!Available builtin endpoints
84
    BuiltinEndpointSet_t m_available_builtin_endpoints;
85
    //!Network configuration
86
    NetworkConfigSet_t m_network_configuration;
87
    //!Manual liveliness count
88
    Count_t m_manual_liveliness_count;
89
    //!
90
    InstanceHandle_t m_key;
91
#if HAVE_SECURITY
92
    //!
93
    IdentityToken identity_token_;
94
    //!
95
    PermissionsToken permissions_token_;
96
    //!
97
    security::ParticipantSecurityAttributesMask security_attributes_;
98
    //!
99
    security::PluginParticipantSecurityAttributesMask plugin_security_attributes_;
100
#endif // if HAVE_SECURITY
101
    //!
102
    bool is_alive;
103
    //!
104
    TimedEvent* lease_duration_event;
105
    //!
106
    bool should_check_lease_duration;
107
    //!
108
    ProxyHashTable<ReaderProxyData>* m_readers = nullptr;
109
    //!
110
    ProxyHashTable<WriterProxyData>* m_writers = nullptr;
111
112
    SampleIdentity m_sample_identity;
113
114
    /**
115
     * Update the data.
116
     * @param pdata Object to copy the data from
117
     * @return True on success
118
     */
119
    bool update_data(
120
            ParticipantProxyData& pdata);
121
122
    /**
123
     * Get the size in bytes of the CDR serialization of this object.
124
     * @param include_encapsulation Whether to include the size of the encapsulation info.
125
     * @param force_including_optional_qos Whether to force including of the optional Qos.
126
     * @return size in bytes of the CDR serialization.
127
     */
128
    uint32_t get_serialized_size(
129
            bool include_encapsulation,
130
            bool force_including_optional_qos = false) const;
131
132
    /**
133
     * Write as a parameter list on a CDRMessage_t
134
     * @param msg CDRMessage_t to write to
135
     * @param write_encapsulation Whether to write the encapsulation info.
136
     * @param force_write_optional_qos Whether to write the optional Qos.
137
     * @return True on success
138
     */
139
    bool write_to_cdr_message(
140
            CDRMessage_t* msg,
141
            bool write_encapsulation,
142
            bool force_write_optional_qos = false);
143
144
    /**
145
     * Read the parameter list from a received CDRMessage_t
146
     * @return True on success
147
     */
148
    bool read_from_cdr_message(
149
            CDRMessage_t* msg,
150
            bool use_encapsulation,
151
            NetworkFactory& network,
152
            bool should_filter_locators,
153
            fastdds::rtps::VendorId_t source_vendor_id = c_VendorId_eProsima);
154
155
    /**
156
     * Check if the host where the current process is running is the same as the one that sent the data.
157
     * It tries to use the machine_id. If it is not available, it will compare GUIDs.
158
     * @return True if the host is the same
159
     */
160
    bool is_from_this_host() const;
161
162
    //! Clear the data (restore to default state).
163
    void clear();
164
165
    /**
166
     * Copy the data from another object.
167
     * @param pdata Object to copy the data from
168
     */
169
    void copy(
170
            const ParticipantProxyData& pdata);
171
172
    /**
173
     * Set participant persistent GUID_t
174
     * @param guid valid GUID_t
175
     */
176
    void set_persistence_guid(
177
            const GUID_t& ps_guid);
178
179
    /**
180
     * Retrieve participant persistent GUID_t
181
     * @return guid persistent GUID_t or c_Guid_Unknown
182
     */
183
    GUID_t get_persistence_guid() const;
184
185
    /**
186
     * Set participant client server sample identity
187
     * @param sid valid SampleIdentity
188
     */
189
    void set_sample_identity(
190
            const SampleIdentity& sid);
191
192
    /**
193
     * Retrieve participant SampleIdentity
194
     * @return SampleIdentity
195
     */
196
    SampleIdentity get_sample_identity() const;
197
198
    /**
199
     * Identifies the participant as client of the given server
200
     * @param guid valid backup server GUID
201
     */
202
    void set_backup_stamp(
203
            const GUID_t& guid);
204
205
    /**
206
     * Retrieves BACKUP server stamp. On deserialization hints if lease duration must be enforced
207
     * @return GUID
208
     */
209
    GUID_t get_backup_stamp() const;
210
211
    void assert_liveliness();
212
213
    const std::chrono::steady_clock::time_point& last_received_message_tm() const
214
0
    {
215
0
        return last_received_message_tm_;
216
0
    }
217
218
    //! Getter for m_should_send_optional_qos.
219
    bool should_send_optional_qos() const
220
0
    {
221
0
        return m_should_send_optional_qos;
222
0
    }
223
224
    /**
225
     * Set whether optional QoS should be serialized and added to Data(p).
226
     * @param should_send_optional_qos Boolean indicating whether optional QoS should be serialized
227
     *                                 and added to Data(p).
228
     */
229
    void should_send_optional_qos(
230
            bool should_send_optional_qos)
231
0
    {
232
0
        m_should_send_optional_qos = should_send_optional_qos;
233
0
    }
234
235
private:
236
237
    //! Store the last timestamp it was received a RTPS message from the remote participant.
238
    std::chrono::steady_clock::time_point last_received_message_tm_;
239
240
    //! Remote participant lease duration in microseconds.
241
    std::chrono::microseconds lease_duration_;
242
243
    //!Whether optional QoS should be serialized and added to Data(p)
244
    bool m_should_send_optional_qos{false};
245
};
246
247
} // namespace rtps
248
} // namespace fastdds
249
} // namespace eprosima
250
251
#endif // RTPS_BUILTIN_DATA__PARTICIPANTPROXYDATA_HPP