holoscan::FastDdsEndpoint
holoscan::FastDdsEndpoint
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>*.
Inherits from: holoscan::Endpoint (public)
Constructors
FastDdsEndpoint
From raw pointer (with output buffer)
Overload 2
From raw pointer (with input buffer)
Move
Copy (deleted)
Construct a FastDdsEndpoint in write mode.
Data will be appended to the output buffer.
Throws: std::invalid_argument if output_buffer is nullptr
Parameters
Non-null pointer to the output buffer. Buffer is NOT cleared; data is appended.
Destructor
~FastDdsEndpoint
Default destructor.
Assignment operators
operator=
Move assign
Copy assign (deleted)
Methods
is_write_available
Check if write operations are available.
Returns: true if constructed in write mode with valid buffer
is_read_available
Check if read operations are available.
Returns: true if constructed in read mode with data remaining
write
Write data to the buffer.
Appends the specified data to the output buffer.
Returns: Number of bytes written, or error if in read mode
Parameters
Pointer to data to write
Number of bytes to write
read
Read data from the buffer.
Reads data from the current position and advances the read position.
Returns: Number of bytes read, or error if insufficient data or in write mode
Parameters
Pointer to destination buffer
Number of bytes to read
write_ptr
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().
Returns: Success for host/system/managed memory, error for device memory
Parameters
Pointer to data
Size of data in bytes
Memory storage type (host, device, system, cuda_managed)
reset_read_position
Reset the read position to the beginning.
Allows re-reading the buffer from the start. Only valid in read mode.
read_position
Get the current read position.
Returns: Current read position (0 in write mode)
size
Get the total bytes written (write mode) or buffer size (read mode).
Returns: Total size in bytes
bytes_remaining
Get remaining bytes available for reading.
Returns: Bytes remaining (0 in write mode)
bytes_written
Get the number of bytes written (raw buffer mode).
Returns: Bytes written in raw buffer mode, or vector size in vector mode, or 0.
is_write_mode
Check if in write mode.
Returns: true if constructed with output buffer (vector or raw)
is_read_mode
Check if in read mode.
Returns: true if constructed with input buffer
write_trivial_type
read_trivial_type
resource_type
Get the resource type.
Returns: The resource type.
name
Set the name of the resource (1)
Set the name of the resource (2)
Const
Set the name of the resource.
Returns: The reference to the resource.
Parameters
The name of the resource.
fragment
Set the fragment of the resource.
Returns: The reference to the resource.
Parameters
The pointer to the fragment of the resource.
spec
Set the component specification to the resource
Get the component specification of the resource
Set the component specification to the resource.
Returns: The reference to the resource.
Parameters
The component specification.
spec_shared
Get the shared pointer to the component spec.
Returns: The shared pointer to the component spec.
setup
Define the resource specification.
Parameters
The reference to the component specification.
initialize
Initialize the component.
This method is called only once when the component is created for the first time, and use of light-weight initialization.
to_yaml_node
Get a YAML representation of the resource.
Returns: YAML node including spec of the resource in addition to the base component properties.
set_parameters
Set the parameters based on defaults (sets GXF parameters for GXF components).
id
Get the identifier of the component.
By default, the identifier is set to -1. It is set to a valid value when the component is initialized.
With the default executor (GXFExecutor), the identifier is set to the GXF component ID.
Returns: The identifier of the component.
add_arg
Add an argument to the component (1)
Add an argument to the component (2)
Add a list of arguments to the component (1)
Add a list of arguments to the component (2)
Add an argument to the component.
Parameters
The argument to add.
args
Get the list of arguments.
Returns: The vector of arguments.
description
Get a description of the component.
Returns: YAML string.
See also: to_yaml_node()
service
Retrieve a registered fragment service or resource.
Retrieves a previously registered fragment service or resource by its type and optional identifier. Returns nullptr if no service/resource is found with the specified type and identifier.
Note that any changes to the service retrieval logic in this method should be synchronized with the implementation in Fragment::service() method to maintain consistency.
Returns: The shared pointer to the service/resource, or nullptr if not found or if type casting fails.
Template parameters
The type of the service/resource to retrieve. Must inherit from either Resource or FragmentService. Defaults to DefaultFragmentService if not specified.
Parameters
The identifier of the service/resource. If empty, retrieves by type only.
get_service_by_type_info
Retrieve a registered fragment service or resource for Python bindings.
This is a helper method for Python bindings to retrieve a service by its C++ type info.
Returns: The shared pointer to the base service, or nullptr if not found.
Parameters
The type info of the service/resource to retrieve.
The identifier of the service/resource. If empty, retrieves by type only.
reset_backend_objects
Reset any backend-specific objects (e.g. GXF GraphEntity).
update_params_from_args
Update parameters based on the specified arguments
Update parameters based on the specified arguments (with params)
Update parameters based on the specified arguments.
service_provider
Set the service provider that owns this component.
Static methods
register_converter
Register the argument setter for the given type.
If an operator or resource has an argument with a custom type, the argument setter must be registered using this method.
The argument setter is used to set the value of the argument from the YAML configuration.
This method can be called in the initialization phase of the operator/resource (e.g., initialize()). The example below shows how to register the argument setter for the custom type (Vec3):
It is assumed that YAML::convert<T>::encode and YAML::convert<T>::decode are implemented for the given type. You need to specialize the YAML::convert<> template class.
For example, suppose that you had a Vec3 class with the following members:
You can define the YAML::convert<Vec3> as follows in a ‘.cpp’ file:
Please refer to the yaml-cpp documentation for more details.
Template parameters
The type of the argument to register.
Example
Example
Example
register_argument_setter
Register the argument setter for the given type.
Please refer to the documentation of register_converter() for more details.
Template parameters
The type of the argument to register.
Types
ResourceType
Resource type used for the initialization of the resource.