3.2 Add Name to Each DomainParticipant

Each time a DomainParticipant is discovered, the LBED Plugin uses the name of that DomainParticipant (propagated in the participant announcements) to look for its endpoints’ information in the XML file. Since the <participant_name> field is used to associate a participant with its XML information, each DomainParticipant using LBED must have a non-NULL name that identifies it.

Note: If you plan on starting multiple applications with participants that have the same configuration and set of endpoints, these participants can reuse the same configuration and have the same name. For example, you could have two temperature sensors with the same DomainParticipant and QoS, each with a DataWriter on the "Temperature" topic. The only difference would be the data both sensors publish. If you use LBED in this case, the XML of both DomainParticipants will be the same; you don't need to duplicate that information and give the DomainParticipants different names.

The name of a DomainParticipant can be configured using the ENTITY_NAME QosPolicy (DDS Extension), in the RTI Connext Core Libraries User's Manual. The USER_QOS_PROFILES.xml generated in 3.1 Generate Connext Project already assigns a name to the DomainParticipants. It assigns the same name, ExampleLBEDParticipant, to both the Publisher and Subscriber DomainParticipants; however, to use LBED, Publisher and Subscriber DomainParticipants need to have different names because they contain different sets of endpoints. Therefore, in this exercise, we will create two separate QoS profiles: one for the Publisher DomainParticipant and another for the Subscriber, each with a different <participant_name>.

  1. Remove the existing qos_profile named “ExampleLBED_Profile” in the USER_QOS_PROFILES.xml file and copy and paste the following two profiles:
  2. <!-- The QoS profile used by the publishing entities -->
    <qos_profile name="ExampleLBED_Publisher_Profile">
        <domain_participant_qos>
            <participant_name>
                <name>ExampleLBEDParticipantPublisher</name>
            </participant_name>
        </domain_participant_qos>
    </qos_profile>
     
    <!-- The QoS profile used by the subscribing entities -->
    <qos_profile name="ExampleLBED_Subscriber_Profile">
        <domain_participant_qos>
            <participant_name>
                <name>ExampleLBEDParticipantSubscriber</name>
            </participant_name>
        </domain_participant_qos>
    </qos_profile>
  3. Modify ExampleLBED_publisher.cxx so that the DomainParticipant, Topic, Publisher, and DataWriter use the “ExampleLBED_Publisher_Profile”:
  4. dds::domain::DomainParticipant participant(
        domain_id,
        dds::core::QosProvider::Default().participant_qos(
            "ExampleLBED_Library::ExampleLBED_Publisher_Profile"));
     
    ...
     
    dds::topic::Topic<ExampleLBED> topic(
        participant,
        "Example ExampleLBED",
        dds::core::QosProvider::Default().topic_qos(
            "ExampleLBED_Library::ExampleLBED_Publisher_Profile"));
     
    ...
     
    dds::pub::Publisher publisher(
        participant,
        dds::core::QosProvider::Default().publisher_qos(
            "ExampleLBED_Library::ExampleLBED_Publisher_Profile"));
     
    ...
     
    dds::pub::DataWriter<ExampleLBED> writer(
        publisher,
        topic,
        dds::core::QosProvider::Default().datawriter_qos(
            "ExampleLBED_Library::ExampleLBED_Publisher_Profile"),
            listener,
            status_mask);
  5. Modify ExampleLBED_subscriber.cxx so that the DomainParticipant, Topic, Subscriber, and DataReader use the “ExampleLBED_Subscriber_Profile”:
  6. dds::domain::DomainParticipant participant(
        domain_id,
        dds::core::QosProvider::Default().participant_qos(
            "ExampleLBED_Library::ExampleLBED_Subscriber_Profile"));
     
    ...
     
    dds::topic::Topic<ExampleLBED> topic(
        participant,
        "Example ExampleLBED",
        dds::core::QosProvider::Default().topic_qos(
            "ExampleLBED_Library::ExampleLBED_Subscriber_Profile"));
     
    ...
     
    dds::sub::Subscriber subscriber(
        participant,
        dds::core::QosProvider::Default().subscriber_qos(
            "ExampleLBED_Library::ExampleLBED_Subscriber_Profile"));
     
    ...
     
    dds::sub::DataReader<ExampleLBED> reader(
        subscriber,
        topic,
        dds::core::QosProvider::Default().datareader_qos(
            "ExampleLBED_Library::ExampleLBED_Subscriber_Profile"),
            listener,
            status_mask);