RTI Connext Traditional C++ API
Version 6.1.2
Topic Use Cases
Programming How-To's
Working with topics.
More...
Working with topics.
Registering a user data type
Set up participant
Register user data type of type
T
under the name "My_Type"
const
char
* type_name =
"My_Type"
;
DDS_ReturnCode_t
retcode;
retcode =
FooTypeSupport::register_type
(participant, type_name);
if
(retcode !=
DDS_RETCODE_OK
) {
// ... error
}
Setting up a topic
Set up participant
Ensure user data type is registered
Create a
DDSTopic
under the name "my_topic"
const
char
* topic_name =
"my_topic"
;
const
char
* type_type =
"My_Type"
;
// user data type
DDS_TopicQos
topic_qos;
DDS_ReturnCode_t
retcode;
// MyTopicListener is user defined and
// extends DDSTopicListener
DDSTopicListener
* topic_listener =
new
MyTopicListener();
// or = NULL
retcode = participant->
get_default_topic_qos
(topic_qos);
if
(retcode !=
DDS_RETCODE_OK
) {
// ... error
}
DDSTopic
* topic = participant->
create_topic
(topic_name, type_name,
topic_qos, topic_listener,
DDS_STATUS_MASK_ALL
);
if
(topic == NULL) {
// ... error
};
Tearing down a topic
Delete
DDSTopic
:
DDS_ReturnCode_t
retcode;
retcode = participant->
delete_topic
(topic);
if
(retcode !=
DDS_RETCODE_OK
) {
// ... check for cause of failure
}