Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
SubscriberHistory.h
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
20#ifndef SUBSCRIBERHISTORY_H_
21#define SUBSCRIBERHISTORY_H_
22#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
23
24#include <fastdds/dds/topic/TopicDataType.hpp>
25#include <fastdds/rtps/resources/ResourceManagement.h>
26#include <fastrtps/qos/ReaderQos.h>
27#include <fastdds/rtps/history/ReaderHistory.h>
28#include <fastrtps/qos/QosPolicies.h>
29#include <fastrtps/common/KeyedChanges.h>
30#include <fastrtps/subscriber/SampleInfo.h>
31#include <fastrtps/attributes/TopicAttributes.h>
32
33#include <chrono>
34#include <functional>
35
36namespace eprosima {
37namespace fastrtps {
38
43class SubscriberHistory : public rtps::ReaderHistory
44{
45public:
46
56 const TopicAttributes& topic_att,
57 fastdds::dds::TopicDataType* type,
58 const fastrtps::ReaderQos& qos,
59 uint32_t payloadMax,
60 rtps::MemoryManagementPolicy_t mempolicy);
61
63
72 const_iterator removal,
73 bool release = true) override;
74
90 const rtps::GUID_t& writer_guid,
91 uint32_t total_payload_size,
92 size_t unknown_missing_changes_up_to,
93 bool& will_never_be_accepted) const override;
94
103 rtps::CacheChange_t* change,
104 size_t unknown_missing_changes_up_to) override;
105
113 rtps::CacheChange_t* change) override;
114
124 void* data,
125 SampleInfo_t* info,
126 std::chrono::steady_clock::time_point& max_blocking_time);
127
129 void* data,
130 SampleInfo_t* info,
131 std::chrono::steady_clock::time_point& max_blocking_time);
133
140 SampleInfo_t* info);
141
148 rtps::CacheChange_t* change);
149
157 rtps::CacheChange_t* change,
158 iterator& it);
159
167 const rtps::InstanceHandle_t& handle,
168 const std::chrono::steady_clock::time_point& next_deadline_us);
169
177 rtps::InstanceHandle_t& handle,
178 std::chrono::steady_clock::time_point& next_deadline_us);
179
180private:
181
182 using rtps::ReaderHistory::completed_change;
183 using rtps::ReaderHistory::received_change;
184 using rtps::ReaderHistory::remove_change_nts;
185
186 using t_m_Inst_Caches = std::map<rtps::InstanceHandle_t, KeyedChanges>;
187
189 t_m_Inst_Caches keyed_changes_;
191 std::chrono::steady_clock::time_point next_deadline_us_;
193 HistoryQosPolicy history_qos_;
195 ResourceLimitsQosPolicy resource_limited_qos_;
197 TopicAttributes topic_att_;
199 fastdds::dds::TopicDataType* type_;
202
204 void* get_key_object_;
205
207 std::function<bool(rtps::CacheChange_t*, size_t)> receive_fn_;
208
210 std::function<bool(rtps::CacheChange_t*)> complete_fn_;
211
218 bool find_key(
219 rtps::CacheChange_t* a_change,
220 t_m_Inst_Caches::iterator& map_it);
221
228 bool find_key_for_change(
229 rtps::CacheChange_t* a_change,
230 t_m_Inst_Caches::iterator& map_it);
231
240 bool received_change_keep_all_no_key(
241 rtps::CacheChange_t* change,
242 size_t unknown_missing_changes_up_to);
243
244 bool received_change_keep_last_no_key(
245 rtps::CacheChange_t* change,
246 size_t unknown_missing_changes_up_to);
247
248 bool received_change_keep_all_with_key(
249 rtps::CacheChange_t* change,
250 size_t unknown_missing_changes_up_to);
251
252 bool received_change_keep_last_with_key(
253 rtps::CacheChange_t* change,
254 size_t unknown_missing_changes_up_to);
255
256 bool completed_change_keep_all_with_key(
257 rtps::CacheChange_t* change);
258
259 bool completed_change_keep_last_with_key(
260 rtps::CacheChange_t* change);
262
263 bool add_received_change(
264 rtps::CacheChange_t* a_change);
265
266 bool add_received_change_with_key(
267 rtps::CacheChange_t* a_change,
268 std::vector<rtps::CacheChange_t*>& instance_changes);
269
270 bool deserialize_change(
271 rtps::CacheChange_t* change,
272 uint32_t ownership_strength,
273 void* data,
274 SampleInfo_t* info);
275};
276
277} // namespace fastrtps
278} // namespace eprosima
279
280#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
281
282#endif /* SUBSCRIBERHISTORY_H_ */
Class SampleInfo_t with information that is provided along a sample when reading data from a Subscrib...
Definition SampleInfo.h:39
Class SubscriberHistory, container of the different CacheChanges of a subscriber.
Definition SubscriberHistory.h:44
bool received_change(rtps::CacheChange_t *change, size_t unknown_missing_changes_up_to) override
Called when a change is received by the Subscriber.
bool remove_change_sub(rtps::CacheChange_t *change)
This method is called to remove a change from the SubscriberHistory.
bool get_first_untaken_info(SampleInfo_t *info)
Returns information about the first untaken sample.
bool remove_change_sub(rtps::CacheChange_t *change, iterator &it)
This method is called to remove a change from the SubscriberHistory.
bool readNextData(void *data, SampleInfo_t *info, std::chrono::steady_clock::time_point &max_blocking_time)
bool get_next_deadline(rtps::InstanceHandle_t &handle, std::chrono::steady_clock::time_point &next_deadline_us)
A method to get the next instance handle that will miss the deadline and the time when the deadline w...
bool can_change_be_added_nts(const rtps::GUID_t &writer_guid, uint32_t total_payload_size, size_t unknown_missing_changes_up_to, bool &will_never_be_accepted) const override
Check if a new change can be added to this history.
bool completed_change(rtps::CacheChange_t *change) override
Called when a fragmented change is received completely by the Subscriber.
SubscriberHistory(const TopicAttributes &topic_att, fastdds::dds::TopicDataType *type, const fastrtps::ReaderQos &qos, uint32_t payloadMax, rtps::MemoryManagementPolicy_t mempolicy)
Constructor.
bool takeNextData(void *data, SampleInfo_t *info, std::chrono::steady_clock::time_point &max_blocking_time)
bool set_next_deadline(const rtps::InstanceHandle_t &handle, const std::chrono::steady_clock::time_point &next_deadline_us)
A method to set the next deadline for the given instance.
iterator remove_change_nts(const_iterator removal, bool release=true) override
Remove a specific change from the history.
Class TopicAttributes, used by the user to define the attributes of the topic associated with a Publi...
Definition TopicAttributes.h:36
fastdds::dds::ReaderQos ReaderQos
Definition ReaderQos.h:30
fastdds::dds::ResourceLimitsQosPolicy ResourceLimitsQosPolicy
Definition QosPolicies.h:81
fastdds::dds::HistoryQosPolicy HistoryQosPolicy
Definition QosPolicies.h:80
eProsima namespace.
Definition LibrarySettingsAttributes.h:23