Class BufferBackend

Class Documentation

class BufferBackend

Abstract interface for vendor-specific buffer backend implementations.

Public Functions

virtual ~BufferBackend() = default
virtual std::string get_backend_type() const = 0

Get the backend type name.

inline virtual std::string get_backend_metadata() const

Get the backend metadata string. This is used by the backend to pass backend-specific information to other endpoints.

virtual const rosidl_message_type_support_t *get_descriptor_type_support() const = 0

Get the message type support handle for this backend’s descriptor type. Implementations should return the generic aggregate handle, typically via rosidl_typesupport_cpp::get_message_type_support_handle<YourDescriptor>(). The consuming RMW resolves this aggregate to the concrete per-typesupport library handle it needs at runtime (e.g. rosidl_typesupport_fastrtps_cpp), so the plugin itself stays RMW-agnostic.

virtual std::shared_ptr<void> create_empty_descriptor() const = 0

Create an empty descriptor message instance for this backend. The returned object must match get_descriptor_type_support().

virtual std::shared_ptr<void> create_descriptor_with_endpoint(const void *impl, const rmw_topic_endpoint_info_t &endpoint_info) const = 0

Create a descriptor message with endpoint awareness.

Parameters:
  • impl – Non-owning, type-erased BufferImplBase pointer (read-only). Backends that need internal bookkeeping (e.g. IPC handle setup, memory pinning) should use mutable members in their impl class.

  • endpoint_info – Endpoint info for the peer.

Returns:

Type-erased descriptor message, or nullptr if the backend cannot handle this endpoint (e.g., the peer does not support this backend). Returning nullptr signals the serialization layer to fall back to CPU-based serialization. The descriptor must not exceed kMaxBufferDescriptorSize bytes.

virtual std::unique_ptr<void, void (*)(void*)> from_descriptor_with_endpoint(const void *descriptor, const rmw_topic_endpoint_info_t &endpoint_info) const = 0

Create a BufferImpl from descriptor with endpoint awareness.

Parameters:
  • descriptor – Non-owning, type-erased descriptor message pointer (read-only).

  • endpoint_info – Endpoint info for the peer.

Returns:

Type-erased unique pointer to a newly created BufferImplBase instance. The custom deleter ensures correct destruction across the plugin boundary.

inline virtual void on_creating_endpoint(const rmw_topic_endpoint_info_t &endpoint_info) const

Hook invoked when creating a local endpoint.

inline virtual std::pair<bool, std::vector<std::set<uint32_t>>> on_discovering_endpoint(const rmw_topic_endpoint_info_t &endpoint_info, const std::vector<rmw_topic_endpoint_info_t> &existing_endpoints, const std::unordered_map<std::string, std::string> &endpoint_supported_backends)

Hook invoked when discovering a remote endpoint. Returns {compatible, groups of endpoint GID hashes}.

Parameters:
  • endpoint_info – Information about the discovered endpoint

  • existing_endpoints – List of existing endpoints for grouping decisions

  • endpoint_supported_backends – Map of backend type to backend metadata string for the discovered endpoint