OpenDDS  Snapshot(2023/04/28-20:55)
Qos_Helper.cpp
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
9 
10 #include "Qos_Helper.h"
11 #if !defined (__ACE_INLINE__)
12 #include "Qos_Helper.inl"
13 #endif /* __ACE_INLINE__ */
14 
15 #include "debug.h"
16 #include "DCPS_Utils.h"
17 
19 
20 namespace OpenDDS {
21 namespace DCPS {
22 
24 {
25  if (!valid(qos.user_data)) {
26  if (log_level >= LogLevel::Notice) {
28  "(%P|%t) NOTICE: Qos_Helper::valid::DomainParticipantQos, invalid user_data qos.\n"));
29  }
30  return false;
31  }
32 
33  if (!valid(qos.entity_factory)) {
34  if (log_level >= LogLevel::Notice) {
36  "(%P|%t) NOTICE: Qos_Helper::valid::DomainParticipantQos, invalid entity_factory qos.\n"));
37  }
38  return false;
39  }
40 
41  if (!valid(qos.property)) {
42  if (log_level >= LogLevel::Notice) {
44  "(%P|%t) NOTICE: Qos_Helper::valid::DomainParticipantQos, invalid property qos.\n"));
45  }
46  return false;
47  }
48 
49  return true;
50 }
51 
53 {
54  if (!valid(qos.topic_data)) {
55  if (log_level >= LogLevel::Notice) {
57  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid topic_data qos.\n"));
58  }
59  return false;
60  }
61 
62  if (!valid(qos.durability)) {
63  if (log_level >= LogLevel::Notice) {
65  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid durability qos.\n"));
66  }
67  return false;
68  }
69 
70 #ifndef OPENDDS_NO_PERSISTENCE_PROFILE
71  if (!valid(qos.durability_service)) {
72  if (log_level >= LogLevel::Notice) {
74  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid durability_service qos.\n"));
75  }
76  return false;
77  }
78 #endif
79 
80  if (!valid(qos.deadline)) {
81  if (log_level >= LogLevel::Notice) {
83  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid deadline qos.\n"));
84  }
85  return false;
86  }
87 
88  if (!valid(qos.latency_budget)) {
89  if (log_level >= LogLevel::Notice) {
91  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid latency_budget qos.\n"));
92  }
93  return false;
94  }
95 
96  if (!valid(qos.liveliness)) {
97  if (log_level >= LogLevel::Notice) {
99  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid liveliness qos.\n"));
100  }
101  return false;
102  }
103 
104  if (!valid(qos.destination_order)) {
105  if (log_level >= LogLevel::Notice) {
107  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid destination_order qos.\n"));
108  }
109  return false;
110  }
111 
112  if (!valid(qos.history)) {
113  if (log_level >= LogLevel::Notice) {
115  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid history qos.\n"));
116  }
117  return false;
118  }
119 
120  if (!valid(qos.resource_limits)) {
121  if (log_level >= LogLevel::Notice) {
123  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid resource_limits qos.\n"));
124  }
125  return false;
126  }
127 
128  if (!valid(qos.transport_priority)) {
129  if (log_level >= LogLevel::Notice) {
131  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid transport_priority qos.\n"));
132  }
133  return false;
134  }
135 
136  if (!valid(qos.lifespan)) {
137  if (log_level >= LogLevel::Notice) {
139  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid lifespan qos.\n"));
140  }
141  return false;
142  }
143 
144  if (!valid(qos.ownership)) {
145  if (log_level >= LogLevel::Notice) {
147  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid ownership qos.\n"));
148  }
149  return false;
150  }
151 
152  if (!valid(qos.representation)) {
153  if (log_level >= LogLevel::Notice) {
155  "(%P|%t) NOTICE: Qos_Helper::valid::TopicQos, invalid representation qos.\n"));
156  }
157  return false;
158  }
159 
160  return true;
161 }
162 
164 {
165  if (!valid(qos.durability)) {
166  if (log_level >= LogLevel::Notice) {
168  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid durability qos.\n"));
169  }
170  return false;
171  }
172 
173 #ifndef OPENDDS_NO_PERSISTENCE_PROFILE
174  if (!valid(qos.durability_service)) {
175  if (log_level >= LogLevel::Notice) {
177  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid durability_service qos.\n"));
178  }
179  return false;
180  }
181 #endif
182 
183  if (!valid(qos.deadline)) {
184  if (log_level >= LogLevel::Notice) {
186  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid deadline qos.\n"));
187  }
188  return false;
189  }
190 
191  if (!valid(qos.latency_budget)) {
192  if (log_level >= LogLevel::Notice) {
194  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid latency_budget qos.\n"));
195  }
196  return false;
197  }
198 
199  if (!valid(qos.liveliness)) {
200  if (log_level >= LogLevel::Notice) {
202  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid liveliness qos.\n"));
203  }
204  return false;
205  }
206 
207  if (!valid(qos.destination_order)) {
208  if (log_level >= LogLevel::Notice) {
210  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid destination_order qos.\n"));
211  }
212  return false;
213  }
214 
215  if (!valid(qos.history)) {
216  if (log_level >= LogLevel::Notice) {
218  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid history qos.\n"));
219  }
220  return false;
221  }
222 
223  if (!valid(qos.resource_limits)) {
224  if (log_level >= LogLevel::Notice) {
226  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid resource_limits qos.\n"));
227  }
228  return false;
229  }
230 
231  if (!valid(qos.transport_priority)) {
232  if (log_level >= LogLevel::Notice) {
234  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid transport_priority qos.\n"));
235  }
236  return false;
237  }
238 
239  if (!valid(qos.lifespan)) {
240  if (log_level >= LogLevel::Notice) {
242  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid lifespan qos.\n"));
243  }
244  return false;
245  }
246 
247  if (!valid(qos.user_data)) {
248  if (log_level >= LogLevel::Notice) {
250  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid user_data qos.\n"));
251  }
252  return false;
253  }
254 
255  if (!valid(qos.ownership)) {
256  if (log_level >= LogLevel::Notice) {
258  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid ownership qos.\n"));
259  }
260  return false;
261  }
262 
263 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
264  if (!valid(qos.ownership_strength)) {
265  if (log_level >= LogLevel::Notice) {
267  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid ownership_strength qos.\n"));
268  }
269  return false;
270  }
271 #endif
272 
273  if (!valid(qos.writer_data_lifecycle)) {
274  if (log_level >= LogLevel::Notice) {
276  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid writer_data_lifecycle qos.\n"));
277  }
278  return false;
279  }
280 
281  if (!valid(qos.representation)) {
282  if (log_level >= LogLevel::Notice) {
284  "(%P|%t) NOTICE: Qos_Helper::valid::DataWriterQos, invalid data representation qos.\n"));
285  }
286  return false;
287  }
288 
289  return true;
290 }
291 
293 {
294 
295  if (!valid(qos.presentation)) {
296  if (log_level >= LogLevel::Notice) {
298  "(%P|%t) NOTICE: Qos_Helper::valid::PublisherQos, invalid presentation qos.\n"));
299  }
300  return false;
301  }
302 
303  if (!valid(qos.partition)) {
304  if (log_level >= LogLevel::Notice) {
306  "(%P|%t) NOTICE: Qos_Helper::valid::PublisherQos, invalid partition qos.\n"));
307  }
308  return false;
309  }
310 
311  if (!valid(qos.group_data)) {
312  if (log_level >= LogLevel::Notice) {
314  "(%P|%t) NOTICE: Qos_Helper::valid::PublisherQos, invalid group_data qos.\n"));
315  }
316  return false;
317  }
318 
319  if (!valid(qos.entity_factory)) {
320  if (log_level >= LogLevel::Notice) {
322  "(%P|%t) NOTICE: Qos_Helper::valid::PublisherQos, sinvalid entity_factory qos.\n"));
323  }
324  return false;
325  }
326 
327  return true;
328 }
329 
331 {
332  if (!valid(qos.durability)) {
333  if (log_level >= LogLevel::Notice) {
335  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid durability qos.\n"));
336  }
337  return false;
338  }
339 
340  if (!valid(qos.deadline)) {
341  if (log_level >= LogLevel::Notice) {
343  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid deadline qos.\n"));
344  }
345  return false;
346  }
347 
348  if (!valid(qos.latency_budget)) {
349  if (log_level >= LogLevel::Notice) {
351  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid latency_budget qos.\n"));
352  }
353  return false;
354  }
355 
356  if (!valid(qos.liveliness)) {
357  if (log_level >= LogLevel::Notice) {
359  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid liveliness qos.\n"));
360  }
361  return false;
362  }
363 
364  if (!valid(qos.reliability)) {
365  if (log_level >= LogLevel::Notice) {
367  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid reliability qos.\n"));
368  }
369  return false;
370  }
371 
372  if (!valid(qos.destination_order)) {
373  if (log_level >= LogLevel::Notice) {
375  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid destination_order qos.\n"));
376  }
377  return false;
378  }
379 
380  if (!valid(qos.history)) {
381  if (log_level >= LogLevel::Notice) {
383  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid history qos.\n"));
384  }
385  return false;
386  }
387 
388  if (!valid(qos.resource_limits)) {
389  if (log_level >= LogLevel::Notice) {
391  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid resource_limits qos.\n"));
392  }
393  return false;
394  }
395 
396  if (!valid(qos.user_data)) {
397  if (log_level >= LogLevel::Notice) {
399  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid user_data qos.\n"));
400  }
401  return false;
402  }
403 
404  if (!valid(qos.time_based_filter)) {
405  if (log_level >= LogLevel::Notice) {
407  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid time_based_filter qos.\n"));
408  }
409  return false;
410  }
411 
412  if (!valid(qos.reader_data_lifecycle)) {
413  if (log_level >= LogLevel::Notice) {
415  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid reader_data_lifecycle qos.\n"));
416  }
417  return false;
418  }
419 
420  if (!valid(qos.ownership)) {
421  if (log_level >= LogLevel::Notice) {
423  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid ownership qos.\n"));
424  }
425  return false;
426  }
427 
428  if (!valid(qos.representation)) {
429  if (log_level >= LogLevel::Notice) {
431  "(%P|%t) NOTICE: Qos_Helper::valid::DataReaderQos, invalid representation qos.\n"));
432  }
433  return false;
434  }
435 
436  return true;
437 }
438 
440 {
441  if (!valid(qos.presentation)) {
442  if (log_level >= LogLevel::Notice) {
444  "(%P|%t) NOTICE: Qos_Helper::valid::SubscriberQos, invalid presentation qos.\n"));
445  }
446  return false;
447  }
448 
449  if (!valid(qos.partition)) {
450  if (log_level >= LogLevel::Notice) {
452  "(%P|%t) NOTICE: Qos_Helper::valid::SubscriberQos, invalid partition qos.\n"));
453  }
454  return false;
455  }
456 
457  if (!valid(qos.group_data)) {
458  if (log_level >= LogLevel::Notice) {
460  "(%P|%t) NOTICE: Qos_Helper::valid::SubscriberQos, invalid group_data qos.\n"));
461  }
462  return false;
463  }
464 
465  if (!valid(qos.entity_factory)) {
466  if (log_level >= LogLevel::Notice) {
468  "(%P|%t) NOTICE: Qos_Helper::valid::SubscriberQos, invalid entity_factory qos.\n"));
469  }
470  return false;
471  }
472 
473  return true;
474 }
475 
477 {
478  if (!valid(qos.entity_factory)) {
479  if (log_level >= LogLevel::Notice) {
481  "(%P|%t) NOTICE: Qos_Helper::valid::DomainParticipantFactoryQos, invalid entity_factory qos.\n"));
482  }
483  return false;
484  }
485 
486  return true;
487 }
488 
489 DataWriterQosBuilder::DataWriterQosBuilder(DDS::Publisher_var publisher)
490 {
491  const DDS::ReturnCode_t ret = publisher->get_default_datawriter_qos(qos_);
492  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
494  ACE_TEXT("(%P|%t) WARNING: DataWriterQosBuilder: ")
495  ACE_TEXT("could not get_default_datawriter_qos: %C\n"),
496  retcode_to_string(ret)));
497  }
498 }
499 
501  DDS::Publisher_var publisher)
502 {
503  DDS::TopicQos tqos;
504  DDS::ReturnCode_t ret = topic->get_qos(tqos);
505  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
507  ACE_TEXT("(%P|%t) WARNING: DataWriterQosBuilder: ")
508  ACE_TEXT("could not get_qos on topic: %C\n"),
509  retcode_to_string(ret)));
510  }
511  ret = publisher->get_default_datawriter_qos(qos_);
512  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
514  ACE_TEXT("(%P|%t) WARNING: DataWriterQosBuilder: ")
515  ACE_TEXT("could not get_default_datawriter_qos: %C\n"),
516  retcode_to_string(ret)));
517  }
518  ret = publisher->copy_from_topic_qos(qos_, tqos);
519  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
521  ACE_TEXT("(%P|%t) WARNING: DataWriterQosBuilder: ")
522  ACE_TEXT("could not copy_from_topic: %C\n"),
523  retcode_to_string(ret)));
524  }
525 }
526 
527 DataReaderQosBuilder::DataReaderQosBuilder(DDS::Subscriber_var subscriber)
528 {
529  const DDS::ReturnCode_t ret = subscriber->get_default_datareader_qos(qos_);
530  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
532  ACE_TEXT("(%P|%t) WARNING: DataReaderQosBuilder: ")
533  ACE_TEXT("could not get_default_datareader_qos: %C\n"),
534  retcode_to_string(ret)));
535  }
536 }
537 
539  DDS::Subscriber_var subscriber)
540 {
541  DDS::TopicQos tqos;
542  DDS::ReturnCode_t ret = topic->get_qos(tqos);
543  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
545  ACE_TEXT("(%P|%t) WARNING: DataReaderQosBuilder: ")
546  ACE_TEXT("could not get_qos on topic: %C\n"),
547  retcode_to_string(ret)));
548  }
549  ret = subscriber->get_default_datareader_qos(qos_);
550  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
552  ACE_TEXT("(%P|%t) WARNING: DataReaderQosBuilder: ")
553  ACE_TEXT("could not get_default_datareader_qos: %C\n"),
554  retcode_to_string(ret)));
555  }
556  ret = subscriber->copy_from_topic_qos(qos_, tqos);
557  if (ret != DDS::RETCODE_OK && log_level >= LogLevel::Warning) {
559  ACE_TEXT("(%P|%t) WARNING: DataReaderQosBuilder: ")
560  ACE_TEXT("could not copy_from_topic: %C\n"),
561  retcode_to_string(ret)));
562  }
563 }
564 
565 } // namespace DCPS
566 } // namespace OpenDDS
567 
UserDataQosPolicy user_data
PartitionQosPolicy partition
HistoryQosPolicy history
#define ACE_ERROR(X)
EntityFactoryQosPolicy entity_factory
LatencyBudgetQosPolicy latency_budget
GroupDataQosPolicy group_data
LifespanQosPolicy lifespan
OwnershipQosPolicy ownership
DurabilityQosPolicy durability
TimeBasedFilterQosPolicy time_based_filter
TransportPriorityQosPolicy transport_priority
DataRepresentationQosPolicy representation
OwnershipQosPolicy ownership
LivelinessQosPolicy liveliness
DeadlineQosPolicy deadline
DestinationOrderQosPolicy destination_order
EntityFactoryQosPolicy entity_factory
DataRepresentationQosPolicy representation
EntityFactoryQosPolicy entity_factory
ResourceLimitsQosPolicy resource_limits
EntityFactoryQosPolicy entity_factory
LatencyBudgetQosPolicy latency_budget
DestinationOrderQosPolicy destination_order
DurabilityServiceQosPolicy durability_service
PresentationQosPolicy presentation
DurabilityQosPolicy durability
OwnershipStrengthQosPolicy ownership_strength
DestinationOrderQosPolicy destination_order
DataRepresentationQosPolicy representation
DurabilityQosPolicy durability
LM_NOTICE
ResourceLimitsQosPolicy resource_limits
TopicDataQosPolicy topic_data
LM_WARNING
DeadlineQosPolicy deadline
ReaderDataLifecycleQosPolicy reader_data_lifecycle
ACE_TEXT("TCP_Factory")
HistoryQosPolicy history
OwnershipQosPolicy ownership
TransportPriorityQosPolicy transport_priority
ReliabilityQosPolicy reliability
OpenDDS_Dcps_Export LogLevel log_level
const char * retcode_to_string(DDS::ReturnCode_t value)
Definition: DCPS_Utils.cpp:29
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
HistoryQosPolicy history
LifespanQosPolicy lifespan
WriterDataLifecycleQosPolicy writer_data_lifecycle
const ReturnCode_t RETCODE_OK
LivelinessQosPolicy liveliness
UserDataQosPolicy user_data
UserDataQosPolicy user_data
DeadlineQosPolicy deadline
static bool valid(const DDS::UserDataQosPolicy &qos)
Definition: Qos_Helper.inl:723
GroupDataQosPolicy group_data
PartitionQosPolicy partition
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
PresentationQosPolicy presentation
ResourceLimitsQosPolicy resource_limits
LivelinessQosPolicy liveliness
PropertyQosPolicy property
DurabilityServiceQosPolicy durability_service
LatencyBudgetQosPolicy latency_budget