| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
ReaderHistory.hpp
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
19
20#ifndef FASTDDS_RTPS_HISTORY__READERHISTORY_HPP
21#define FASTDDS_RTPS_HISTORY__READERHISTORY_HPP
22
23#include <fastdds/rtps/history/History.hpp>
24#include <fastdds/rtps/common/CacheChange.hpp>
25#include <fastdds/dds/core/status/SampleRejectedStatus.hpp>
26
27 namespace eprosima {
28 namespace fastdds {
29 namespace rtps {
30
31 class WriterProxy;
32 class RTPSReader;
33
38 class ReaderHistory : public History
39{
40 friend class RTPSReader;
41
42 ReaderHistory(
43 ReaderHistory&&) = delete;
44 ReaderHistory& operator =(
45 ReaderHistory&&) = delete;
46
47 public:
48
52 FASTDDS_EXPORTED_API ReaderHistory(
53 const HistoryAttributes& att);
54 FASTDDS_EXPORTED_API ~ReaderHistory() override;
55
70 FASTDDS_EXPORTED_API virtual bool can_change_be_added_nts(
71 const GUID_t& writer_guid,
72 uint32_t total_payload_size,
73 size_t unknown_missing_changes_up_to,
74 bool& will_never_be_accepted) const;
75
85 FASTDDS_EXPORTED_API virtual bool received_change(
86 CacheChange_t* change,
87 size_t unknown_missing_changes_up_to);
88
99 FASTDDS_EXPORTED_API virtual bool received_change(
100 CacheChange_t* change,
101 size_t unknown_missing_changes_up_to,
102 fastdds::dds::SampleRejectedStatusKind& rejection_reason)
103 {
104 rejection_reason = fastdds::dds::NOT_REJECTED;
105 return received_change(change, unknown_missing_changes_up_to);
106 }
107
114 FASTDDS_EXPORTED_API bool virtual completed_change(
115 rtps::CacheChange_t* change)
116 {
117 (void)change;
118 return true;
119 }
120
129 FASTDDS_EXPORTED_API virtual bool completed_change(
130 CacheChange_t* change,
131 size_t unknown_missing_changes_up_to,
132 fastdds::dds::SampleRejectedStatusKind& rejection_reason)
133 {
134 (void)change;
135 (void)unknown_missing_changes_up_to;
136 (void)rejection_reason;
137 return true;
138 }
139
145 FASTDDS_EXPORTED_API bool add_change(
146 CacheChange_t* a_change);
147
155 FASTDDS_EXPORTED_API iterator remove_change_nts(
156 const_iterator removal,
157 bool release = true) override;
158
167 FASTDDS_EXPORTED_API iterator remove_change_nts(
168 const_iterator removal,
169 const std::chrono::time_point<std::chrono::steady_clock>& max_blocking_time,
170 bool release = true) override;
171
178 FASTDDS_EXPORTED_API bool matches_change(
179 const CacheChange_t* inner,
180 CacheChange_t* outer) override;
181
183 using History::remove_change;
184
190 FASTDDS_EXPORTED_API bool remove_changes_with_guid(
191 const GUID_t& a_guid);
192
199 bool remove_fragmented_changes_until(
200 const SequenceNumber_t& seq_num,
201 const GUID_t& writer_guid);
202
203 FASTDDS_EXPORTED_API bool get_min_change_from(
204 CacheChange_t** min_change,
205 const GUID_t& writerGuid);
206
216 FASTDDS_EXPORTED_API virtual void writer_unmatched(
217 const GUID_t& writer_guid,
218 const SequenceNumber_t& last_notified_seq);
219
226 FASTDDS_EXPORTED_API virtual void writer_update_its_ownership_strength_nts(
227 const GUID_t& writer_guid,
228 const uint32_t ownership_strength)
229 {
230 static_cast<void>(writer_guid);
231 static_cast<void>(ownership_strength);
232 }
233
234 protected:
235
236 FASTDDS_EXPORTED_API void do_release_cache(
237 CacheChange_t* ch) override;
238
239 template<typename Pred>
240 inline void remove_changes_with_pred(
241 Pred pred)
242 {
243 assert(nullptr != mp_reader);
244 assert(nullptr != mp_mutex);
245
246 std::lock_guard<RecursiveTimedMutex> guard(*mp_mutex);
247 std::vector<CacheChange_t*>::iterator chit = m_changes.begin();
248 while (chit != m_changes.end())
249 {
250 if (pred(*chit))
251 {
252 chit = remove_change_nts(chit);
253 }
254 else
255 {
256 ++chit;
257 }
258 }
259 }
260
262 RTPSReader* mp_reader;
263
264};
265
266} // namespace rtps
267} // namespace fastdds
268} // namespace eprosima
269
270#endif // FASTDDS_RTPS_HISTORY__READERHISTORY_HPP
eprosima::fastdds::rtps::HistoryAttributes
Class HistoryAttributes, to specify the attributes of a WriterHistory or a ReaderHistory.
Definition HistoryAttributes.hpp:39
eprosima::fastdds::rtps::History::iterator
std::vector< CacheChange_t * >::iterator iterator
Definition History.hpp:58
eprosima::fastdds::rtps::History::remove_change
FASTDDS_EXPORTED_API bool remove_change(CacheChange_t *ch)
Remove a specific change from the history.
eprosima::fastdds::rtps::History::const_iterator
std::vector< CacheChange_t * >::const_iterator const_iterator
Definition History.hpp:60
eprosima::fastdds::rtps::History::mp_mutex
RecursiveTimedMutex * mp_mutex
Mutex for the History.
Definition History.hpp:269
eprosima::fastdds::rtps::History::History
History(const HistoryAttributes &att)
eprosima::fastdds::rtps::History::m_changes
std::vector< CacheChange_t * > m_changes
Vector of pointers to the CacheChange_t.
Definition History.hpp:263
eprosima::fastdds::rtps::RTPSReader
Class RTPSReader, manages the reception of data from its matched writers.
Definition RTPSReader.hpp:54
eprosima::fastdds::rtps::ReaderHistory::ReaderHistory
FASTDDS_EXPORTED_API ReaderHistory(const HistoryAttributes &att)
Constructor of the ReaderHistory.
eprosima::fastdds::rtps::ReaderHistory::remove_change_nts
FASTDDS_EXPORTED_API iterator remove_change_nts(const_iterator removal, const std::chrono::time_point< std::chrono::steady_clock > &max_blocking_time, bool release=true) override
Remove a specific change from the history.
eprosima::fastdds::rtps::ReaderHistory::completed_change
FASTDDS_EXPORTED_API virtual bool completed_change(rtps::CacheChange_t *change)
Called when a fragmented change is received completely by the Subscriber.
Definition ReaderHistory.hpp:114
eprosima::fastdds::rtps::ReaderHistory::writer_update_its_ownership_strength_nts
virtual FASTDDS_EXPORTED_API void writer_update_its_ownership_strength_nts(const GUID_t &writer_guid, const uint32_t ownership_strength)
This function should be called by reader if a writer updates its ownership strength.
Definition ReaderHistory.hpp:226
eprosima::fastdds::rtps::ReaderHistory::received_change
virtual FASTDDS_EXPORTED_API bool received_change(CacheChange_t *change, size_t unknown_missing_changes_up_to, fastdds::dds::SampleRejectedStatusKind &rejection_reason)
Virtual method that is called when a new change is received.
Definition ReaderHistory.hpp:99
eprosima::fastdds::rtps::ReaderHistory::add_change
FASTDDS_EXPORTED_API bool add_change(CacheChange_t *a_change)
Add a CacheChange_t to the ReaderHistory.
eprosima::fastdds::rtps::ReaderHistory::get_min_change_from
FASTDDS_EXPORTED_API bool get_min_change_from(CacheChange_t **min_change, const GUID_t &writerGuid)
eprosima::fastdds::rtps::ReaderHistory::remove_change_nts
FASTDDS_EXPORTED_API iterator remove_change_nts(const_iterator removal, bool release=true) override
Remove a specific change from the history.
eprosima::fastdds::rtps::ReaderHistory::matches_change
FASTDDS_EXPORTED_API bool matches_change(const CacheChange_t *inner, CacheChange_t *outer) override
Criteria to search a specific CacheChange_t on history.
eprosima::fastdds::rtps::ReaderHistory::do_release_cache
FASTDDS_EXPORTED_API void do_release_cache(CacheChange_t *ch) override
eprosima::fastdds::rtps::ReaderHistory::writer_unmatched
virtual FASTDDS_EXPORTED_API void writer_unmatched(const GUID_t &writer_guid, const SequenceNumber_t &last_notified_seq)
Called when a writer is unmatched from the reader holding this history.
eprosima::fastdds::rtps::ReaderHistory::remove_changes_with_guid
FASTDDS_EXPORTED_API bool remove_changes_with_guid(const GUID_t &a_guid)
Remove all changes from the History that have a certain guid.
eprosima::fastdds::rtps::ReaderHistory::remove_changes_with_pred
void remove_changes_with_pred(Pred pred)
Definition ReaderHistory.hpp:240
eprosima::fastdds::rtps::ReaderHistory::mp_reader
RTPSReader * mp_reader
Pointer to the reader.
Definition ReaderHistory.hpp:262
eprosima::fastdds::rtps::ReaderHistory::received_change
virtual FASTDDS_EXPORTED_API bool received_change(CacheChange_t *change, size_t unknown_missing_changes_up_to)
Virtual method that is called when a new change is received.
eprosima::fastdds::rtps::ReaderHistory::remove_fragmented_changes_until
bool remove_fragmented_changes_until(const SequenceNumber_t &seq_num, const GUID_t &writer_guid)
Remove all fragmented changes from certain writer up to certain sequence number.
eprosima::fastdds::rtps::ReaderHistory::RTPSReader
friend class RTPSReader
Definition ReaderHistory.hpp:40
eprosima::fastdds::rtps::ReaderHistory::completed_change
virtual FASTDDS_EXPORTED_API bool completed_change(CacheChange_t *change, size_t unknown_missing_changes_up_to, fastdds::dds::SampleRejectedStatusKind &rejection_reason)
Called when a fragmented change is received completely by the Subscriber.
Definition ReaderHistory.hpp:129
eprosima::fastdds::rtps::ReaderHistory::~ReaderHistory
FASTDDS_EXPORTED_API ~ReaderHistory() override
eprosima::fastdds::rtps::ReaderHistory::can_change_be_added_nts
virtual FASTDDS_EXPORTED_API bool can_change_be_added_nts(const GUID_t &writer_guid, uint32_t total_payload_size, size_t unknown_missing_changes_up_to, bool &will_never_be_accepted) const
Check if a new change can be added to this history.
eprosima::fastdds::dds::SampleRejectedStatusKind
SampleRejectedStatusKind
An enum with the possible values for the sample rejected reason.
Definition SampleRejectedStatus.hpp:32
eprosima::fastdds::dds::NOT_REJECTED
@ NOT_REJECTED
Default value.
Definition SampleRejectedStatus.hpp:34
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::CacheChange_t
Structure CacheChange_t, contains information on a specific CacheChange.
Definition CacheChange.hpp:78
eprosima::fastdds::rtps::GUID_t
Structure GUID_t, entity identifier, unique in DDS-RTPS Domain.
Definition Guid.hpp:40
eprosima::fastdds::rtps::SequenceNumber_t
Structure SequenceNumber_t, different for each change in the same writer.
Definition SequenceNumber.hpp:38