// Create a domain with ID 0 DDS::DomainId_t domainId = 0; DDS::DomainParticipantFactory_var dpf = DDS::DomainParticipantFactory::get_instance(); DDS::DomainParticipant_var participant = dpf->create_participant(domainId, DDS::PARTICIPANT_QOS_DEFAULT, nullptr, DDS::STATUS_MASK_NONE);
// Create a publisher and a subscriber for a topic DDS::Topic_var topic = participant->create_topic("my_topic", "my_type", DDS::TOPIC_QOS_DEFAULT, nullptr, DDS::STATUS_MASK_NONE); DDS::Publisher_var publisher = participant->create_publisher(DDS::PUBLISHER_QOS_DEFAULT, nullptr, DDS::STATUS_MASK_NONE); DDS::Subscriber_var subscriber = participant->create_subscriber(DDS::SUBSCRIBER_QOS_DEFAULT, nullptr, DDS::STATUS_MASK_NONE);In this example, we create a topic with name "my_topic" and type "my_type", and then create a publisher and a subscriber using default quality-of-service and no listener. The DomainParticipantFactory_var class is part of the OpenDDS package library.