The following #includes are needed for the examples on this page
#include <dds/domain/ddsdomain.hpp>
#include <dds/core/ddscore.hpp>
#include <dds/topic/ddstopic.hpp>
#include "Foo.hpp"
Registering a user data type
Setting up a Topic
- Set up a DomainParticipant
- Create a Topic with each of the available constructors
auto listener = std::make_shared<ExampleTopicListener>();
participant, "MyTopic6", "MyTypeName6", qos, listener);
participant, "MyTopic7", qos, listener,
participant, "MyTopic8", "MyTypeName8", qos, listener,
Discovering Topics
- Lookup local Topics by their topic name
void howto_lookup_topics()
{
create_and_retain_topic(participant, "Topic1");
create_and_retain_topic(participant, "Topic2");
dds::topic::find<dds::topic::Topic<Foo> >(participant, "Topic1");
dds::topic::find<dds::topic::Topic<Foo> >(participant, "Topic2");
topic2.close();
}
void create_and_retain_topic(
{
topic.retain();
}
- The next two examples assume the following setup
- Discover all Topics in a domain
participant1, std::back_inserter(handles1));
- Retrieve the TopicBuiltinTopicData for a Topic
std::vector<dds::topic::TopicBuiltinTopicData> topic_data1;
std::vector<dds::topic::TopicBuiltinTopicData> topic_data2(10);
std::vector<dds::topic::TopicBuiltinTopicData> topic_data3(10);
local_handles.push_back(topic2.instance_handle());
participant1, topic_data3.begin(), local_handles);
Tearing down a topic