Class Resource

Base Type

Derived Type

class Resource : public holoscan::Component

Base class for all resources.

Resources such as system memory or a GPU memory pool that an Operator needs to perform its job. Resources are allocated during the initialization phase of the application. This matches the semantics of GXF’s Memory Allocator or any other components derived from the Component class in GXF.

Subclassed by holoscan::gxf::GXFResource

Public Functions

Resource() = default

Resource(Resource&&) = default

template<typename ArgT, typename ...ArgsT, typename = std::enable_if_t<!std::is_base_of_v<Resource, std::decay_t<ArgT>> && (std::is_same_v<Arg, std::decay_t<ArgT>> || std::is_same_v<ArgList, std::decay_t<ArgT>>)>>
inline Resource(ArgT &&arg, ArgsT&&... args)

~Resource() override = default

inline Resource &name(const std::string &name) &

Set the name of the resource.

Parameters:

name – The name of the resource.

Returns:

The reference to the resource.

inline Resource &&name(const std::string &name) &&

Set the name of the resource.

Parameters:

name – The name of the resource.

Returns:

The reference to the resource.

inline Resource &fragment(Fragment *fragment)

Set the fragment of the resource.

Parameters:

fragment – The pointer to the fragment of the resource.

Returns:

The reference to the resource.

inline Resource &spec(std::unique_ptr<ComponentSpec> spec)

Set the component specification to the resource.

The component specification would be ‘moved’ to the resource.

Parameters:

spec – The component specification.

Returns:

The reference to the resource.

inline ComponentSpec *spec()

Get the component specification of the resource.

Returns:

The pointer to the component specification.

inline virtual void setup(ComponentSpec &spec)

Define the resource specification.

Parameters:

spec – The reference to the component specification.

inline const std::string &name() const

Get the name of the component.

Returns:

The name of the component.

inline Fragment *fragment()

Get a pointer to Fragment object.

Returns:

The Pointer to Fragment object.

inline void add_arg(const Arg &arg)

Add an argument to the component.

Parameters:

arg – The argument to add.

inline void add_arg(Arg &&arg)

Add an argument to the component.

Parameters:

arg – The argument to add.

inline void add_arg(const ArgList &arg)

Add a list of arguments to the component.

Parameters:

arg – The list of arguments to add.

inline void add_arg(ArgList &&arg)

Add a list of arguments to the component.

Parameters:

arg – The list of arguments to add.

Protected Attributes

std::unique_ptr<ComponentSpec> spec_

The component specification.

© Copyright 2022, NVIDIA. Last updated on Jun 28, 2023.