holoscan::DefaultFragmentService

Beta
View as Markdown

Default implementation of FragmentService for basic resource sharing.

DefaultFragmentService provides a straightforward implementation of the FragmentService interface. It manages a single Resource instance and provides type-safe access methods.

This class is designed to be used directly for simple resource sharing scenarios or as a base class for more specialized service implementations.

#include <holoscan/fragment_service.hpp>

This class is non-copyable to prevent accidental duplication of the managed resource. Move operations are supported to allow transfer of ownership.

Inherits from: holoscan::FragmentService (public)


Constructors

DefaultFragmentService

Destructor

~DefaultFragmentService

holoscan::DefaultFragmentService::~DefaultFragmentService() override = default

Assignment operators

operator=


Methods

resource

const
template <typename ResourceT>
std::shared_ptr<ResourceT> holoscan::DefaultFragmentService::resource() const

Get the resource cast to a specific type.

This templated method provides type-safe access to the managed resource. It attempts to cast the resource to the requested type using dynamic_pointer_cast.

Returns: Shared pointer to the resource cast to ResourceT, or nullptr if the cast fails.

Template parameters

ResourceT
typename

The type to cast the resource to. Must be derived from Resource.


Member variables

NameTypeDescription
resource_std::shared_ptr< Resource >The managed resource instance.