Quality of Service¶
Quality of Service is the collection of restrictions and expectations (called QoSPolicies) that appy to the different components of CycloneDDS. Some QoSPolicies only affect a single type of DDS entity, whereas others affect multiple DDS entities. QoSPolicies on a DDS entity can not be modified after creating the entity as they affect matching/discovery of entities. The QoS used is linked to the type of DDS entity the QoS is used for, for example, a SubscriberQoS is not accepted when creating a DataReader. The entity-specific QoSes are found in the qos sub-namespace of the same namespace the entity is defined in, whereas the different QoSPolicies are located in the dds::core::policy namespace.
CDDS-CXX Entity Type |
QoS Type |
---|---|
DomainParticipant |
DomainParticipantQos |
Publisher |
PublisherQos |
Subscriber |
SubscriberQos |
Topic |
TopicQos |
DataWriter |
DataWriterQos |
DataReader |
DataReaderQos |
Setting of QoSPolicies can be done by:
Either left-shifting the QoSPolicy “into” the QoS:
dds::sub::qos::DataReaderQos rqos;
rqos << dds::core::policy::Durability(dds::core::policy::DurabilityKind::TRANSIENT_LOCAL);
Or passing it as the parameter of the policy function:
dds::pub::qos::DataWriterQos wqos;
dds::core::policy::Reliability rel(dds::core::policy::ReliabilityKind::RELIABLE, dds::core::Duration(8, 8));
wqos.policy(rel);
Getting of QoSPolicies can be done by:
Either through the right-shifting the QoSPolicy “out of” the QoS:
dds::topic::qos::TopicQos tqos;
dds::core::policy::TopicData td;
tqos >> td;
Or through the policy function, which is templated to indicate which QoSPolicy is being accessed:
dds::domain::qos::DomainParticipantQos dqos;
auto ud = dqos.policy<dds::core::policy::UserData>();
For a detailed explanation of the different QoSPolicies and their effects on the behaviour of CycloneDDS, refer to the OMG DDS Spec v1.4 section 2.2.3.
Default and Inherited QoSes¶
QoSes have a number of default settings that are falled-back to when none are provided on creation. These defaults are either defined in the DDS standard, or propagated from “superior” entities. The default inherited QoS for entities is set through the following functions:
Superior Entity |
Subordinate Entity |
Default QoS accessor |
---|---|---|
DomainParticipant |
Topic |
default_topic_qos |
Publisher |
default_publisher_qos |
|
Subscriber |
default_subscriber_qos |
|
Topic |
DataReader |
default_datareader_qos |
DataWriter |
default_datawriter_qos |
|
Publisher |
DataWriter |
default_datawriter_qos |
Subscriber |
DataReader |
default_datareader_qos |
For example, in the following case:
dds::sub::Subscriber sub(participant);
dds::sub::qos::DataReaderQos qos1, qos2;
qos1 << dds::core::policy::Durability(dds::core::policy::DurabilityKind::TRANSIENT_LOCAL);
qos2 << dds::core::policy::DestinationOrder(dds::core::policy::DestinationOrderKind::BY_SOURCE_TIMESTAMP);
sub.default_datareader_qos(qos1);
dds::sub::DataReader<DataType> reader(sub,topic,qos2);
reader has its DestinationOrder QoSPolicy set to the value set in the QoS supplied in its constructor, which is BY_SOURCE_TIMESTAMP. Durability QoSPolicy defaults to the one set as default on the Subscriber, which is TRANSIENT_LOCAL. All other QosPolicies default to the DDS Spec, for example, the Ownership QoSPolicy has the value SHARED.