DDS-XML QoS Profiles

AstuteDDS supports loading QoS policies from XML files using the XmlQosLoader class (<astutedds/dcps/xml_config.hpp>). This lets you configure DDS entities without recompiling, following the OMG DDS XML profile format.

XML Profile Format

Profiles are grouped into libraries. Each profile can contain QoS blocks for DataWriters, DataReaders, Topics, and DomainParticipants.

<dds>
  <qos_library name="MyLibrary">

    <qos_profile name="ReliableProfile">
      <datawriter_qos>
        <reliability><kind>RELIABLE</kind></reliability>
        <durability><kind>TRANSIENT_LOCAL</kind></durability>
        <history><kind>KEEP_LAST</kind><depth>10</depth></history>
      </datawriter_qos>
      <datareader_qos>
        <reliability><kind>RELIABLE</kind></reliability>
        <durability><kind>TRANSIENT_LOCAL</kind></durability>
      </datareader_qos>
    </qos_profile>

    <!-- Inherit from ReliableProfile, override history only -->
    <qos_profile name="DeepHistoryProfile" base_name="MyLibrary::ReliableProfile">
      <datawriter_qos>
        <history><kind>KEEP_ALL</kind></history>
      </datawriter_qos>
    </qos_profile>

  </qos_library>
</dds>

Profile keys use the format "LibraryName::ProfileName".

Supported QoS Policies

Policy XML element Supported values
Reliability <reliability><kind> BEST_EFFORT, RELIABLE
Durability <durability><kind> VOLATILE, TRANSIENT_LOCAL, TRANSIENT, PERSISTENT
History <history><kind>, <depth> KEEP_LAST, KEEP_ALL
Liveliness <liveliness><kind>, <lease_duration> AUTOMATIC, MANUAL_BY_PARTICIPANT, MANUAL_BY_TOPIC
Deadline <deadline><period> duration in seconds
Ownership <ownership><kind> SHARED, EXCLUSIVE
Ownership Strength <ownership_strength><value> integer
Resource Limits <resource_limits> max_samples, max_instances, max_samples_per_instance
Destination Order <destination_order><kind> BY_RECEPTION_TIMESTAMP, BY_SOURCE_TIMESTAMP
Entity Factory <entity_factory><autoenable_created_entities> true, false

Loading Profiles

#include <astutedds/dcps/xml_config.hpp>

astutedds::dcps::XmlQosLoader loader;

// Load from a file
if (!loader.load_file("my_profiles.xml"))
{
    std::cerr << "Failed to load QoS profiles\n";
    return -1;
}

// Or load from a string
loader.load_string(xml_string);

Multiple files can be loaded; later loads merge into the existing profile map and overwrite duplicate keys.

Applying Profiles to Entities

#include <astutedds/dcps/domain_participant.hpp>
#include <astutedds/dcps/xml_config.hpp>

astutedds::dcps::XmlQosLoader loader;
loader.load_file("my_profiles.xml");

// DataWriter QoS
astutedds::dcps::DataWriterQos wqos;
if (loader.get_datawriter_qos("MyLibrary::ReliableProfile", wqos))
{
    auto writer = publisher->create_datawriter(topic, wqos);
}

// DataReader QoS
astutedds::dcps::DataReaderQos rqos;
if (loader.get_datareader_qos("MyLibrary::ReliableProfile", rqos))
{
    auto reader = subscriber->create_datareader(topic, rqos);
}

// Topic QoS
astutedds::dcps::TopicQos tqos;
loader.get_topic_qos("MyLibrary::ReliableProfile", tqos);

// DomainParticipant QoS
astutedds::dcps::DomainParticipantQos pqos;
loader.get_participant_qos("MyLibrary::ReliableProfile", pqos);

Profile Inheritance

A profile may set base_name to inherit another profile's QoS blocks. When a QoS block (e.g., <datawriter_qos>) is present in the derived profile, it fully overrides the corresponding block from the base. Blocks not present in the derived profile are inherited as-is from the base.

<!-- Base: RELIABLE writer -->
<qos_profile name="Base">
  <datawriter_qos>
    <reliability><kind>RELIABLE</kind></reliability>
  </datawriter_qos>
</qos_profile>

<!-- Derived: inherits RELIABLE writer qos block entirely; adds reader block -->
<qos_profile name="Derived" base_name="MyLib::Base">
  <datareader_qos>
    <reliability><kind>RELIABLE</kind></reliability>
  </datareader_qos>
</qos_profile>

Listing Available Profiles

for (const auto& key : loader.profile_keys())
    std::cout << key << "\n";
// e.g. "MyLibrary::ReliableProfile"
//      "MyLibrary::DeepHistoryProfile"

Clearing the Loader

loader.clear();   // Remove all loaded profiles

Thread Safety

XmlQosLoader is thread-safe. Concurrent calls to load_file(), load_string(), and any get_*_qos() method are safe.