Holoscan SDK v4.2.0

Class FastDdsEndpoint

Base Type

class FastDdsEndpoint : public holoscan::Endpoint

Endpoint implementation for DDS serialization.

This class implements the holoscan::Endpoint interface to enable serialization/deserialization to/from a byte buffer, which can then be used with DDS DataWriter/DataReader.

Two write-mode storage options are provided:

  • Vector mode: backed by a std::vector<uint8_t> that grows automatically.

  • Raw-buffer mode: backed by a caller-supplied fixed-size uint8_t* buffer; writes that would exceed the buffer size fail instead of growing.

Read mode always operates over a const std::vector<uint8_t>*.

Public Functions

explicit FastDdsEndpoint(std::vector<uint8_t> *output_buffer)

Construct a FastDdsEndpoint in write mode.

Data will be appended to the output buffer.

Parameters

output_buffer – Non-null pointer to the output buffer. Buffer is NOT cleared; data is appended.

Throws

std::invalid_argument – if output_buffer is nullptr

FastDdsEndpoint(uint8_t *buffer, size_t buffer_size)

Construct a FastDdsEndpoint in write mode with a fixed-size raw buffer.

Data will be written starting at position 0. Unlike the vector mode, writes that exceed buffer_size will fail (the buffer does not grow).

Parameters
  • buffer – Non-null pointer to the output buffer.

  • buffer_size – Available buffer size in bytes.

Throws

std::invalid_argument – if buffer is nullptr

explicit FastDdsEndpoint(const std::vector<uint8_t> *input_buffer)

Construct a FastDdsEndpoint in read mode.

Data will be read from the input buffer starting at position 0.

Parameters

input_buffer – Non-null pointer to the input buffer.

Throws

std::invalid_argument – if input_buffer is nullptr

~FastDdsEndpoint() override = default

Default destructor.

FastDdsEndpoint(const FastDdsEndpoint&) = delete
FastDdsEndpoint &operator=(const FastDdsEndpoint&) = delete
FastDdsEndpoint(FastDdsEndpoint&&) = default
FastDdsEndpoint &operator=(FastDdsEndpoint&&) = default
virtual bool is_write_available() override

Check if write operations are available.

Returns

true if constructed in write mode with valid buffer

virtual bool is_read_available() override

Check if read operations are available.

Returns

true if constructed in read mode with data remaining

virtual expected<size_t, RuntimeError> write(const void *data, size_t size) override

Write data to the buffer.

Appends the specified data to the output buffer.

Parameters
  • data – Pointer to data to write

  • size – Number of bytes to write

Returns

Number of bytes written, or error if in read mode

virtual expected<size_t, RuntimeError> read(void *data, size_t size) override

Read data from the buffer.

Reads data from the current position and advances the read position.

Parameters
  • data – Pointer to destination buffer

  • size – Number of bytes to read

Returns

Number of bytes read, or error if insufficient data or in write mode

virtual expected<void, RuntimeError> write_ptr(const void *pointer, size_t size, holoscan::MemoryStorageType type) override

Write a pointer reference for zero-copy support.

For DDS, GPU device memory cannot be sent directly. This method fails for kDevice memory — the caller must stage device data to host memory before serialization. kCudaManaged memory is accepted (with a warning to ensure GPU operations are complete), and kHost/kSystem memory is written directly via write().

Parameters
  • pointer – Pointer to data

  • size – Size of data in bytes

  • type – Memory storage type (host, device, system, cuda_managed)

Returns

Success for host/system/managed memory, error for device memory

void reset_read_position()

Reset the read position to the beginning.

Allows re-reading the buffer from the start. Only valid in read mode.

inline size_t read_position() const

Get the current read position.

Returns

Current read position (0 in write mode)

size_t size() const

Get the total bytes written (write mode) or buffer size (read mode).

Returns

Total size in bytes

size_t bytes_remaining() const

Get remaining bytes available for reading.

Returns

Bytes remaining (0 in write mode)

size_t bytes_written() const

Get the number of bytes written (raw buffer mode).

Returns

Bytes written in raw buffer mode, or vector size in vector mode, or 0.

inline bool is_write_mode() const

Check if in write mode.

Returns

true if constructed with output buffer (vector or raw)

inline bool is_read_mode() const

Check if in read mode.

Returns

true if constructed with input buffer

Previous Class FastDdsDiscovery
Next Class FastDdsHoloscanEntityTypeSupport
© Copyright 2022-2026, NVIDIA. Last updated on May 11, 2026