holoscan::FastDdsEndpoint
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:
std::vector<uint8_t> that grows automatically.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)
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.
Default destructor.
Check if write operations are available.
Returns: true if constructed in write mode with valid buffer
Check if read operations are available.
Returns: true if constructed in read mode with data remaining
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 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 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 the read position to the beginning.
Allows re-reading the buffer from the start. Only valid in read mode.
Get the current read position.
Returns: Current read position (0 in write mode)
Get the total bytes written (write mode) or buffer size (read mode).
Returns: Total size in bytes
Get remaining bytes available for reading.
Returns: Bytes remaining (0 in write mode)
Get the number of bytes written (raw buffer mode).
Returns: Bytes written in raw buffer mode, or vector size in vector mode, or 0.
Check if in write mode.
Returns: true if constructed with output buffer (vector or raw)
Check if in read mode.
Returns: true if constructed with input buffer
Get the resource type.
Returns: The resource type.
Set the name of the resource.
Returns: The reference to the resource.
Parameters
The name of the resource.
Set the fragment of the resource.
Returns: The reference to the resource.
Parameters
The pointer to the fragment of the resource.
Set the component specification to the resource.
Returns: The reference to the resource.
Parameters
The component specification.
Get the shared pointer to the component spec.
Returns: The shared pointer to the component spec.
Define the resource specification.
Parameters
The reference to the component specification.
Initialize the component.
This method is called only once when the component is created for the first time, and use of light-weight initialization.
Get a YAML representation of the resource.
Returns: YAML node including spec of the resource in addition to the base component properties.
Set the parameters based on defaults (sets GXF parameters for GXF components).
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 an argument to the component.
Parameters
The argument to add.
Get the list of arguments.
Returns: The vector of arguments.
Get a description of the component.
Returns: YAML string.
See also: to_yaml_node()
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.
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 any backend-specific objects (e.g. GXF GraphEntity).
Update parameters based on the specified arguments.
Set the service provider that owns this component.
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 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.
Resource type used for the initialization of the resource.