How do I load QoS profiles via source code in Modern C++?

It is possible to create an Entity (a DataReader, DataWriter, or DomainParticipant)  with a QoS profile defined in the USER_QOS_PROFILES.xml file. In the Java, C, Traditional C++ and .NET APIs, there are methods such as:

DDS_Publisher_create_datawriter_with_profile() 

Depending on what kind of Entity is provided by the method, the parameters for these functions will change, but there are two parameters that will appear in all these functions: library_name and profile_name. These parameters help select what QoS profile will be loaded.

In Modern C++, it is necessary to use the QoSProvider class. This class provides a way for you to control and access the XML QoS profiles that are loaded by RTI Connext DDS. This class simplifies the management of the different QoS libraries and profiles from the code. 

For example, if you want to load the QoS settings from the file my_custom_qos_profiles.xml and create a DomainParticipant with a given profile, the code will look like the following:

// Create the QoS provider from a file
QosProvider qos_provider("my_custom_qos_profiles.xml");

// Create a DomainParticipant with a given profile
DomainParticipant participant(domain_id, qos_provider.participant_qos(“myLibrary::myProfile”));

Also, there are methods to find the Entities that this QosProvider is currently associated with.

For more information about the methods of this class, you can check the Modern C++ API.

You can compare how to load the QoS profiles in the different languages in the example “Using QoS profiles".

Programming Language: