Coverage Report

Created: 2026-02-14 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Fast-DDS/include/fastdds/rtps/common/WriteParams.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 WriteParams.hpp
17
 */
18
#ifndef FASTDDS_RTPS_COMMON__WRITEPARAMS_HPP
19
#define FASTDDS_RTPS_COMMON__WRITEPARAMS_HPP
20
21
#include <memory>
22
23
#include <fastdds/rtps/common/OriginalWriterInfo.hpp>
24
#include <fastdds/rtps/common/SampleIdentity.hpp>
25
#include <fastdds/rtps/common/Time_t.hpp>
26
27
namespace eprosima {
28
namespace fastdds {
29
namespace rtps {
30
31
/*!
32
 * @brief This class contains additional information of a CacheChange.
33
 *
34
 * @ingroup COMMON_MODULE
35
 */
36
class FASTDDS_EXPORTED_API WriteParams
37
{
38
public:
39
40
    /**
41
     * @brief Base class storing custom information in the
42
     * WriteParams structure for later filtering.
43
     *
44
     * This struct serves as a base class that allows derived
45
     * classes to be deleted safely through a pointer to this base type.
46
     * It is intended to be user-extensible.
47
     */
48
    struct FASTDDS_EXPORTED_API UserWriteData
49
    {
50
        UserWriteData() = default;
51
52
        virtual ~UserWriteData() = default;
53
    };
54
55
    /**
56
     * Set the value of the sample_identity member.
57
     *
58
     * @param sample_id  New value for the sample_identity member.
59
     *
60
     * @return Reference to the modified object in order to allow daisy chaining.
61
     */
62
    WriteParams& sample_identity(
63
            const SampleIdentity& sample_id)
64
0
    {
65
0
        sample_identity_ = sample_id;
66
0
        return *this;
67
0
    }
68
69
    /**
70
     * Set the value of the sample_identity member.
71
     *
72
     * @param sample_id  New value for the sample_identity member.
73
     *
74
     * @return Reference to the modified object in order to allow daisy chaining.
75
     */
76
    WriteParams& sample_identity(
77
            SampleIdentity&& sample_id)
78
0
    {
79
0
        sample_identity_ = std::move(sample_id);
80
0
        return *this;
81
0
    }
82
83
    /**
84
     * Get the value of the sample_identity member.
85
     *
86
     * @return Constant reference to the sample_identity member.
87
     */
88
    const SampleIdentity& sample_identity() const
89
0
    {
90
0
        return sample_identity_;
91
0
    }
92
93
    /**
94
     * Set the value of the sample_identity member.
95
     *
96
     * @return Reference to the sample_identity member.
97
     */
98
    SampleIdentity& sample_identity()
99
0
    {
100
0
        return sample_identity_;
101
0
    }
102
103
    /**
104
     * Set the value of the related_sample_identity member of this class.
105
     *
106
     * @param sample_id  New value for the related_sample_identity member.
107
     *
108
     * @return Reference to the modified object in order to allow daisy chaining.
109
     */
110
    WriteParams& related_sample_identity(
111
            const SampleIdentity& sample_id)
112
0
    {
113
0
        related_sample_identity_ = sample_id;
114
0
        return *this;
115
0
    }
116
117
    /**
118
     * Set the related_sample_identity member of this class.
119
     *
120
     * @param sample_id  New value for the related_sample_identity member.
121
     *
122
     * @return Reference to the modified object in order to allow daisy chaining.
123
     */
124
    WriteParams& related_sample_identity(
125
            SampleIdentity&& sample_id)
126
0
    {
127
0
        related_sample_identity_ = std::move(sample_id);
128
0
        return *this;
129
0
    }
130
131
    /**
132
     * Get the value of the related_sample_identity member.
133
     *
134
     * @return Constant reference to the related_sample_identity member.
135
     */
136
    const SampleIdentity& related_sample_identity() const
137
0
    {
138
0
        return related_sample_identity_;
139
0
    }
140
141
    /**
142
     * Set the value of the related_sample_identity member.
143
     *
144
     * @return Reference to the related_sample_identity member.
145
     */
146
    SampleIdentity& related_sample_identity()
147
0
    {
148
0
        return related_sample_identity_;
149
0
    }
150
151
    /**
152
     * Get the value of the source_timestamp member.
153
     *
154
     * @return Current value of the source_timestamp member.
155
     */
156
    Time_t source_timestamp() const
157
0
    {
158
0
        return source_timestamp_;
159
0
    }
160
161
    /**
162
     * Set the value of the source_timestamp member.
163
     *
164
     * @return Reference to the source_timestamp member.
165
     */
166
    Time_t& source_timestamp()
167
0
    {
168
0
        return source_timestamp_;
169
0
    }
170
171
    /**
172
     * Set the source_timestamp member of this class.
173
     *
174
     * @param timestamp  New value for the source_timestamp member.
175
     *
176
     * @return Reference to the modified object in order to allow daisy chaining.
177
     */
178
    WriteParams& source_timestamp(
179
            const Time_t& timestamp)
180
0
    {
181
0
        source_timestamp_ = timestamp;
182
0
        return *this;
183
0
    }
184
185
    /**
186
     * Set the source_timestamp member of this class.
187
     *
188
     * @param timestamp  New value for the source_timestamp member.
189
     *
190
     * @return Reference to the modified object in order to allow daisy chaining.
191
     */
192
    WriteParams& source_timestamp(
193
            Time_t&& timestamp)
194
0
    {
195
0
        source_timestamp_ = std::move(timestamp);
196
0
        return *this;
197
0
    }
198
199
    /**
200
     * @brief Retrieves the user write data.
201
     *
202
     * @return Shared pointer to the user write data.
203
     */
204
    std::shared_ptr<UserWriteData> user_write_data() const
205
0
    {
206
0
        return user_write_data_;
207
0
    }
208
209
    /**
210
     * Set the user write data.
211
     *
212
     * @param write_data  New value for the user_write_data member.
213
     *
214
     * @return Reference to the modified object in order to allow daisy chaining.
215
     */
216
    WriteParams& user_write_data(
217
            std::shared_ptr<UserWriteData> write_data)
218
0
    {
219
0
        user_write_data_ = write_data;
220
0
        return *this;
221
0
    }
222
223
    bool has_more_replies() const
224
0
    {
225
0
        return has_more_replies_;
226
0
    }
227
228
    WriteParams& has_more_replies(
229
            bool more_replies)
230
0
    {
231
0
        has_more_replies_ = more_replies;
232
0
        return *this;
233
0
    }
234
235
    /*!
236
     * @brief Get the Original Writer Info.
237
     * @return Constant reference to the original_writer_info_ member.
238
     */
239
    const OriginalWriterInfo& original_writer_info() const
240
0
    {
241
0
        return original_writer_info_;
242
0
    }
243
244
    /*!
245
     * @brief Get the Original Writer Info.
246
     * @return Constant reference to the original_writer_info_ member.
247
     */
248
    OriginalWriterInfo& original_writer_info()
249
0
    {
250
0
        return original_writer_info_;
251
0
    }
252
253
    /*!
254
     * @brief Set the Original Writer Info of the original writer.
255
     *
256
     * @param original_writer  New value for the original_writer_info_ member.
257
     *
258
     * @return Reference to the modified object in order to allow daisy chaining.
259
     */
260
    WriteParams& original_writer_info(
261
            const OriginalWriterInfo& original_writer)
262
0
    {
263
0
        original_writer_info_ = original_writer;
264
0
        return *this;
265
0
    }
266
267
    static WriteParams WRITE_PARAM_DEFAULT;
268
269
    /**
270
     * Default value for methods receiving a WriteParams.
271
     *
272
     * Will contain the following values on its members:
273
     * - sample_identity: Invalid SampleIdentity
274
     * - related_sample_identity: Invalid SampleIdentity
275
     * - source_timestamp: Invalid Time_t
276
     *
277
     * @note This should not return a reference to the static value if this value is meant to be
278
     * read and written from different threads.
279
     */
280
    static WriteParams write_params_default() noexcept
281
0
    {
282
0
        return WriteParams();
283
0
    }
284
285
private:
286
287
    class FASTDDS_EXPORTED_API UserWriteDataPtr : public std::shared_ptr<UserWriteData>
288
    {
289
    public:
290
291
        UserWriteDataPtr(
292
                std::shared_ptr<UserWriteData> ptr)
293
4
            : std::shared_ptr<UserWriteData>(ptr)
294
4
        {
295
4
        }
296
297
    };
298
299
    /// Attribute that holds sample_identity member value
300
    SampleIdentity sample_identity_;
301
    /// Attribute that holds related_sample_identity member value
302
    SampleIdentity related_sample_identity_;
303
    /// Attribute that holds source_timestamp member value
304
    Time_t source_timestamp_{ -1, TIME_T_INFINITE_NANOSECONDS };
305
    /// User write data
306
    UserWriteDataPtr user_write_data_{nullptr};
307
    /// Flag to indicate if there are more replies
308
    bool has_more_replies_ = false;
309
    /// Attribute that holds the GUID of the original writer
310
    OriginalWriterInfo original_writer_info_;
311
};
312
313
}  // namespace rtps
314
}  // namespace fastdds
315
}  // namespace eprosima
316
317
#endif //FASTDDS_RTPS_COMMON__WRITEPARAMS_HPP