Fast RTPS  Version 2.1.0
Fast RTPS
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 
36 namespace eprosima {
37 namespace fastrtps {
38 
43 class SubscriberHistory : public rtps::ReaderHistory
44 {
45 public:
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 
62  virtual ~SubscriberHistory();
63 
72  rtps::CacheChange_t* change,
73  size_t unknown_missing_changes_up_to);
74 
84  void* data,
85  SampleInfo_t* info,
86  std::chrono::steady_clock::time_point& max_blocking_time);
87 
89  void* data,
90  SampleInfo_t* info,
91  std::chrono::steady_clock::time_point& max_blocking_time);
93 
100  SampleInfo_t* info);
101 
108  rtps::CacheChange_t* change);
109 
117  const rtps::InstanceHandle_t& handle,
118  const std::chrono::steady_clock::time_point& next_deadline_us);
119 
127  rtps::InstanceHandle_t& handle,
128  std::chrono::steady_clock::time_point& next_deadline_us);
129 
130 private:
131 
132  using t_m_Inst_Caches = std::map<rtps::InstanceHandle_t, KeyedChanges>;
133 
135  t_m_Inst_Caches keyed_changes_;
137  std::chrono::steady_clock::time_point next_deadline_us_;
139  HistoryQosPolicy history_qos_;
141  ResourceLimitsQosPolicy resource_limited_qos_;
143  TopicAttributes topic_att_;
145  fastdds::dds::TopicDataType* type_;
147  fastrtps::ReaderQos qos_;
148 
150  void* get_key_object_;
151 
153  std::function<bool(rtps::CacheChange_t*, size_t)> receive_fn_;
154 
161  bool find_key(
162  rtps::CacheChange_t* a_change,
163  t_m_Inst_Caches::iterator* map_it);
164 
171  bool find_key_for_change(
172  rtps::CacheChange_t* a_change,
173  t_m_Inst_Caches::iterator& map_it);
174 
183  bool received_change_keep_all_no_key(
184  rtps::CacheChange_t* change,
185  size_t unknown_missing_changes_up_to);
186 
187  bool received_change_keep_last_no_key(
188  rtps::CacheChange_t* change,
189  size_t unknown_missing_changes_up_to);
190 
191  bool received_change_keep_all_with_key(
192  rtps::CacheChange_t* change,
193  size_t unknown_missing_changes_up_to);
194 
195  bool received_change_keep_last_with_key(
196  rtps::CacheChange_t* change,
197  size_t unknown_missing_changes_up_to);
199 
200  bool add_received_change(
201  rtps::CacheChange_t* a_change);
202 
203  bool add_received_change_with_key(
204  rtps::CacheChange_t* a_change,
205  std::vector<rtps::CacheChange_t*>& instance_changes);
206 
207  bool deserialize_change(
208  rtps::CacheChange_t* change,
209  uint32_t ownership_strength,
210  void* data,
211  SampleInfo_t* info);
212 };
213 
214 } // namespace fastrtps
215 } // namespace eprosima
216 
217 #endif
218 
219 #endif /* SUBSCRIBERHISTORY_H_ */
Class SampleInfo_t with information that is provided along a sample when reading data from a Subscrib...
Definition: SampleInfo.h:38
Class SubscriberHistory, container of the different CacheChanges of a subscriber.
Definition: SubscriberHistory.h:44
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 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...
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.
bool received_change(rtps::CacheChange_t *change, size_t unknown_missing_changes_up_to)
Called when a change is received by the Subscriber.
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