/src/Fast-DDS/src/cpp/fastdds/subscriber/DataReaderImpl.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2019 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 DataReaderImpl.hpp |
17 | | * |
18 | | */ |
19 | | |
20 | | #ifndef FASTDDS_SUBSCRIBER__DATAREADERIMPL_HPP |
21 | | #define FASTDDS_SUBSCRIBER__DATAREADERIMPL_HPP |
22 | | |
23 | | #include <mutex> |
24 | | |
25 | | #include <fastdds/dds/core/ReturnCode.hpp> |
26 | | #include <fastdds/dds/core/LoanableCollection.hpp> |
27 | | #include <fastdds/dds/core/LoanableSequence.hpp> |
28 | | #include <fastdds/dds/core/status/LivelinessChangedStatus.hpp> |
29 | | #include <fastdds/dds/core/status/StatusMask.hpp> |
30 | | #include <fastdds/dds/subscriber/DataReaderListener.hpp> |
31 | | #include <fastdds/dds/subscriber/qos/DataReaderQos.hpp> |
32 | | #include <fastdds/dds/subscriber/ReadCondition.hpp> |
33 | | #include <fastdds/dds/subscriber/SampleInfo.hpp> |
34 | | #include <fastdds/dds/topic/TypeSupport.hpp> |
35 | | #include <fastdds/rtps/attributes/ReaderAttributes.hpp> |
36 | | #include <fastdds/rtps/common/Guid.hpp> |
37 | | #include <fastdds/rtps/common/LocatorList.hpp> |
38 | | #include <fastdds/rtps/history/IPayloadPool.hpp> |
39 | | #include <fastdds/rtps/reader/ReaderListener.hpp> |
40 | | |
41 | | #include <fastdds/subscriber/DataReaderImpl/DataReaderLoanManager.hpp> |
42 | | #include <fastdds/subscriber/DataReaderImpl/SampleInfoPool.hpp> |
43 | | #include <fastdds/subscriber/DataReaderImpl/SampleLoanManager.hpp> |
44 | | #include <fastdds/subscriber/DataReaderImpl/StateFilter.hpp> |
45 | | #include <fastdds/subscriber/history/DataReaderHistory.hpp> |
46 | | #include <fastdds/subscriber/SubscriberImpl.hpp> |
47 | | #include <fastdds/dds/builtin/topic/SubscriptionBuiltinTopicData.hpp> |
48 | | #include <rtps/history/ITopicPayloadPool.h> |
49 | | |
50 | | namespace eprosima { |
51 | | namespace fastdds { |
52 | | namespace rtps { |
53 | | |
54 | | class RTPSReader; |
55 | | class TimedEvent; |
56 | | |
57 | | } // namespace rtps |
58 | | |
59 | | namespace dds { |
60 | | |
61 | | class ContentFilteredTopicImpl; |
62 | | class Subscriber; |
63 | | class SubscriberImpl; |
64 | | class TopicDescription; |
65 | | |
66 | | using SampleInfoSeq = LoanableSequence<SampleInfo>; |
67 | | |
68 | | namespace detail { |
69 | | |
70 | | struct ReadTakeCommand; |
71 | | class ReadConditionImpl; |
72 | | |
73 | | } // namespace detail |
74 | | |
75 | | /** |
76 | | * Class DataReader, contains the actual implementation of the behaviour of the Subscriber. |
77 | | * @ingroup FASTDDS_MODULE |
78 | | */ |
79 | | class DataReaderImpl |
80 | | { |
81 | | friend struct detail::ReadTakeCommand; |
82 | | friend class detail::ReadConditionImpl; |
83 | | |
84 | | protected: |
85 | | |
86 | | using ITopicPayloadPool = eprosima::fastdds::rtps::ITopicPayloadPool; |
87 | | using IPayloadPool = eprosima::fastdds::rtps::IPayloadPool; |
88 | | |
89 | | friend class SubscriberImpl; |
90 | | |
91 | | /** |
92 | | * Creates a DataReader. Don't use it directly, but through Subscriber. |
93 | | */ |
94 | | DataReaderImpl( |
95 | | SubscriberImpl* s, |
96 | | const TypeSupport& type, |
97 | | TopicDescription* topic, |
98 | | const DataReaderQos& qos, |
99 | | DataReaderListener* listener = nullptr, |
100 | | std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool = nullptr); |
101 | | |
102 | | public: |
103 | | |
104 | | virtual ~DataReaderImpl(); |
105 | | |
106 | | virtual ReturnCode_t enable(); |
107 | | |
108 | | /** |
109 | | * Method to check if a DataReader can be deleted |
110 | | * @param recursive == true if is used from delete_contained_entities otherwise delete_datareader |
111 | | * @return true if can be deleted according to the standard rules |
112 | | */ |
113 | | bool can_be_deleted( |
114 | | bool recursive = true) const; |
115 | | |
116 | | /** |
117 | | * Method to block the current thread until an unread message is available |
118 | | */ |
119 | | bool wait_for_unread_message( |
120 | | const fastdds::dds::Duration_t& timeout); |
121 | | |
122 | | |
123 | | /** @name Read or take data methods. |
124 | | * Methods to read or take data from the History. |
125 | | */ |
126 | | |
127 | | ///@{ |
128 | | |
129 | | ReturnCode_t read( |
130 | | LoanableCollection& data_values, |
131 | | SampleInfoSeq& sample_infos, |
132 | | int32_t max_samples = LENGTH_UNLIMITED, |
133 | | SampleStateMask sample_states = ANY_SAMPLE_STATE, |
134 | | ViewStateMask view_states = ANY_VIEW_STATE, |
135 | | InstanceStateMask instance_states = ANY_INSTANCE_STATE); |
136 | | |
137 | | ReturnCode_t read_instance( |
138 | | LoanableCollection& data_values, |
139 | | SampleInfoSeq& sample_infos, |
140 | | int32_t max_samples = LENGTH_UNLIMITED, |
141 | | const InstanceHandle_t& a_handle = HANDLE_NIL, |
142 | | SampleStateMask sample_states = ANY_SAMPLE_STATE, |
143 | | ViewStateMask view_states = ANY_VIEW_STATE, |
144 | | InstanceStateMask instance_states = ANY_INSTANCE_STATE); |
145 | | |
146 | | ReturnCode_t read_next_instance( |
147 | | LoanableCollection& data_values, |
148 | | SampleInfoSeq& sample_infos, |
149 | | int32_t max_samples = LENGTH_UNLIMITED, |
150 | | const InstanceHandle_t& previous_handle = HANDLE_NIL, |
151 | | SampleStateMask sample_states = ANY_SAMPLE_STATE, |
152 | | ViewStateMask view_states = ANY_VIEW_STATE, |
153 | | InstanceStateMask instance_states = ANY_INSTANCE_STATE); |
154 | | |
155 | | ReturnCode_t read_next_sample( |
156 | | void* data, |
157 | | SampleInfo* info); |
158 | | |
159 | | ReturnCode_t take( |
160 | | LoanableCollection& data_values, |
161 | | SampleInfoSeq& sample_infos, |
162 | | int32_t max_samples = LENGTH_UNLIMITED, |
163 | | SampleStateMask sample_states = ANY_SAMPLE_STATE, |
164 | | ViewStateMask view_states = ANY_VIEW_STATE, |
165 | | InstanceStateMask instance_states = ANY_INSTANCE_STATE); |
166 | | |
167 | | ReturnCode_t take_instance( |
168 | | LoanableCollection& data_values, |
169 | | SampleInfoSeq& sample_infos, |
170 | | int32_t max_samples = LENGTH_UNLIMITED, |
171 | | const InstanceHandle_t& a_handle = HANDLE_NIL, |
172 | | SampleStateMask sample_states = ANY_SAMPLE_STATE, |
173 | | ViewStateMask view_states = ANY_VIEW_STATE, |
174 | | InstanceStateMask instance_states = ANY_INSTANCE_STATE); |
175 | | |
176 | | ReturnCode_t take_next_instance( |
177 | | LoanableCollection& data_values, |
178 | | SampleInfoSeq& sample_infos, |
179 | | int32_t max_samples = LENGTH_UNLIMITED, |
180 | | const InstanceHandle_t& previous_handle = HANDLE_NIL, |
181 | | SampleStateMask sample_states = ANY_SAMPLE_STATE, |
182 | | ViewStateMask view_states = ANY_VIEW_STATE, |
183 | | InstanceStateMask instance_states = ANY_INSTANCE_STATE); |
184 | | |
185 | | ReturnCode_t take_next_sample( |
186 | | void* data, |
187 | | SampleInfo* info); |
188 | | |
189 | | ///@} |
190 | | |
191 | | ReturnCode_t return_loan( |
192 | | LoanableCollection& data_values, |
193 | | SampleInfoSeq& sample_infos); |
194 | | |
195 | | /** |
196 | | * @brief Returns information about the first untaken sample. This method is meant to be called prior to |
197 | | * a read() or take() operation as it does not modify the status condition of the entity. |
198 | | * @param [out] info Pointer to a SampleInfo structure to store first untaken sample information. |
199 | | * @return true if sample info was returned. false if there is no sample to take. |
200 | | */ |
201 | | ReturnCode_t get_first_untaken_info( |
202 | | SampleInfo* info); |
203 | | |
204 | | /** |
205 | | * Get the number of samples pending to be read. |
206 | | * |
207 | | * @param mark_as_read Whether the unread samples should be marked as read or not. |
208 | | * |
209 | | * @return the number of samples on the reader history that have never been read. |
210 | | */ |
211 | | uint64_t get_unread_count( |
212 | | bool mark_as_read); |
213 | | |
214 | | /** |
215 | | * Get associated GUID |
216 | | * @return Associated GUID |
217 | | */ |
218 | | const fastdds::rtps::GUID_t& guid() const; |
219 | | |
220 | | fastdds::rtps::InstanceHandle_t get_instance_handle() const; |
221 | | |
222 | | /** |
223 | | * Get topic data type |
224 | | * @return Topic data type |
225 | | */ |
226 | | TypeSupport type() const; |
227 | | |
228 | | /** |
229 | | * Get TopicDescription |
230 | | * @return TopicDescription |
231 | | */ |
232 | | const TopicDescription* get_topicdescription() const; |
233 | | |
234 | | ReturnCode_t get_subscription_matched_status( |
235 | | SubscriptionMatchedStatus& status); |
236 | | |
237 | | /** |
238 | | * @brief Retrieves in a publication associated with the DataWriter |
239 | | * |
240 | | * @param[out] publication_data publication data struct |
241 | | * @param publication_handle @ref InstanceHandle_t of the publication |
242 | | * @return @ref RETCODE_BAD_PARAMETER if the DataReader is not matched with |
243 | | * the given publication handle, @ref RETCODE_OK otherwise. |
244 | | * |
245 | | */ |
246 | | ReturnCode_t get_matched_publication_data( |
247 | | rtps::PublicationBuiltinTopicData& publication_data, |
248 | | const InstanceHandle_t& publication_handle) const; |
249 | | |
250 | | /** |
251 | | * @brief Fills the given vector with the @ref InstanceHandle_t of matched DataReaders |
252 | | * |
253 | | * @param[out] publication_handles Vector where the @ref InstanceHandle_t are returned |
254 | | * @return @ref RETCODE_OK if the operation succeeds. |
255 | | * |
256 | | * @note Returning an empty list is not an error, it returns @ref RETCODE_OK. |
257 | | * |
258 | | */ |
259 | | ReturnCode_t get_matched_publications( |
260 | | std::vector<InstanceHandle_t>& publication_handles) const; |
261 | | |
262 | | ReturnCode_t get_requested_deadline_missed_status( |
263 | | RequestedDeadlineMissedStatus& status); |
264 | | |
265 | | ReturnCode_t set_qos( |
266 | | const DataReaderQos& qos); |
267 | | |
268 | | const DataReaderQos& get_qos() const; |
269 | | |
270 | | ReturnCode_t set_listener( |
271 | | DataReaderListener* listener); |
272 | | |
273 | | const DataReaderListener* get_listener() const; |
274 | | |
275 | | /* TODO |
276 | | bool get_key_value( |
277 | | void* data, |
278 | | const fastdds::rtps::InstanceHandle_t& handle); |
279 | | */ |
280 | | |
281 | | ReturnCode_t get_liveliness_changed_status( |
282 | | LivelinessChangedStatus& status); |
283 | | |
284 | | ReturnCode_t get_requested_incompatible_qos_status( |
285 | | RequestedIncompatibleQosStatus& status); |
286 | | |
287 | | /*! |
288 | | * @brief Get the SAMPLE_LOST communication status |
289 | | * |
290 | | * @param [out] status SampleLostStatus object where the status is returned. |
291 | | * |
292 | | * @return RETCODE_OK |
293 | | */ |
294 | | ReturnCode_t get_sample_lost_status( |
295 | | fastdds::dds::SampleLostStatus& status); |
296 | | |
297 | | /*! |
298 | | * @brief Get the SAMPLE_REJECTED communication status |
299 | | * |
300 | | * @param [out] status SampleRejectedStatus object where the status is returned. |
301 | | * |
302 | | * @return RETCODE_OK |
303 | | */ |
304 | | ReturnCode_t get_sample_rejected_status( |
305 | | SampleRejectedStatus& status); |
306 | | |
307 | | const Subscriber* get_subscriber() const; |
308 | | |
309 | | /* TODO |
310 | | bool wait_for_historical_data( |
311 | | const fastdds::dds::Duration_t& max_wait) const; |
312 | | */ |
313 | | |
314 | | //! Remove all listeners in the hierarchy to allow a quiet destruction |
315 | | virtual void disable(); |
316 | | |
317 | | /* Extends the check_qos() call, including the check for |
318 | | * resource limits policy. |
319 | | * @param qos Pointer to the qos to be checked. |
320 | | * @param type Pointer to the associated TypeSupport object. |
321 | | * @return True if correct. |
322 | | */ |
323 | | static ReturnCode_t check_qos_including_resource_limits( |
324 | | const DataReaderQos& qos, |
325 | | const TypeSupport& type); |
326 | | |
327 | | /* Check whether values in the DataReaderQos are compatible among them or not |
328 | | * @param qos Pointer to the qos to be checked. |
329 | | * @return True if correct. |
330 | | */ |
331 | | static ReturnCode_t check_qos ( |
332 | | const DataReaderQos& qos); |
333 | | |
334 | | /* Checks resource limits policy: Instance allocation consistency |
335 | | * @param qos Pointer to the qos to be checked. |
336 | | * @return True if correct. |
337 | | */ |
338 | | static ReturnCode_t check_allocation_consistency( |
339 | | const DataReaderQos& qos); |
340 | | |
341 | | /* Check whether the DataReaderQos can be updated with the values provided. This method DOES NOT update anything. |
342 | | * @param to Reference to the qos instance to be changed. |
343 | | * @param from Reference to the qos instance with the new values. |
344 | | * @return True if they can be updated. |
345 | | */ |
346 | | static bool can_qos_be_updated( |
347 | | const DataReaderQos& to, |
348 | | const DataReaderQos& from); |
349 | | |
350 | | /* Update a DataReaderQos with new values |
351 | | * @param to Reference to the qos instance to be changed. |
352 | | * @param from Reference to the qos instance with the new values. |
353 | | * @param first_time Boolean indicating whether is the first time (If not some parameters cannot be set). |
354 | | */ |
355 | | static void set_qos( |
356 | | DataReaderQos& to, |
357 | | const DataReaderQos& from, |
358 | | bool first_time); |
359 | | |
360 | | /** |
361 | | * Checks whether the sample is still valid or is corrupted |
362 | | * @param data Pointer to the sample data to check |
363 | | * @param info Pointer to the SampleInfo related to \c data |
364 | | * @return true if the sample is valid |
365 | | */ |
366 | | bool is_sample_valid( |
367 | | const void* data, |
368 | | const SampleInfo* info) const; |
369 | | |
370 | | /** |
371 | | * Get the list of locators on which this DataReader is listening. |
372 | | * |
373 | | * @param [out] locators LocatorList where the list of locators will be stored. |
374 | | * |
375 | | * @return NOT_ENABLED if the reader has not been enabled. |
376 | | * @return OK if a list of locators is returned. |
377 | | */ |
378 | | ReturnCode_t get_listening_locators( |
379 | | rtps::LocatorList& locators) const; |
380 | | |
381 | | ReturnCode_t delete_contained_entities(); |
382 | | |
383 | | void filter_has_been_updated(); |
384 | | |
385 | | InstanceHandle_t lookup_instance( |
386 | | const void* instance) const; |
387 | | |
388 | | ReadCondition* create_readcondition( |
389 | | SampleStateMask sample_states, |
390 | | ViewStateMask view_states, |
391 | | InstanceStateMask instance_states) noexcept; |
392 | | |
393 | | ReturnCode_t delete_readcondition( |
394 | | ReadCondition* a_condition) noexcept; |
395 | | |
396 | | const detail::StateFilter& get_last_mask_state() const; |
397 | | |
398 | | void try_notify_read_conditions() noexcept; |
399 | | |
400 | | std::recursive_mutex& get_conditions_mutex() const noexcept; |
401 | | |
402 | | /** |
403 | | * Retrieve the subscription data discovery information. |
404 | | * |
405 | | * @param [out] subscription_data The subscription data discovery information. |
406 | | * |
407 | | * @return NOT_ENABLED if the reader has not been enabled. |
408 | | * @return OK if the subscription data is returned. |
409 | | */ |
410 | | ReturnCode_t get_subscription_builtin_topic_data( |
411 | | SubscriptionBuiltinTopicData& subscription_data) const; |
412 | | |
413 | | protected: |
414 | | |
415 | | //!Subscriber |
416 | | SubscriberImpl* subscriber_ = nullptr; |
417 | | |
418 | | //!Pointer to associated RTPSReader |
419 | | fastdds::rtps::RTPSReader* reader_ = nullptr; |
420 | | |
421 | | //! Pointer to the TopicDataType object. |
422 | | TypeSupport type_; |
423 | | |
424 | | TopicDescription* topic_ = nullptr; |
425 | | |
426 | | DataReaderQos qos_; |
427 | | |
428 | | //!History |
429 | | detail::DataReaderHistory history_; |
430 | | |
431 | | //!Listener |
432 | | DataReaderListener* listener_ = nullptr; |
433 | | mutable std::mutex listener_mutex_; |
434 | | |
435 | | fastdds::rtps::GUID_t guid_; |
436 | | |
437 | | class InnerDataReaderListener : public fastdds::rtps::ReaderListener |
438 | | { |
439 | | public: |
440 | | |
441 | | InnerDataReaderListener( |
442 | | DataReaderImpl* s) |
443 | 0 | : data_reader_(s) |
444 | 0 | { |
445 | 0 | } |
446 | | |
447 | | virtual ~InnerDataReaderListener() override |
448 | 0 | { |
449 | 0 | } |
450 | | |
451 | | void on_reader_matched( |
452 | | fastdds::rtps::RTPSReader* reader, |
453 | | const fastdds::rtps::MatchingInfo& info) override; |
454 | | |
455 | | void on_data_available( |
456 | | fastdds::rtps::RTPSReader* reader, |
457 | | const fastdds::rtps::GUID_t& writer_guid, |
458 | | const fastdds::rtps::SequenceNumber_t& first_sequence, |
459 | | const fastdds::rtps::SequenceNumber_t& last_sequence, |
460 | | bool& should_notify_individual_changes) override; |
461 | | |
462 | | void on_liveliness_changed( |
463 | | fastdds::rtps::RTPSReader* reader, |
464 | | const LivelinessChangedStatus& status) override; |
465 | | |
466 | | void on_requested_incompatible_qos( |
467 | | fastdds::rtps::RTPSReader* reader, |
468 | | fastdds::dds::PolicyMask qos) override; |
469 | | |
470 | | void on_sample_lost( |
471 | | fastdds::rtps::RTPSReader* reader, |
472 | | int32_t sample_lost_since_last_update) override; |
473 | | |
474 | | void on_sample_rejected( |
475 | | fastdds::rtps::RTPSReader* reader, |
476 | | SampleRejectedStatusKind reason, |
477 | | const fastdds::rtps::CacheChange_t* const change) override; |
478 | | |
479 | | #ifdef FASTDDS_STATISTICS |
480 | | void notify_status_observer( |
481 | | const uint32_t& status_id); |
482 | | #endif //FASTDDS_STATISTICS |
483 | | |
484 | | DataReaderImpl* data_reader_; |
485 | | |
486 | | } |
487 | | reader_listener_; |
488 | | |
489 | | //! A timer used to check for deadlines |
490 | | fastdds::rtps::TimedEvent* deadline_timer_ = nullptr; |
491 | | |
492 | | //! Deadline duration in microseconds |
493 | | std::chrono::duration<double, std::ratio<1, 1000000>> deadline_duration_us_; |
494 | | |
495 | | //! The current timer owner, i.e. the instance which started the deadline timer |
496 | | fastdds::rtps::InstanceHandle_t timer_owner_; |
497 | | |
498 | | //! Subscription matched status |
499 | | SubscriptionMatchedStatus subscription_matched_status_; |
500 | | |
501 | | //! Liveliness changed status |
502 | | LivelinessChangedStatus liveliness_changed_status_; |
503 | | |
504 | | //! Requested deadline missed status |
505 | | RequestedDeadlineMissedStatus deadline_missed_status_; |
506 | | |
507 | | //! Requested incompatible QoS status |
508 | | RequestedIncompatibleQosStatus requested_incompatible_qos_status_; |
509 | | |
510 | | //! Sample lost status |
511 | | SampleLostStatus sample_lost_status_; |
512 | | //! Sample rejected status |
513 | | SampleRejectedStatus sample_rejected_status_; |
514 | | |
515 | | //! A timed callback to remove expired samples |
516 | | fastdds::rtps::TimedEvent* lifespan_timer_ = nullptr; |
517 | | |
518 | | //! The lifespan duration |
519 | | std::chrono::duration<double, std::ratio<1, 1000000>> lifespan_duration_us_; |
520 | | |
521 | | DataReader* user_datareader_ = nullptr; |
522 | | |
523 | | std::shared_ptr<detail::SampleLoanManager> sample_pool_; |
524 | | std::shared_ptr<IPayloadPool> payload_pool_; |
525 | | |
526 | | bool is_custom_payload_pool_ = false; |
527 | | |
528 | | detail::SampleInfoPool sample_info_pool_; |
529 | | detail::DataReaderLoanManager loan_manager_; |
530 | | |
531 | | /** |
532 | | * Mutex to protect ReadCondition collection |
533 | | * is required because the RTPSReader mutex is only available when the object is enabled |
534 | | * @note use get_conditions_mutex() instead of directly referencing it |
535 | | * @note lock get_conditions_mutex() after lock reader_->getMutex() to avoid ABBAs because |
536 | | * try_notify_read_conditions() will be called from the callbacks with the reader |
537 | | * mutex locked |
538 | | */ |
539 | | mutable std::recursive_mutex conditions_mutex_; |
540 | | |
541 | | // Order for the ReadCondition collection |
542 | | struct ReadConditionOrder |
543 | | { |
544 | | using is_transparent = void; |
545 | | |
546 | | bool operator ()( |
547 | | const detail::ReadConditionImpl* lhs, |
548 | | const detail::ReadConditionImpl* rhs) const; |
549 | | bool operator ()( |
550 | | const detail::ReadConditionImpl* lhs, |
551 | | const detail::StateFilter& rhs) const; |
552 | | bool operator ()( |
553 | | const detail::StateFilter& lhs, |
554 | | const detail::ReadConditionImpl* rhs) const; |
555 | | |
556 | | template<class S, class V, class I> |
557 | | static inline bool less( |
558 | | S&& s1, |
559 | | V&& v1, |
560 | | I&& i1, |
561 | | S&& s2, |
562 | | V&& v2, |
563 | | I&& i2) |
564 | 0 | { |
565 | 0 | return s1 < s2 || (s1 == s2 && (v1 < v2 || (v1 == v2 && i1 < i2))); |
566 | 0 | } |
567 | | |
568 | | }; |
569 | | |
570 | | // ReadConditions collection |
571 | | std::set<detail::ReadConditionImpl*, ReadConditionOrder> read_conditions_; |
572 | | |
573 | | // State of the History mask last time it was queried |
574 | | // protected with the RTPSReader mutex |
575 | | detail::StateFilter last_mask_state_ {}; |
576 | | |
577 | | ReturnCode_t check_collection_preconditions_and_calc_max_samples( |
578 | | LoanableCollection& data_values, |
579 | | SampleInfoSeq& sample_infos, |
580 | | int32_t& max_samples); |
581 | | |
582 | | ReturnCode_t prepare_loan( |
583 | | LoanableCollection& data_values, |
584 | | SampleInfoSeq& sample_infos, |
585 | | int32_t& max_samples); |
586 | | |
587 | | ReturnCode_t read_or_take( |
588 | | LoanableCollection& data_values, |
589 | | SampleInfoSeq& sample_infos, |
590 | | int32_t max_samples, |
591 | | const InstanceHandle_t& handle, |
592 | | SampleStateMask sample_states, |
593 | | ViewStateMask view_states, |
594 | | InstanceStateMask instance_states, |
595 | | bool exact_instance, |
596 | | bool single_instance, |
597 | | bool should_take); |
598 | | |
599 | | ReturnCode_t read_or_take_next_sample( |
600 | | void* data, |
601 | | SampleInfo* info, |
602 | | bool should_take); |
603 | | |
604 | | void set_read_communication_status( |
605 | | bool trigger_value); |
606 | | |
607 | | void update_subscription_matched_status( |
608 | | const fastdds::rtps::MatchingInfo& status); |
609 | | |
610 | | bool on_data_available( |
611 | | const fastdds::rtps::GUID_t& writer_guid, |
612 | | const fastdds::rtps::SequenceNumber_t& first_sequence, |
613 | | const fastdds::rtps::SequenceNumber_t& last_sequence); |
614 | | |
615 | | /** |
616 | | * @brief A method called when a new cache change is added |
617 | | * @param change The cache change that has been added |
618 | | * @return True if the change was added (due to some QoS it could have been 'rejected') |
619 | | */ |
620 | | bool on_new_cache_change_added( |
621 | | const fastdds::rtps::CacheChange_t* const change); |
622 | | |
623 | | /** |
624 | | * @brief Method called when an instance misses the deadline |
625 | | */ |
626 | | bool deadline_missed(); |
627 | | |
628 | | /** |
629 | | * @brief A method to reschedule the deadline timer |
630 | | */ |
631 | | bool deadline_timer_reschedule(); |
632 | | |
633 | | /** |
634 | | * @brief A method called when the lifespan timer expires |
635 | | */ |
636 | | bool lifespan_expired(); |
637 | | |
638 | | void subscriber_qos_updated(); |
639 | | |
640 | | RequestedIncompatibleQosStatus& update_requested_incompatible_qos( |
641 | | PolicyMask incompatible_policies); |
642 | | |
643 | | LivelinessChangedStatus& update_liveliness_status( |
644 | | const LivelinessChangedStatus& status); |
645 | | |
646 | | const SampleLostStatus& update_sample_lost_status( |
647 | | int32_t sample_lost_since_last_update); |
648 | | |
649 | | /*! |
650 | | * @brief Update SampleRejectedStatus with information about a new rejected sample. |
651 | | * |
652 | | * @param [in] Reason why the new sample was rejected. |
653 | | * @param [in] New sample which was rejected. |
654 | | */ |
655 | | const SampleRejectedStatus& update_sample_rejected_status( |
656 | | SampleRejectedStatusKind reason, |
657 | | const fastdds::rtps::CacheChange_t* const change_in); |
658 | | |
659 | | /** |
660 | | * Returns the most appropriate listener to handle the callback for the given status, |
661 | | * or nullptr if there is no appropriate listener. |
662 | | */ |
663 | | DataReaderListener* get_listener_for( |
664 | | const StatusMask& status); |
665 | | |
666 | | std::shared_ptr<IPayloadPool> get_payload_pool(); |
667 | | |
668 | | void release_payload_pool(); |
669 | | |
670 | | void stop(); |
671 | | |
672 | | ReturnCode_t check_datasharing_compatible( |
673 | | const fastdds::rtps::ReaderAttributes& reader_attributes, |
674 | | bool& is_datasharing_compatible) const; |
675 | | |
676 | | private: |
677 | | |
678 | | void update_rtps_reader_qos(); |
679 | | |
680 | | DataReaderQos get_datareader_qos_from_settings( |
681 | | const DataReaderQos& qos); |
682 | | |
683 | | bool is_data_sharing_compatible_ = false; |
684 | | |
685 | | }; |
686 | | |
687 | | } /* namespace dds */ |
688 | | } /* namespace fastdds */ |
689 | | } /* namespace eprosima */ |
690 | | |
691 | | #endif /* FASTDDS_SUBSCRIBER__DATAREADERIMPL_HPP*/ |