/src/Fast-DDS/src/cpp/fastdds/publisher/qos/WriterQos.cpp
Line | Count | Source |
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 | | |
15 | | /** |
16 | | * @file WriterQos.cpp |
17 | | * |
18 | | */ |
19 | | |
20 | | #include <fastdds/dds/publisher/qos/WriterQos.hpp> |
21 | | #include <fastdds/dds/log/Log.hpp> |
22 | | |
23 | | using namespace eprosima::fastdds::rtps; |
24 | | |
25 | | namespace eprosima { |
26 | | namespace fastdds { |
27 | | namespace dds { |
28 | | |
29 | | //FASTDDS_EXPORTED_API const WriterQos DATAWRITER_QOS_DEFAULT; |
30 | | |
31 | | WriterQos::WriterQos() |
32 | 70.1k | { |
33 | 70.1k | m_reliability.kind = RELIABLE_RELIABILITY_QOS; |
34 | 70.1k | m_durability.kind = TRANSIENT_LOCAL_DURABILITY_QOS; |
35 | 70.1k | } |
36 | | |
37 | | WriterQos::~WriterQos() |
38 | 68.1k | { |
39 | 68.1k | } |
40 | | |
41 | | void WriterQos::setQos( |
42 | | const WriterQos& qos, |
43 | | bool first_time) |
44 | 0 | { |
45 | 0 | if (first_time) |
46 | 0 | { |
47 | 0 | m_durability = qos.m_durability; |
48 | 0 | } |
49 | 0 | if (first_time || m_deadline.period != qos.m_deadline.period) |
50 | 0 | { |
51 | 0 | m_deadline = qos.m_deadline; |
52 | 0 | } |
53 | 0 | if (m_latencyBudget.duration != qos.m_latencyBudget.duration) |
54 | 0 | { |
55 | 0 | m_latencyBudget = qos.m_latencyBudget; |
56 | 0 | } |
57 | 0 | if (first_time) |
58 | 0 | { |
59 | 0 | m_liveliness = qos.m_liveliness; |
60 | 0 | } |
61 | 0 | if (first_time) |
62 | 0 | { |
63 | 0 | m_reliability = qos.m_reliability; |
64 | 0 | } |
65 | 0 | if (first_time) |
66 | 0 | { |
67 | 0 | m_ownership = qos.m_ownership; |
68 | 0 | } |
69 | 0 | if (m_destinationOrder.kind != qos.m_destinationOrder.kind) |
70 | 0 | { |
71 | 0 | m_destinationOrder = qos.m_destinationOrder; |
72 | 0 | } |
73 | 0 | if (first_time || m_userData.data_vec() != qos.m_userData.data_vec()) |
74 | 0 | { |
75 | 0 | m_userData = qos.m_userData; |
76 | 0 | } |
77 | 0 | if (first_time || m_timeBasedFilter.minimum_separation != qos.m_timeBasedFilter.minimum_separation) |
78 | 0 | { |
79 | 0 | m_timeBasedFilter = qos.m_timeBasedFilter; |
80 | 0 | } |
81 | 0 | if (first_time || m_presentation.access_scope != qos.m_presentation.access_scope || |
82 | 0 | m_presentation.coherent_access != qos.m_presentation.coherent_access || |
83 | 0 | m_presentation.ordered_access != qos.m_presentation.ordered_access) |
84 | 0 | { |
85 | 0 | m_presentation = qos.m_presentation; |
86 | 0 | } |
87 | 0 | if (first_time || qos.m_partition.names() != m_partition.names()) |
88 | 0 | { |
89 | 0 | m_partition = qos.m_partition; |
90 | 0 | } |
91 | |
|
92 | 0 | if (first_time || m_topicData.getValue() != qos.m_topicData.getValue()) |
93 | 0 | { |
94 | 0 | m_topicData = qos.m_topicData; |
95 | 0 | } |
96 | 0 | if (first_time || m_groupData.getValue() != qos.m_groupData.getValue()) |
97 | 0 | { |
98 | 0 | m_groupData = qos.m_groupData; |
99 | 0 | } |
100 | 0 | if (first_time || m_durabilityService.history_kind != qos.m_durabilityService.history_kind || |
101 | 0 | m_durabilityService.history_depth != qos.m_durabilityService.history_depth || |
102 | 0 | m_durabilityService.max_instances != qos.m_durabilityService.max_instances || |
103 | 0 | m_durabilityService.max_samples != qos.m_durabilityService.max_samples || |
104 | 0 | m_durabilityService.max_samples_per_instance != qos.m_durabilityService.max_samples_per_instance || |
105 | 0 | m_durabilityService.service_cleanup_delay != qos.m_durabilityService.service_cleanup_delay |
106 | 0 | ) |
107 | 0 | { |
108 | 0 | m_durabilityService = qos.m_durabilityService; |
109 | 0 | } |
110 | 0 | if (m_lifespan.duration != qos.m_lifespan.duration) |
111 | 0 | { |
112 | 0 | m_lifespan = qos.m_lifespan; |
113 | 0 | } |
114 | 0 | if (qos.m_ownershipStrength.value != m_ownershipStrength.value) |
115 | 0 | { |
116 | 0 | m_ownershipStrength = qos.m_ownershipStrength; |
117 | 0 | } |
118 | 0 | if (first_time) |
119 | 0 | { |
120 | 0 | m_disablePositiveACKs = qos.m_disablePositiveACKs; |
121 | 0 | } |
122 | | // Writers only manages the first element in the list of data representations. |
123 | 0 | if (qos.representation.m_value.size() != representation.m_value.size() || |
124 | 0 | (qos.representation.m_value.size() > 0 && representation.m_value.size() > 0 && |
125 | 0 | *qos.representation.m_value.begin() != *representation.m_value.begin())) |
126 | 0 | { |
127 | 0 | representation = qos.representation; |
128 | 0 | } |
129 | 0 | if (first_time && !(data_sharing == qos.data_sharing)) |
130 | 0 | { |
131 | 0 | data_sharing = qos.data_sharing; |
132 | 0 | } |
133 | 0 | } |
134 | | |
135 | | bool WriterQos::checkQos() const |
136 | 0 | { |
137 | 0 | if (m_durability.kind == PERSISTENT_DURABILITY_QOS) |
138 | 0 | { |
139 | 0 | EPROSIMA_LOG_ERROR(RTPS_QOS_CHECK, "PERSISTENT Durability not supported"); |
140 | 0 | return false; |
141 | 0 | } |
142 | 0 | if (m_destinationOrder.kind == BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS) |
143 | 0 | { |
144 | 0 | EPROSIMA_LOG_ERROR(RTPS_QOS_CHECK, "BY SOURCE TIMESTAMP DestinationOrder not supported"); |
145 | 0 | return false; |
146 | 0 | } |
147 | 0 | if (m_liveliness.kind == AUTOMATIC_LIVELINESS_QOS || m_liveliness.kind == MANUAL_BY_PARTICIPANT_LIVELINESS_QOS) |
148 | 0 | { |
149 | 0 | if (m_liveliness.lease_duration < dds::c_TimeInfinite && |
150 | 0 | m_liveliness.lease_duration <= m_liveliness.announcement_period) |
151 | 0 | { |
152 | 0 | EPROSIMA_LOG_ERROR(RTPS_QOS_CHECK, "WRITERQOS: LeaseDuration <= announcement period."); |
153 | 0 | return false; |
154 | 0 | } |
155 | 0 | } |
156 | 0 | return true; |
157 | 0 | } |
158 | | |
159 | | bool WriterQos::canQosBeUpdated( |
160 | | const WriterQos& qos) const |
161 | 0 | { |
162 | 0 | bool updatable = true; |
163 | 0 | if ( m_durability.kind != qos.m_durability.kind) |
164 | 0 | { |
165 | 0 | updatable = false; |
166 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "Durability kind cannot be changed after the creation of a publisher."); |
167 | 0 | } |
168 | |
|
169 | 0 | if (m_liveliness.kind != qos.m_liveliness.kind) |
170 | 0 | { |
171 | 0 | updatable = false; |
172 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "Liveliness Kind cannot be changed after the creation of a publisher."); |
173 | 0 | } |
174 | |
|
175 | 0 | if (m_liveliness.lease_duration != qos.m_liveliness.lease_duration) |
176 | 0 | { |
177 | 0 | updatable = false; |
178 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, |
179 | 0 | "Liveliness lease duration cannot be changed after the creation of a publisher."); |
180 | 0 | } |
181 | |
|
182 | 0 | if (m_liveliness.announcement_period != qos.m_liveliness.announcement_period) |
183 | 0 | { |
184 | 0 | updatable = false; |
185 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, |
186 | 0 | "Liveliness announcement cannot be changed after the creation of a publisher."); |
187 | 0 | } |
188 | |
|
189 | 0 | if (m_reliability.kind != qos.m_reliability.kind) |
190 | 0 | { |
191 | 0 | updatable = false; |
192 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "Reliability Kind cannot be changed after the creation of a publisher."); |
193 | 0 | } |
194 | 0 | if (m_ownership.kind != qos.m_ownership.kind) |
195 | 0 | { |
196 | 0 | updatable = false; |
197 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "Ownership Kind cannot be changed after the creation of a publisher."); |
198 | 0 | } |
199 | 0 | if (m_destinationOrder.kind != qos.m_destinationOrder.kind) |
200 | 0 | { |
201 | 0 | updatable = false; |
202 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, |
203 | 0 | "Destination order Kind cannot be changed after the creation of a publisher."); |
204 | 0 | } |
205 | 0 | if (data_sharing.kind() != qos.data_sharing.kind() || |
206 | 0 | data_sharing.domain_ids() != qos.data_sharing.domain_ids()) |
207 | 0 | { |
208 | 0 | updatable = false; |
209 | 0 | EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, |
210 | 0 | "Data sharing configuration cannot be changed after the creation of a publisher."); |
211 | 0 | } |
212 | 0 | return updatable; |
213 | 0 | } |
214 | | |
215 | | void WriterQos::clear() |
216 | 0 | { |
217 | 0 | m_durability.clear(); |
218 | 0 | m_deadline.clear(); |
219 | 0 | m_latencyBudget.clear(); |
220 | 0 | m_liveliness.clear(); |
221 | 0 | m_reliability.clear(); |
222 | 0 | m_ownership.clear(); |
223 | 0 | m_destinationOrder.clear(); |
224 | 0 | m_userData.clear(); |
225 | 0 | m_timeBasedFilter.clear(); |
226 | 0 | m_presentation.clear(); |
227 | 0 | m_partition.clear(); |
228 | 0 | m_topicData.clear(); |
229 | 0 | m_groupData.clear(); |
230 | 0 | m_durabilityService.clear(); |
231 | 0 | m_lifespan.clear(); |
232 | 0 | m_disablePositiveACKs.clear(); |
233 | 0 | m_ownershipStrength.clear(); |
234 | 0 | m_publishMode.clear(); |
235 | 0 | representation.clear(); |
236 | 0 | data_sharing.clear(); |
237 | |
|
238 | 0 | m_reliability.kind = RELIABLE_RELIABILITY_QOS; |
239 | 0 | } |
240 | | |
241 | | } //namespace dds |
242 | | } //namespace fastdds |
243 | | } //namespace eprosima |