NVIDIA Holoscan SDK v3.5.0

Class DefaultFragmentService

Base Type

class DefaultFragmentService : public holoscan::FragmentService

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.

Note

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

Public Functions

DefaultFragmentService() = default
explicit DefaultFragmentService(const std::shared_ptr<Resource> &resource)

Construct a service managing the specified resource.

Parameters

resource – The resource to be managed by this service.

~DefaultFragmentService() = default
DefaultFragmentService(const DefaultFragmentService&) = delete
DefaultFragmentService &operator=(const DefaultFragmentService&) = delete
DefaultFragmentService(DefaultFragmentService&&) = default
DefaultFragmentService &operator=(DefaultFragmentService&&) = default
template<typename ResourceT>
inline virtual std::shared_ptr<ResourceT> 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.

Template Parameters

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

Returns

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

inline virtual std::shared_ptr<Resource> resource() const override

Get the underlying resource without type casting.

Returns

Shared pointer to the managed resource.

inline virtual void resource(const std::shared_ptr<Resource> &resource) override

Set the underlying resource.

Parameters

resource – The resource to be managed by this service.

Protected Attributes

std::shared_ptr<Resource> resource_

The managed resource instance.

Friends

friend class Fragment

Previous Class DataLoggerResource
Next Class DFFTCollector
© Copyright 2022-2025, NVIDIA. Last updated on Sep 4, 2025.