RTI Connext Modern C++ API Version 7.2.0
XML Application Creation

Defining DDS systems in XML.

Defining DDS systems in XML.

Introduction <br>

XML-Based Application Creation is a mechanism to simplify the development and programming of RTI Connext applications. RTI Connext supports the use of XML for the complete system definition. This includes not only the definition of the data types and Quality of Service settings, but also the definition of the Topics, DomainParticipants, and all the Entities they contain (Publishers, Subscribers, DataWriters and DataReaders).

The application code simply indicates the participant configuration name of the DomainParticipant that the application wants to create. The XML-Based Application Creation infrastructure takes care of the rest: creating the DomainParticipant, registering the types and Topics, and populating all the configured Entities. When the application needs to read or write data, register listeners, or perform any other action, it simply looks up the appropriate Entity by name and uses it.

See the RTI_ConnextDDS_CoreLibraries_XML_AppCreation_GettingStarted.pdf for a more exhaustive description XML Application Creation, most notably, how to set up the XML Configuration files.

The example on this page shows a basic use of the APIs that are necessary in order to access the entities that have been created in an XML file.

Relevant functions that enable the use of XML Application Creation are:

Setting up this Example

The following #includes are needed for the examples on this page

#include <iostream>
#include <dds/core/QosProvider.hpp>
#include <dds/sub/DataReader.hpp>
#include <dds/sub/find.hpp>
#include <dds/pub/DataWriter.hpp>
#include <dds/pub/find.hpp>
#include "Foo.hpp"

The following is the configuration that we will be using in this example:

<dds>
<types>
<struct name="Foo">
<member name="x" type="long"/>
</struct>
</types>
<domain_library name="ExampleDomainLibrary" >
<domain name="ExampleDomain" domain_id="0">
<register_type name="Foo" kind ="userGenerated"/>
<topic name="ExampleTopic" register_type_ref="Foo"/>
</domain>
</domain_library>
<participant_library name="ExampleParticipantLibrary">
<domain_participant name="ExamplePublicationParticipant" domain_ref="ExampleDomainLibrary::ExampleDomain">
<publisher name="ExamplePublisher">
<data_writer name="ExampleWriter" topic_ref="ExampleTopic"/>
</publisher>
</domain_participant>
<domain_participant name="ExampleSubscriptionParticipant" domain_ref="ExampleDomainLibrary::ExampleDomain">
<data_reader name="ExampleReader" topic_ref="ExampleTopic">
<content_filter name="ExampleTopic" kind="builtin.sql">
<expression> foo > 5 </expression>
</content_filter>
</data_reader>
</domain_participant>
</participant_library>
</dds>
void register_type(dds::domain::DomainParticipant &participant, const std::string &name, const dds::core::xtypes::DynamicType &type, const rti::core::xtypes::DynamicDataTypeSerializationProperty &serialization_property=rti::core::xtypes::DynamicDataTypeSerializationProperty::DEFAULT)
<<extension>> Registers a DynamicType with specific serialization properties
std::string name() const
<<extension>> Gets the filter name
Definition: FilterImpl.hpp:133
int32_t domain_id() const
<<extension>> Get the domain ID associated with the discovered dds::domain::DomainParticipant.
Definition: BuiltinTopicImpl.hpp:245
dds::core::optional< dds::core::xtypes::DynamicType > type() const
<<extension>> Get the type
The dds namespace. The dds namespace includes all of the standard types, classes, and functions.
Definition: ClientEndpoint.hpp:27

Using XML Application Creation

You must first make sure that your configuration file is loaded by RTI Connext by using the QosProvider:

// Configure the default QosProvider to load the configuration
// config_file == "/the/path/to/your/xml/configuration.xml"
provider_params.url_profile({ config_file });
rti::core::QosProviderParams provider_params() const
<<extension>> Get the QosProvider params for this QosProvider.
<<extension>> <<value-type>> Configure options that control the way that XML documents containing QoS...
Definition: QosProviderParams.hpp:80
const dds::core::StringSeq url_profile() const
Get the current list of URL groups stored by this QosProviderParams.
QosProviderParams default_qos_provider_params()
<<extension>> Get the rti::core::QosProviderParams for the default QosProvider

Then, if you are using a user-generated type, you must register the type with RTI Connext:

// When using user-generated types, you must register the type with RTI
// Connext DDS before creating the participants and the rest of the entities
// in your system
rti::domain::register_type<Foo>("Foo");

To create and access the system that you have defined in your system, call dds::core::QosProvider::create_participant_from_config:

// Create the participants, changing the domain id from the one in the
// configuration
// Create the participants
auto default_provider = dds::core::QosProvider::Default();
dds::domain::DomainParticipant publication_participant =
default_provider.extensions().create_participant_from_config(
"ExampleParticipantLibrary::ExamplePublicationParticipant",
params);
dds::domain::DomainParticipant subscription_participant =
default_provider.extensions().create_participant_from_config(
"ExampleParticipantLibrary::ExampleSubscriptionParticipant",
params);
static QosProvider Default()
Get the default QosProvider.
Definition: TQosProvider.hpp:409
<<reference-type>> Container for all dds::core::Entity objects.
Definition: TDomainParticipant.hpp:63
<<extension>> <<value-type>> Input paramaters for creating a participant from xml configuration....
Definition: DomainParticipantConfigParams.hpp:80

After you have created the participants which were defined in your configuration, you can use various find functions to access the other entities that you have configured. For example, to lookup the DataWriter and DataReader from the example configuration:

// Lookup the DataWriter and DataReader from the configuration
rti::pub::find_datawriter_by_name<dds::pub::DataWriter<Foo>>(
publication_participant,
"ExamplePublisher::ExampleWriter");
// The implicit subscriber was used to create this reader so we only
// provide the reader's name, and not a fully qualified name as we did to
// look up the DataWriter
rti::sub::find_datareader_by_name<dds::sub::DataReader<Foo>>(
subscription_participant,
"ExampleReader");
<<reference-type>> Allows an application to publish data for a dds::topic::Topic
Definition: TDataWriter.hpp:58
<<reference-type>> Allows the application to: (1) declare the data it wishes to receive (i....
Definition: TDataReader.hpp:73