holoscan::FragmentServiceProvider

Beta
View as Markdown

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.

#include <holoscan/fragment_service_provider.hpp>

Constructors

Destructor

~FragmentServiceProvider

virtual holoscan::FragmentServiceProvider::~FragmentServiceProvider() = defaultvirtual holoscan::FragmentServiceProvider::~FragmentServiceProvider() = default

Methods

get_service_erased

virtual std::shared_ptr<FragmentService> holoscan::FragmentServiceProvider::get_service_erased(virtual std::shared_ptr<FragmentService> holoscan::FragmentServiceProvider::get_service_erased(
const std::type_info &service_type,
std::string_view id
) const

Retrieves a service using type erasure.

Returns: A shared_ptr to FragmentService if found, otherwise nullptr.

Parameters

service_type
const std::type_info &

The std::type_info of the service to retrieve.

id
std::string_view

The identifier of the service instance.

get_service_resource_by_name

virtual std::shared_ptr<Resource> holoscan::FragmentServiceProvider::get_service_resource_by_name(virtual std::shared_ptr<Resource> holoscan::FragmentServiceProvider::get_service_resource_by_name(
std::string_view id
) const

Retrieve a resource registered as a fragment service by name.

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

Parameters

id
std::string_view

The service id (name) used during service registration.

get_services_by_id

virtual std::vector<std::shared_ptr<FragmentService>> holoscan::FragmentServiceProvider::get_services_by_id(virtual std::vector<std::shared_ptr<FragmentService>> holoscan::FragmentServiceProvider::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.

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

Parameters

id
std::string_view

The service id (name) used during service registration.