Holoscan SDK v4.0.0

Class FragmentServiceProvider

class FragmentServiceProvider

Interface for classes that can provide access to registered fragment services.

This interface is used by ComponentBase to decouple component service access from the concrete Fragment implementation, enabling better testability and modularity while still allowing service retrieval.

Subclassed by holoscan::Fragment

Public Functions

virtual ~FragmentServiceProvider() = default
virtual std::shared_ptr<FragmentService> get_service_erased(const std::type_info &service_type, std::string_view id) const = 0

Retrieves a service using type erasure.

Parameters
  • service_type – The std::type_info of the service to retrieve.

  • id – The identifier of the service instance.

Returns

A shared_ptr to FragmentService if found, otherwise nullptr.

virtual std::shared_ptr<Resource> get_service_resource_by_name(std::string_view id) const = 0

Retrieve a resource registered as a fragment service by name.

Parameters

id – The service id (name) used during service registration.

Returns

A shared_ptr to the service resource, or nullptr if not found.

inline virtual std::vector<std::shared_ptr<FragmentService>> get_services_by_id(std::string_view id) const

Retrieve all fragment services with a matching id, regardless of registered type.

This method is used as a fallback when exact type lookup fails, enabling retrieval of services registered with a derived type when looking up by a base type.

Parameters

id – The service id (name) used during service registration.

Returns

A vector of shared_ptrs to matching FragmentServices. Empty if none found.

Previous Class FragmentService
Next Class GPUDevice
© Copyright 2022-2026, NVIDIA. Last updated on Mar 9, 2026