Fast RTPS  Version 2.5.1
Fast RTPS
PublisherHistory.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 PUBLISHERHISTORY_H_
21 #define PUBLISHERHISTORY_H_
22 #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
23 
24 #include <chrono>
25 #include <mutex>
26 
27 #include <fastdds/rtps/common/InstanceHandle.h>
28 #include <fastdds/rtps/common/Time_t.h>
29 #include <fastdds/rtps/history/WriterHistory.h>
30 #include <fastdds/rtps/resources/ResourceManagement.h>
31 #include <fastrtps/attributes/TopicAttributes.h>
32 #include <fastrtps/common/KeyedChanges.h>
33 #include <fastrtps/qos/QosPolicies.h>
34 
35 namespace eprosima {
36 namespace fastrtps {
37 
43 class PublisherHistory : public rtps::WriterHistory
44 {
45 public:
46 
54  const TopicAttributes& topic_att,
55  uint32_t payloadMax,
56  rtps::MemoryManagementPolicy_t mempolicy);
57 
58  virtual ~PublisherHistory();
59 
64 
73  const rtps::InstanceHandle_t& instance_handle,
74  std::unique_lock<RecursiveTimedMutex>& lock,
75  const std::chrono::time_point<std::chrono::steady_clock>& max_blocking_time);
76 
86  rtps::CacheChange_t* change,
87  rtps::WriteParams& wparams,
88  std::unique_lock<RecursiveTimedMutex>& lock,
89  const std::chrono::time_point<std::chrono::steady_clock>& max_blocking_time);
90 
97  size_t* removed);
98 
104 
111  rtps::CacheChange_t* change);
112 
113  virtual bool remove_change_g(
114  rtps::CacheChange_t* a_change);
115 
117  const rtps::InstanceHandle_t& handle,
118  const rtps::SequenceNumber_t& seq_up_to);
119 
127  const rtps::InstanceHandle_t& handle,
128  const std::chrono::steady_clock::time_point& next_deadline_us);
129 
137  rtps::InstanceHandle_t& handle,
138  std::chrono::steady_clock::time_point& next_deadline_us);
139 
146  const rtps::InstanceHandle_t& handle);
147 
156  const rtps::InstanceHandle_t& handle,
157  std::unique_lock<RecursiveTimedMutex>& lock,
158  const std::chrono::time_point<std::chrono::steady_clock>& max_blocking_time);
159 
160 private:
161 
162  typedef std::map<rtps::InstanceHandle_t, KeyedChanges> t_m_Inst_Caches;
163 
165  t_m_Inst_Caches keyed_changes_;
167  std::chrono::steady_clock::time_point next_deadline_us_;
169  HistoryQosPolicy history_qos_;
171  ResourceLimitsQosPolicy resource_limited_qos_;
173  TopicAttributes topic_att_;
174 
181  bool find_or_add_key(
182  const rtps::InstanceHandle_t& instance_handle,
183  t_m_Inst_Caches::iterator* map_it);
184 };
185 
186 } /* namespace fastrtps */
187 } /* namespace eprosima */
188 
189 #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
190 #endif // PUBLISHERHISTORY_H_
Class PublisherHistory, implementing a WriterHistory with support for keyed topics and HistoryQOS.
Definition: PublisherHistory.h:44
bool removeAllChange(size_t *removed)
Remove all change from the associated history.
bool wait_for_acknowledgement_last_change(const rtps::InstanceHandle_t &handle, std::unique_lock< RecursiveTimedMutex > &lock, const std::chrono::time_point< std::chrono::steady_clock > &max_blocking_time)
Waits till the last change in the instance history has been acknowledged.
bool remove_instance_changes(const rtps::InstanceHandle_t &handle, const rtps::SequenceNumber_t &seq_up_to)
void rebuild_instances()
Rebuild instances loaded from DB.
bool removeMinChange()
Remove the change with the minimum sequence Number.
virtual bool remove_change_g(rtps::CacheChange_t *a_change)
bool add_pub_change(rtps::CacheChange_t *change, rtps::WriteParams &wparams, std::unique_lock< RecursiveTimedMutex > &lock, const std::chrono::time_point< std::chrono::steady_clock > &max_blocking_time)
Add a change comming from the Publisher.
bool get_next_deadline(rtps::InstanceHandle_t &handle, std::chrono::steady_clock::time_point &next_deadline_us)
Returns the deadline for the instance that is next going to 'expire'.
PublisherHistory(const TopicAttributes &topic_att, uint32_t payloadMax, rtps::MemoryManagementPolicy_t mempolicy)
Constructor of the PublisherHistory.
bool is_key_registered(const rtps::InstanceHandle_t &handle)
Checks if the instance's key is registered.
bool remove_change_pub(rtps::CacheChange_t *change)
Remove a change by the publisher History.
bool register_instance(const rtps::InstanceHandle_t &instance_handle, std::unique_lock< RecursiveTimedMutex > &lock, const std::chrono::time_point< std::chrono::steady_clock > &max_blocking_time)
Tries to reserve resources for the new instance.
bool set_next_deadline(const rtps::InstanceHandle_t &handle, const std::chrono::steady_clock::time_point &next_deadline_us)
Sets the next deadline for the given instance.
Class TopicAttributes, used by the user to define the attributes of the topic associated with a Publi...
Definition: TopicAttributes.h:36
fastdds::dds::ResourceLimitsQosPolicy ResourceLimitsQosPolicy
Definition: QosPolicies.h:81
fastdds::dds::HistoryQosPolicy HistoryQosPolicy
Definition: QosPolicies.h:80
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23