holoscan::gxf::GXFExtensionRegistrar

Beta
View as Markdown

Class to register a GXF extension.

This class is a helper class to register a GXF extension. GXFLoadExtensionFromPointer() API is used to register the extension programmatically.

#include <holoscan/gxf/gxf_extension_registrar.hpp>

Constructors

GXFExtensionRegistrar

holoscan::gxf::GXFExtensionRegistrar::GXFExtensionRegistrar(holoscan::gxf::GXFExtensionRegistrar::GXFExtensionRegistrar(
gxf_context_t context,
const char *extension_name,
const char *extension_description = "",
gxf_tid_t tid = {0,
0}
)

Construct a new GXFExtensionRegistrar object.

If tid is not provided, a random tid is generated and used to register the extension.

Parameters

context
gxf_context_t

The pointer to the GXF context.

extension_name
const char *

The name of the extension.

extension_description
const char *Defaults to ""

A description of the extension.

tid
gxf_tid_tDefaults to {0, 0}

The type ID of the extension to use.


Methods

is_allocated

bool holoscan::gxf::GXFExtensionRegistrar::is_allocated(
gxf_tid_t tid,
TypeKind kind
) const

Check if the given tid is already allocated.

Returns: true If the tid is already allocated. Otherwise, false.

Parameters

tid
gxf_tid_t

The tid to check.

kind
TypeKind

The kind of the tid to check.

allocate_tid

gxf_tid_t holoscan::gxf::GXFExtensionRegistrar::allocate_tid(
TypeKind kind
)

Create a random tid that is not allocated.

Returns: The allocated tid.

Parameters

kind
TypeKind

The kind of the tid to create.

add_component

template <typename T, typename Base>
bool holoscan::gxf::GXFExtensionRegistrar::add_component(
const char *description = "",
gxf_tid_t tid = {0,
0}
)

Add a component to the extension.

If tid is not provided, a random tid is generated and used to register the component.

Returns: true If the component is added successfully. Otherwise, false.

Template parameters

T
typename

The type of the component.

Base
typename

The base type of the component.

Parameters

description
const char *Defaults to ""

The description of the component.

tid
gxf_tid_tDefaults to {0, 0}

The type ID of the component to use.

add_type

template <typename T>
bool holoscan::gxf::GXFExtensionRegistrar::add_type(
const char *description = "",
gxf_tid_t tid = {0,
0}
)

Add a type to the extension.

If tid is not provided, a random tid is generated and used to register the type.

Returns: true If the type is added successfully. Otherwise, false.

Template parameters

T
typename

The type to add.

Parameters

description
const char *Defaults to ""

The description of the type.

tid
gxf_tid_tDefaults to {0, 0}

The type ID of the type to use.

register_extension

bool holoscan::gxf::GXFExtensionRegistrar::register_extension(
nvidia::gxf::Extension **out_extension_ptr = nullptr
)

Register the extension.

Returns: true If the extension is registered successfully. Otherwise, false.

Parameters

out_extension_ptr
nvidia::gxf::Extension **Defaults to nullptr

If provided, the pointer to the extension is set to this pointer.

reset

void holoscan::gxf::GXFExtensionRegistrar::reset(
gxf_context_t context,
const char *extension_name,
const char *extension_description = "",
gxf_tid_t tid = {0,
0}
)

Reset the GXFExtensionRegistrar object.

If tid is not provided, a random tid is generated and used to register the extension.

Parameters

context
gxf_context_t

The pointer to the GXF context.

extension_name
const char *

The name of the extension.

extension_description
const char *Defaults to ""

The description of the extension.

tid
gxf_tid_tDefaults to {0, 0}

The type ID of the extension to use.


Static methods

create_random_tid

static gxf_tid_t holoscan::gxf::GXFExtensionRegistrar::create_random_tid()

Create a random tid object.

Generate a sudo random tid using std::mt19937_64. This implementation does not guarantee that the tid is unique.

Returns: A random tid.


Types

TypeKind

Kind of the Type.

NameValueDescription
kExtensionExtension.
kComponentComponent.

Member variables

NameTypeDescription
context_gxf_context_t
factory_std::unique_ptr< nvidia::gxf::DefaultExtension >
allocated_tids_std::set< gxf_tid_t >
extension_tid_gxf_tid_t