How to use dds::core::QosProvider to access XML QoS profiles.
More...
How to use dds::core::QosProvider to access XML QoS profiles.
Managing Qos Profiles
This section provides several examples on how to use a dds::core::QosProvider to load QoS profiles from XML. The class documentation provides general usage information.
These examples use the following file, ExampleQos.xml, which defines only the EntityName QoS policy for the DomainParticipant and DataWriter to illustrate how the profiles are loaded:
<?xml version="1.0"?>
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://community.rti.com/schema/current/rti_dds_profiles.xsd">
<qos_library name="MyLibrary">
<qos_profile name="MyProfile" is_default_qos="true">
<domain_participant_qos>
<participant_name>
<name>ExampleParticipantName</name>
</participant_name>
</domain_participant_qos>
<datawriter_qos>
<publication_name>
<name>ExamplePublicationName</name>
</publication_name>
</datawriter_qos>
</qos_profile>
</qos_library>
<qos_library name="MySecondLibrary">
<qos_profile name="MySecondProfile">
<domain_participant_qos>
<participant_name>
<name>SecondExampleParticipantName</name>
</participant_name>
</domain_participant_qos>
<datawriter_qos>
<publication_name>
<name>SecondExamplePublicationName</name>
</publication_name>
</datawriter_qos>
</qos_profile>
</qos_library>
</dds>
The example code shows how to create a QosProvider, load QoS profiles from the provider, and create entities with those QoS values:
auto participant_qos = my_provider.participant_qos();
std::cout << participant.
qos().
policy<EntityName>().
name().value()
<< std::endl;
participant_qos =
my_provider.participant_qos("MySecondLibrary::MySecondProfile");
std::cout << participant_qos.
policy<EntityName>().
name().value()
<< std::endl;
my_provider.extensions().default_profile("MySecondLibrary::MySecondProfile");
participant_qos = my_provider.participant_qos();
std::cout << participant_qos.
policy<EntityName>().
name().value()
<< std::endl;
publisher,
topic,
my_provider.datawriter_qos());
<< std::endl;
my_provider.datawriter_qos("MyLibrary::MyProfile"));
std::cout << writer.qos().policy<EntityName>().
name().value() << std::endl;
const char * my_xml_str =
"str://\"<dds>"
"<qos_library name=\"MyThirdLibrary\">"
"<qos_profile name=\"MyThirdProfile\">"
"<domain_participant_qos>"
"<participant_name>"
"<name>ThirdExampleParticipantName</name>"
"</participant_name>"
"</domain_participant_qos>"
"</qos_profile>"
"</qos_library>"
"</dds>\"";
my_xml_str,
"MyThirdLibrary::MyThirdProfile");
participant_qos = my_provider2.participant_qos();
std::cout << participant_qos.
policy<EntityName>().
name().value()
<< std::endl;
auto libraries = my_provider.extensions().qos_profile_libraries();
std::cout << library << std::endl;
auto profiles = my_provider.extensions().qos_profiles(library);
std::cout << " -" << profile << std::endl;
}
}
- See also
- Create a DynamicType from an XML description
-
XML Application Creation
The Default Qos Provider
This example shows how to configure the default QosProvider:
std::cout << participant1.
qos().
policy<EntityName>().
name().value()
<< std::endl;
default_provider.extensions().
default_profile(
"MySecondLibrary::MySecondProfile");
std::cout << participant2.
qos().
policy<EntityName>().
name().value()
<< std::endl;
std::cout << std::boolalpha
<< std::endl;