RTI Connext Modern C++ API  Version 6.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
XML Application Creation

Creating a custom content filter. More...

Creating a custom content filter.

Introduction

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">
<filter name="ExampleTopic" kind="builtin.sql">
<expression> foo > 5 </expression>
</filter>
</data_reader>
</domain_participant>
</participant_library>
</dds>

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(dds::core::StringSeq(1, config_file));

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
dds::domain::DomainParticipant publication_participant =
"ExampleParticipantLibrary::ExamplePublicationParticipant", params);
dds::domain::DomainParticipant subscription_participant =
"ExampleParticipantLibrary::ExampleSubscriptionParticipant", params);

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
dds::pub::DataWriter<Foo> found_writer =
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
dds::sub::DataReader<Foo> found_reader =
subscription_participant, "ExampleReader");

RTI Connext Modern C++ API Version 6.0.1 Copyright © Sat Nov 23 2019 Real-Time Innovations, Inc