-
Notifications
You must be signed in to change notification settings - Fork 940
Expand file tree
/
Copy pathWriteParams.hpp
More file actions
268 lines (238 loc) · 7.13 KB
/
Copy pathWriteParams.hpp
File metadata and controls
268 lines (238 loc) · 7.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file WriteParams.hpp
*/
#ifndef FASTDDS_RTPS_COMMON__WRITEPARAMS_HPP
#define FASTDDS_RTPS_COMMON__WRITEPARAMS_HPP
#include <memory>
#include <fastdds/rtps/common/SampleIdentity.hpp>
#include <fastdds/rtps/common/Time_t.hpp>
namespace eprosima {
namespace fastdds {
namespace rtps {
/*!
* @brief This class contains additional information of a CacheChange.
*
* @ingroup COMMON_MODULE
*/
class FASTDDS_EXPORTED_API WriteParams
{
public:
/**
* @brief Base class storing custom information in the
* WriteParams structure for later filtering.
*
* This struct serves as a base class that allows derived
* classes to be deleted safely through a pointer to this base type.
* It is intended to be user-extensible.
*/
struct FASTDDS_EXPORTED_API UserWriteData
{
UserWriteData() = default;
virtual ~UserWriteData() = default;
};
/**
* Set the value of the sample_identity member.
*
* @param sample_id New value for the sample_identity member.
*
* @return Reference to the modified object in order to allow daisy chaining.
*/
WriteParams& sample_identity(
const SampleIdentity& sample_id)
{
sample_identity_ = sample_id;
return *this;
}
/**
* Set the value of the sample_identity member.
*
* @param sample_id New value for the sample_identity member.
*
* @return Reference to the modified object in order to allow daisy chaining.
*/
WriteParams& sample_identity(
SampleIdentity&& sample_id)
{
sample_identity_ = std::move(sample_id);
return *this;
}
/**
* Get the value of the sample_identity member.
*
* @return Constant reference to the sample_identity member.
*/
const SampleIdentity& sample_identity() const
{
return sample_identity_;
}
/**
* Set the value of the sample_identity member.
*
* @return Reference to the sample_identity member.
*/
SampleIdentity& sample_identity()
{
return sample_identity_;
}
/**
* Set the value of the related_sample_identity member of this class.
*
* @param sample_id New value for the related_sample_identity member.
*
* @return Reference to the modified object in order to allow daisy chaining.
*/
WriteParams& related_sample_identity(
const SampleIdentity& sample_id)
{
related_sample_identity_ = sample_id;
return *this;
}
/**
* Set the related_sample_identity member of this class.
*
* @param sample_id New value for the related_sample_identity member.
*
* @return Reference to the modified object in order to allow daisy chaining.
*/
WriteParams& related_sample_identity(
SampleIdentity&& sample_id)
{
related_sample_identity_ = std::move(sample_id);
return *this;
}
/**
* Get the value of the related_sample_identity member.
*
* @return Constant reference to the related_sample_identity member.
*/
const SampleIdentity& related_sample_identity() const
{
return related_sample_identity_;
}
/**
* Set the value of the related_sample_identity member.
*
* @return Reference to the related_sample_identity member.
*/
SampleIdentity& related_sample_identity()
{
return related_sample_identity_;
}
/**
* Get the value of the source_timestamp member.
*
* @return Current value of the source_timestamp member.
*/
Time_t source_timestamp() const
{
return source_timestamp_;
}
/**
* Set the value of the source_timestamp member.
*
* @return Reference to the source_timestamp member.
*/
Time_t& source_timestamp()
{
return source_timestamp_;
}
/**
* Set the source_timestamp member of this class.
*
* @param timestamp New value for the source_timestamp member.
*
* @return Reference to the modified object in order to allow daisy chaining.
*/
WriteParams& source_timestamp(
const Time_t& timestamp)
{
source_timestamp_ = timestamp;
return *this;
}
/**
* Set the source_timestamp member of this class.
*
* @param timestamp New value for the source_timestamp member.
*
* @return Reference to the modified object in order to allow daisy chaining.
*/
WriteParams& source_timestamp(
Time_t&& timestamp)
{
source_timestamp_ = std::move(timestamp);
return *this;
}
/**
* @brief Retrieves the user write data.
*
* @return Shared pointer to the user write data.
*/
std::shared_ptr<UserWriteData> user_write_data() const
{
return user_write_data_;
}
/**
* Set the user write data.
*
* @param write_data New value for the user_write_data member.
*
* @return Reference to the modified object in order to allow daisy chaining.
*/
WriteParams& user_write_data(
std::shared_ptr<UserWriteData> write_data)
{
user_write_data_ = write_data;
return *this;
}
static WriteParams WRITE_PARAM_DEFAULT;
/**
* Default value for methods receiving a WriteParams.
*
* Will contain the following values on its members:
* - sample_identity: Invalid SampleIdentity
* - related_sample_identity: Invalid SampleIdentity
* - source_timestamp: Invalid Time_t
*
* @note This should not return a reference to the static value if this value is meant to be
* read and written from different threads.
*/
static WriteParams write_params_default() noexcept
{
return WriteParams();
}
private:
class FASTDDS_EXPORTED_API UserWriteDataPtr : public std::shared_ptr<UserWriteData>
{
public:
UserWriteDataPtr(
std::shared_ptr<UserWriteData> ptr)
: std::shared_ptr<UserWriteData>(ptr)
{
}
};
/// Attribute that holds sample_identity member value
SampleIdentity sample_identity_;
/// Attribute that holds related_sample_identity member value
SampleIdentity related_sample_identity_;
/// Attribute that holds source_timestamp member value
Time_t source_timestamp_{ -1, TIME_T_INFINITE_NANOSECONDS };
/// User write data
UserWriteDataPtr user_write_data_{nullptr};
};
} // namespace rtps
} // namespace fastdds
} // namespace eprosima
#endif //FASTDDS_RTPS_COMMON__WRITEPARAMS_HPP