/src/Fast-DDS/include/fastdds/rtps/builtin/data/ReaderProxyData.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 ReaderProxyData.h |
17 | | * |
18 | | */ |
19 | | |
20 | | #ifndef _FASTDDS_RTPS_BUILTIN_DATA_READERPROXYDATA_H_ |
21 | | #define _FASTDDS_RTPS_BUILTIN_DATA_READERPROXYDATA_H_ |
22 | | #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
23 | | |
24 | | #include <fastrtps/attributes/TopicAttributes.h> |
25 | | #include <fastrtps/qos/ReaderQos.h> |
26 | | |
27 | | #include <fastdds/rtps/attributes/WriterAttributes.h> |
28 | | #include <fastdds/rtps/attributes/RTPSParticipantAllocationAttributes.hpp> |
29 | | #include <fastdds/rtps/common/RemoteLocators.hpp> |
30 | | #include <fastdds/rtps/builtin/data/ContentFilterProperty.hpp> |
31 | | |
32 | | #if HAVE_SECURITY |
33 | | #include <fastdds/rtps/security/accesscontrol/EndpointSecurityAttributes.h> |
34 | | #endif // if HAVE_SECURITY |
35 | | |
36 | | |
37 | | namespace eprosima { |
38 | | namespace fastrtps { |
39 | | namespace rtps { |
40 | | |
41 | | struct CDRMessage_t; |
42 | | class NetworkFactory; |
43 | | |
44 | | /** |
45 | | * Class ReaderProxyData, used to represent all the information on a Reader (both local and remote) with the purpose of |
46 | | * implementing the discovery. |
47 | | * *@ingroup BUILTIN_MODULE |
48 | | */ |
49 | | class ReaderProxyData |
50 | | { |
51 | | public: |
52 | | |
53 | | RTPS_DllAPI ReaderProxyData( |
54 | | const size_t max_unicast_locators, |
55 | | const size_t max_multicast_locators, |
56 | | const fastdds::rtps::ContentFilterProperty::AllocationConfiguration& content_filter_limits = {}); |
57 | | |
58 | | RTPS_DllAPI ReaderProxyData( |
59 | | const size_t max_unicast_locators, |
60 | | const size_t max_multicast_locators, |
61 | | const VariableLengthDataLimits& data_limits, |
62 | | const fastdds::rtps::ContentFilterProperty::AllocationConfiguration& content_filter_limits = {}); |
63 | | |
64 | | RTPS_DllAPI virtual ~ReaderProxyData(); |
65 | | |
66 | | RTPS_DllAPI ReaderProxyData( |
67 | | const ReaderProxyData& readerInfo); |
68 | | |
69 | | RTPS_DllAPI ReaderProxyData& operator =( |
70 | | const ReaderProxyData& readerInfo); |
71 | | |
72 | | RTPS_DllAPI void guid( |
73 | | const GUID_t& guid) |
74 | 0 | { |
75 | 0 | m_guid = guid; |
76 | 0 | } |
77 | | |
78 | | RTPS_DllAPI void guid( |
79 | | GUID_t&& guid) |
80 | 0 | { |
81 | 0 | m_guid = std::move(guid); |
82 | 0 | } |
83 | | |
84 | | RTPS_DllAPI const GUID_t& guid() const |
85 | 0 | { |
86 | 0 | return m_guid; |
87 | 0 | } |
88 | | |
89 | | RTPS_DllAPI GUID_t& guid() |
90 | 0 | { |
91 | 0 | return m_guid; |
92 | 0 | } |
93 | | |
94 | | RTPS_DllAPI bool has_locators() const |
95 | 0 | { |
96 | 0 | return !remote_locators_.unicast.empty() || !remote_locators_.multicast.empty(); |
97 | 0 | } |
98 | | |
99 | | RTPS_DllAPI const RemoteLocatorList& remote_locators() const |
100 | 0 | { |
101 | 0 | return remote_locators_; |
102 | 0 | } |
103 | | |
104 | | RTPS_DllAPI void add_unicast_locator( |
105 | | const Locator_t& locator); |
106 | | |
107 | | void set_announced_unicast_locators( |
108 | | const LocatorList_t& locators); |
109 | | |
110 | | void set_remote_unicast_locators( |
111 | | const LocatorList_t& locators, |
112 | | const NetworkFactory& network); |
113 | | |
114 | | RTPS_DllAPI void add_multicast_locator( |
115 | | const Locator_t& locator); |
116 | | |
117 | | void set_multicast_locators( |
118 | | const LocatorList_t& locators, |
119 | | const NetworkFactory& network); |
120 | | |
121 | | void set_locators( |
122 | | const RemoteLocatorList& locators); |
123 | | |
124 | | void set_remote_locators( |
125 | | const RemoteLocatorList& locators, |
126 | | const NetworkFactory& network, |
127 | | bool use_multicast_locators); |
128 | | |
129 | | RTPS_DllAPI void key( |
130 | | const InstanceHandle_t& key) |
131 | 0 | { |
132 | 0 | m_key = key; |
133 | 0 | } |
134 | | |
135 | | RTPS_DllAPI void key( |
136 | | InstanceHandle_t&& key) |
137 | 0 | { |
138 | 0 | m_key = std::move(key); |
139 | 0 | } |
140 | | |
141 | | RTPS_DllAPI InstanceHandle_t key() const |
142 | 0 | { |
143 | 0 | return m_key; |
144 | 0 | } |
145 | | |
146 | | RTPS_DllAPI InstanceHandle_t& key() |
147 | 0 | { |
148 | 0 | return m_key; |
149 | 0 | } |
150 | | |
151 | | RTPS_DllAPI void RTPSParticipantKey( |
152 | | const InstanceHandle_t& RTPSParticipantKey) |
153 | 0 | { |
154 | 0 | m_RTPSParticipantKey = RTPSParticipantKey; |
155 | 0 | } |
156 | | |
157 | | RTPS_DllAPI void RTPSParticipantKey( |
158 | | InstanceHandle_t&& RTPSParticipantKey) |
159 | 0 | { |
160 | 0 | m_RTPSParticipantKey = std::move(RTPSParticipantKey); |
161 | 0 | } |
162 | | |
163 | | RTPS_DllAPI InstanceHandle_t RTPSParticipantKey() const |
164 | 0 | { |
165 | 0 | return m_RTPSParticipantKey; |
166 | 0 | } |
167 | | |
168 | | RTPS_DllAPI InstanceHandle_t& RTPSParticipantKey() |
169 | 0 | { |
170 | 0 | return m_RTPSParticipantKey; |
171 | 0 | } |
172 | | |
173 | | RTPS_DllAPI void typeName( |
174 | | const string_255& typeName) |
175 | 0 | { |
176 | 0 | m_typeName = typeName; |
177 | 0 | } |
178 | | |
179 | | RTPS_DllAPI void typeName( |
180 | | string_255&& typeName) |
181 | 0 | { |
182 | 0 | m_typeName = std::move(typeName); |
183 | 0 | } |
184 | | |
185 | | RTPS_DllAPI const string_255& typeName() const |
186 | 0 | { |
187 | 0 | return m_typeName; |
188 | 0 | } |
189 | | |
190 | | RTPS_DllAPI string_255& typeName() |
191 | 0 | { |
192 | 0 | return m_typeName; |
193 | 0 | } |
194 | | |
195 | | RTPS_DllAPI void topicName( |
196 | | const string_255& topicName) |
197 | 0 | { |
198 | 0 | m_topicName = topicName; |
199 | 0 | } |
200 | | |
201 | | RTPS_DllAPI void topicName( |
202 | | string_255&& topicName) |
203 | 0 | { |
204 | 0 | m_topicName = std::move(topicName); |
205 | 0 | } |
206 | | |
207 | | RTPS_DllAPI const string_255& topicName() const |
208 | 0 | { |
209 | 0 | return m_topicName; |
210 | 0 | } |
211 | | |
212 | | RTPS_DllAPI string_255& topicName() |
213 | 0 | { |
214 | 0 | return m_topicName; |
215 | 0 | } |
216 | | |
217 | | RTPS_DllAPI void userDefinedId( |
218 | | uint16_t userDefinedId) |
219 | 0 | { |
220 | 0 | m_userDefinedId = userDefinedId; |
221 | 0 | } |
222 | | |
223 | | RTPS_DllAPI uint16_t userDefinedId() const |
224 | 0 | { |
225 | 0 | return m_userDefinedId; |
226 | 0 | } |
227 | | |
228 | | RTPS_DllAPI uint16_t& userDefinedId() |
229 | 0 | { |
230 | 0 | return m_userDefinedId; |
231 | 0 | } |
232 | | |
233 | | RTPS_DllAPI void content_filter( |
234 | | const fastdds::rtps::ContentFilterProperty& filter) |
235 | 0 | { |
236 | 0 | content_filter_ = filter; |
237 | 0 | } |
238 | | |
239 | | RTPS_DllAPI void content_filter( |
240 | | fastdds::rtps::ContentFilterProperty&& filter) |
241 | 0 | { |
242 | 0 | content_filter_ = std::move(filter); |
243 | 0 | } |
244 | | |
245 | | RTPS_DllAPI const fastdds::rtps::ContentFilterProperty& content_filter() const |
246 | 0 | { |
247 | 0 | return content_filter_; |
248 | 0 | } |
249 | | |
250 | | RTPS_DllAPI fastdds::rtps::ContentFilterProperty& content_filter() |
251 | 0 | { |
252 | 0 | return content_filter_; |
253 | 0 | } |
254 | | |
255 | | RTPS_DllAPI void isAlive( |
256 | | bool isAlive) |
257 | 0 | { |
258 | 0 | m_isAlive = isAlive; |
259 | 0 | } |
260 | | |
261 | | RTPS_DllAPI bool isAlive() const |
262 | 0 | { |
263 | 0 | return m_isAlive; |
264 | 0 | } |
265 | | |
266 | | RTPS_DllAPI bool& isAlive() |
267 | 0 | { |
268 | 0 | return m_isAlive; |
269 | 0 | } |
270 | | |
271 | | RTPS_DllAPI void topicKind( |
272 | | TopicKind_t topicKind) |
273 | 0 | { |
274 | 0 | m_topicKind = topicKind; |
275 | 0 | } |
276 | | |
277 | | RTPS_DllAPI TopicKind_t topicKind() const |
278 | 0 | { |
279 | 0 | return m_topicKind; |
280 | 0 | } |
281 | | |
282 | | RTPS_DllAPI TopicKind_t& topicKind() |
283 | 0 | { |
284 | 0 | return m_topicKind; |
285 | 0 | } |
286 | | |
287 | | RTPS_DllAPI void type_id( |
288 | | const TypeIdV1& other_type_id) |
289 | 0 | { |
290 | 0 | type_id() = other_type_id; |
291 | 0 | } |
292 | | |
293 | | RTPS_DllAPI const TypeIdV1& type_id() const |
294 | 0 | { |
295 | 0 | assert(m_type_id != nullptr); |
296 | 0 | return *m_type_id; |
297 | 0 | } |
298 | | |
299 | | RTPS_DllAPI TypeIdV1& type_id() |
300 | 0 | { |
301 | 0 | if (m_type_id == nullptr) |
302 | 0 | { |
303 | 0 | m_type_id = new TypeIdV1(); |
304 | 0 | } |
305 | 0 | return *m_type_id; |
306 | 0 | } |
307 | | |
308 | | RTPS_DllAPI bool has_type_id() const |
309 | 0 | { |
310 | 0 | return m_type_id != nullptr; |
311 | 0 | } |
312 | | |
313 | | RTPS_DllAPI void type( |
314 | | const TypeObjectV1& other_type) |
315 | 0 | { |
316 | 0 | type() = other_type; |
317 | 0 | } |
318 | | |
319 | | RTPS_DllAPI const TypeObjectV1& type() const |
320 | 0 | { |
321 | 0 | assert(m_type != nullptr); |
322 | 0 | return *m_type; |
323 | 0 | } |
324 | | |
325 | | RTPS_DllAPI TypeObjectV1& type() |
326 | 0 | { |
327 | 0 | if (m_type == nullptr) |
328 | 0 | { |
329 | 0 | m_type = new TypeObjectV1(); |
330 | 0 | } |
331 | 0 | return *m_type; |
332 | 0 | } |
333 | | |
334 | | RTPS_DllAPI bool has_type() const |
335 | 0 | { |
336 | 0 | return m_type != nullptr; |
337 | 0 | } |
338 | | |
339 | | RTPS_DllAPI void type_information( |
340 | | const xtypes::TypeInformation& other_type_information) |
341 | 0 | { |
342 | 0 | type_information() = other_type_information; |
343 | 0 | } |
344 | | |
345 | | RTPS_DllAPI const xtypes::TypeInformation& type_information() const |
346 | 0 | { |
347 | 0 | assert(m_type_information != nullptr); |
348 | 0 | return *m_type_information; |
349 | 0 | } |
350 | | |
351 | | RTPS_DllAPI xtypes::TypeInformation& type_information() |
352 | 0 | { |
353 | 0 | if (m_type_information == nullptr) |
354 | 0 | { |
355 | 0 | m_type_information = new xtypes::TypeInformation(); |
356 | 0 | } |
357 | 0 | return *m_type_information; |
358 | 0 | } |
359 | | |
360 | | RTPS_DllAPI bool has_type_information() const |
361 | 0 | { |
362 | 0 | return m_type_information != nullptr; |
363 | 0 | } |
364 | | |
365 | | inline bool disable_positive_acks() const |
366 | 0 | { |
367 | 0 | return m_qos.m_disablePositiveACKs.enabled; |
368 | 0 | } |
369 | | |
370 | | /** |
371 | | * Set participant client server sample identity |
372 | | * @param sid valid SampleIdentity |
373 | | */ |
374 | | void set_sample_identity( |
375 | | const SampleIdentity& sid) |
376 | 0 | { |
377 | 0 | fastdds::dds::set_proxy_property(sid, "PID_CLIENT_SERVER_KEY", m_properties); |
378 | 0 | } |
379 | | |
380 | | /** |
381 | | * Retrieve participant SampleIdentity |
382 | | * @return SampleIdentity |
383 | | */ |
384 | | SampleIdentity get_sample_identity() const |
385 | 0 | { |
386 | 0 | return fastdds::dds::get_proxy_property<SampleIdentity>("PID_CLIENT_SERVER_KEY", m_properties); |
387 | 0 | } |
388 | | |
389 | | /** |
390 | | * Get the size in bytes of the CDR serialization of this object. |
391 | | * @param include_encapsulation Whether to include the size of the encapsulation info. |
392 | | * @return size in bytes of the CDR serialization. |
393 | | */ |
394 | | uint32_t get_serialized_size( |
395 | | bool include_encapsulation) const; |
396 | | |
397 | | /** |
398 | | * Write as a parameter list on a CDRMessage_t |
399 | | * @return True on success |
400 | | */ |
401 | | bool writeToCDRMessage( |
402 | | CDRMessage_t* msg, |
403 | | bool write_encapsulation) const; |
404 | | |
405 | | /** |
406 | | * Read the information from a CDRMessage_t. The position of the message must be in the beginning on the |
407 | | * parameter list. |
408 | | * @param msg Pointer to the message. |
409 | | * @param network Reference to network factory for locator validation and transformation |
410 | | * @param is_shm_transport_available Indicates whether the Reader is reachable by SHM. |
411 | | * @return true on success |
412 | | */ |
413 | | RTPS_DllAPI bool readFromCDRMessage( |
414 | | CDRMessage_t* msg, |
415 | | const NetworkFactory& network, |
416 | | bool is_shm_transport_available); |
417 | | |
418 | | //! |
419 | | bool m_expectsInlineQos; |
420 | | //!Reader Qos |
421 | | ReaderQos m_qos; |
422 | | |
423 | | #if HAVE_SECURITY |
424 | | //!EndpointSecurityInfo.endpoint_security_attributes |
425 | | security::EndpointSecurityAttributesMask security_attributes_; |
426 | | |
427 | | //!EndpointSecurityInfo.plugin_endpoint_security_attributes |
428 | | security::PluginEndpointSecurityAttributesMask plugin_security_attributes_; |
429 | | #endif // if HAVE_SECURITY |
430 | | |
431 | | /** |
432 | | * Clear (put to default) the information. |
433 | | */ |
434 | | void clear(); |
435 | | |
436 | | /** |
437 | | * Check if this object can be updated with the information on another object. |
438 | | * @param rdata ReaderProxyData object to be checked. |
439 | | * @return true if this object can be updated with the information on rdata. |
440 | | */ |
441 | | bool is_update_allowed( |
442 | | const ReaderProxyData& rdata) const; |
443 | | |
444 | | /** |
445 | | * Update the information (only certain fields will be updated). |
446 | | * @param rdata Pointer to the object from which we are going to update. |
447 | | */ |
448 | | void update( |
449 | | ReaderProxyData* rdata); |
450 | | |
451 | | /** |
452 | | * Copy ALL the information from another object. |
453 | | * @param rdata Pointer to the object from where the information must be copied. |
454 | | */ |
455 | | void copy( |
456 | | ReaderProxyData* rdata); |
457 | | |
458 | | private: |
459 | | |
460 | | //!GUID |
461 | | GUID_t m_guid; |
462 | | //!Holds locator information |
463 | | RemoteLocatorList remote_locators_; |
464 | | //!GUID_t of the Reader converted to InstanceHandle_t |
465 | | InstanceHandle_t m_key; |
466 | | //!GUID_t of the participant converted to InstanceHandle |
467 | | InstanceHandle_t m_RTPSParticipantKey; |
468 | | //!Type name |
469 | | string_255 m_typeName; |
470 | | //!Topic name |
471 | | string_255 m_topicName; |
472 | | //!User defined ID |
473 | | uint16_t m_userDefinedId; |
474 | | //!Field to indicate if the Reader is Alive. |
475 | | bool m_isAlive; |
476 | | //!Topic kind |
477 | | TopicKind_t m_topicKind; |
478 | | //!Type Identifier |
479 | | TypeIdV1* m_type_id; |
480 | | //!Type Object |
481 | | TypeObjectV1* m_type; |
482 | | //!Type Information |
483 | | xtypes::TypeInformation* m_type_information; |
484 | | //! |
485 | | ParameterPropertyList_t m_properties; |
486 | | //!Information on the content filter applied by the reader. |
487 | | fastdds::rtps::ContentFilterProperty content_filter_; |
488 | | }; |
489 | | |
490 | | } // namespace rtps |
491 | | } /* namespace rtps */ |
492 | | } /* namespace eprosima */ |
493 | | |
494 | | #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
495 | | #endif // _FASTDDS_RTPS_BUILTIN_DATA_READERPROXYDATA_H_ |