In this lesson, you add a domain participant for your MyPublisher
publisher entity.
- Right-click the PublisherPkg package and select .
- Open the Features window for the domain participant element
and enter the following information:
- On the General tab, name the
element MyPublishingApplication. Notice that by default the same name has also been entered
in the Directory field, and Executable has
been selected in the Type area.
- On the Scope tab, select PublisherPkg. If other check boxes are selected, clear them. Click OK.
- Specify the configuration for the MyPublishingApplication
domain participant:
- Open the Features window for the DefaultConfig configuration
under MyPublishingApplication
- On the Initialization tab, expand PublisherPkg and
select MyPublisher
- On the Settings tab, select the MSVC9 or Linux environment,
and then click OK
- Add a dependency from the MyPublishingApplication domain
participant to the MyTopicStructLib domain participant:
- Right-click MyPublishingApplication and
select
- On the Add Dependency window, select MyTopicStructLib
in TopicsPkg
- From the browser, open the Features window for the dependency
and enter the following information:
- On the General tab, in the Stereotype field,
select Usage in PredefinedTypes
- Make sure that the Usage field
is set to Specification, and then click OK. This dependency allows the functions of MyTopicStructLib to
be used while MyTopicStruct is registered and MyTopic is created.
The dependency also provides functions from MyTopicStructLib to create
MyDataWriter.
- Generate code: Select .
Note: Because you created the PublisherPkg
package in this lesson, the DefaultConfig configuration is already
set as the active configuration.
- Under the MyPublishingApplication domain participant, right-click
the DefaultConfig configuration and select Edit
Configuration Main File. Notice that
code generation created a singleton class called MyPublishingApplicationDP.
This class is a wrapper to the DDS::DomainParticipant entity.
It supplies the following API:
- DDS::DomainParticipant* getDomainParticipant():
Gets the DDS::DomainParticipant member of this class
- DDS::TopicDescription* lookupTopicDescription(char* topicName):
A wrapper to DDS standard API call DDS::DomainParticipant::lookup_topicdescription
- static MyPublishingApplicationDP* instance():
The singleton operation that allows the singleton instance of this
class to be received
In the implementation main file, you can see the following
actions in the constructor of
MyPublishingApplicationDP:
- The DDS::DomainParticipant element is created
- MyTopicStruct is registered
- MyTopic is created
The last two elements are a result of the notation that MyDataWriter,
which is in the scope of the domain participant component, updates
MyTopic.
As the diagram shape of the publisher entity implies,
the generated code for publisher entity is a class. This class contains
the attribute of a DDS::Publisher pointer that is
initialized during the construction of a new class instance. It also
contains a MyTopicStructDataWriter pointer named MyDataWriter that
represents the dataWriter element that you created. The MyTopicStructDataWriter pointer
is defined in the files that are generated from the DDSMyTopicStructLib.idl file
in the domain participant component named MyTopicStructLib.
If
you edit the code of MyPublisher, you see that during its construction, MyPublishingApplicationDP is
called to retrieve its DDS::DomainParticipant member
so that the DDS::Publisher element can be created.
You also find this operation: DDS::ReturnCode_t publishMyDataWriter(const
MyTopicStruct& data);
This operation is a wrapper
to MyTopicStructDataWriter::write. This function
was generated from the DDSMyTopicStructLib.idl file
that was generated.