DCPS API Overview

The DCPS (Data-Centric Publish-Subscribe) API is the main interface for DDS applications.

Full API Reference

Auto-generated reference documentation (from Doxygen source comments) is available in the API Reference section of the online documentation. The pages below give a guided overview of the main entry points.

Core Entities

DomainParticipant

Entry point for DDS applications.

auto& factory = astutedds::dcps::DomainParticipantFactory::instance();
auto* participant = factory.create_participant(0);  // Domain 0
if (participant && participant->enable()) {
    // DDS is now active
}

Topic

Named data channel.

auto* topic = participant->create_topic(
    "TopicName",
    "MyModule::DataType"
);

Publisher / DataWriter

Publish data to topics.

auto* publisher = participant->create_publisher();
auto* writer = publisher->create_datawriter(topic);

// Serialize and write data
std::vector<uint8_t> serialized;
// ... populate serialized data ...
writer->write(serialized);

Subscriber / DataReader

Subscribe to topic data.

auto* subscriber = participant->create_subscriber();
auto* reader = subscriber->create_datareader(topic);

// Read samples
std::vector<uint8_t> sample;
DDS::SampleInfo info;
if (reader->read_next_sample(sample, info) == DDS::ReturnCode_t::RETCODE_OK) {
    // Process sample
}

QoS Policies

See QoS Documentation for details.

XML QoS Profiles

Load QoS policies from OMG DDS XML profile files without recompiling.

#include <astutedds/dcps/xml_config.hpp>

astutedds::dcps::XmlQosLoader loader;
loader.load_file("profiles.xml");

astutedds::dcps::DataWriterQos wqos;
if (loader.get_datawriter_qos("MyLibrary::ReliableProfile", wqos))
    auto writer = publisher->create_datawriter(topic, wqos);

XmlQosLoader API

Method Description
load_file(path) Load profiles from an XML file
load_string(xml) Load profiles from an in-memory XML string
get_datawriter_qos(key, qos) Fill a DataWriterQos from a named profile
get_datareader_qos(key, qos) Fill a DataReaderQos from a named profile
get_topic_qos(key, qos) Fill a TopicQos from a named profile
get_participant_qos(key, qos) Fill a DomainParticipantQos from a named profile
profile_keys() Return all loaded profile keys
clear() Remove all loaded profiles

Profile keys use the format "LibraryName::ProfileName". Profiles may inherit from a base via the base_name attribute. Thread-safe.

See XML QoS Profiles Guide for full details and XML format.


Persistence Service

Delivers historical samples to late-joining DataReaders (OMG DDS 1.4 Section 2.2.3.4).

#include <astutedds/dcps/persistence_service.hpp>

// Override the storage directory (default: ".astutedds_persistence/")
astutedds::dcps::PersistenceService::instance().set_persistence_dir("/var/lib/astutedds");

// Configure a durable DataWriter
auto wqos = astutedds::dcps::DataWriterQosBuilder()
    .durability(astutedds::dcps::DurabilityQosPolicyKind::PERSISTENT_DURABILITY_QOS)
    .build();
Durability Kind Storage Survives restart
TRANSIENT In-memory No
PERSISTENT File-backed Yes

See Persistence Service Guide for full details.


Recording and Replay

Capture raw DDS payload streams to disk and replay them with original timing.

#include <astutedds/dcps/record_replay.hpp>

// Write
astutedds::dcps::DataLogTool::write_samples("capture.addslog", samples);

// Read back
std::vector<astutedds::dcps::LoggedSample> loaded;
astutedds::dcps::DataLogTool::read_samples("capture.addslog", loaded);

// Replay (preserves inter-sample timing)
astutedds::dcps::DataLogTool::replay_samples(*participant, loaded);

LoggedSample

struct LoggedSample {
    uint64_t             relative_timestamp_ns;  // ns since first sample
    std::string          topic_name;
    std::vector<uint8_t> payload;                // raw XCDR bytes
};

See Recording and Replay Guide for full details.


DDS Security

Secure DDS communication with authentication, access control, and encryption.

#include <astutedds/security/security.hpp>

// Create security plugins
auto auth = astutedds::security::create_pki_authentication_plugin();
auto crypto = astutedds::security::create_aes_gcm_crypto_plugin();

// Authenticate
SEC::CertificateCredentials creds = {...};
auto identity = auth->validate_local_identity(creds, 0, {}, ex);

// Encrypt payload before sending
std::vector<uint8_t> encrypted;
crypto->encode_serialized_payload(encrypted, plain, writer_crypto, ex);

See DDS Security Guide for complete examples.


Domain Routing

Bridge multiple DDS domains with automatic type checking and QoS mapping.

Use the astutedds-router tool to configure and manage domain bridging:

./bin/astutedds-router router_config.yaml

See DDS Domain Router Guide for configuration details.


AstuteDDS Inspector

Visual topology monitoring and diagnostics tool for DDS systems.

# Launch the Qt6-based GUI
./build/tools/inspect/astutedds-inspect

# Or inspect a specific domain
ASTUTEDDS_DOMAIN=1 ./build/tools/inspect/astutedds-inspect

Features: - Live participant and endpoint discovery - Real-time QoS compatibility checking - Message statistics and throughput - Topology export and logging

See AstuteDDS Inspector Guide for details.


Header Files

  • <astutedds/dcps/domain_participant.hpp>
  • <astutedds/dcps/topic.hpp>
  • <astutedds/dcps/publisher.hpp>
  • <astutedds/dcps/subscriber.hpp>
  • <astutedds/dcps/data_writer.hpp>
  • <astutedds/dcps/data_reader.hpp>
  • <astutedds/dcps/qos.hpp>
  • <astutedds/dcps/xml_config.hpp>
  • <astutedds/dcps/persistence_service.hpp>
  • <astutedds/dcps/record_replay.hpp>