> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::gxf::GXFExtensionRegistrar

> Class to register a GXF extension.

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.

```cpp showLineNumbers={false}
#include <holoscan/gxf/gxf_extension_registrar.hpp>
```

---

## Constructors

### GXFExtensionRegistrar \[#gxfextensionregistrar]

#### Construct a new \`GXFExtensionRegistrar\` object

```cpp showLineNumbers={false}
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 *` — default: ""

A description of the extension.

---

**`tid`** `gxf_tid_t` — default: \{0, 0}

The type ID of the extension to use.

---

#### Deleted overload 1

```cpp showLineNumbers={false}
holoscan::gxf::GXFExtensionRegistrar::GXFExtensionRegistrar() = delete
```

---

## Methods

### is\_allocated \[#isallocated]

```cpp showLineNumbers={false}
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 \[#allocatetid]

```cpp showLineNumbers={false}
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 \[#addcomponent]

```cpp showLineNumbers={false}
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 *` — default: ""

The description of the component.

---

**`tid`** `gxf_tid_t` — default: \{0, 0}

The type ID of the component to use.

---

### add\_type \[#addtype]

```cpp showLineNumbers={false}
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 *` — default: ""

The description of the type.

---

**`tid`** `gxf_tid_t` — default: \{0, 0}

The type ID of the type to use.

---

### register\_extension \[#registerextension]

```cpp showLineNumbers={false}
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 **` — default: nullptr

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

---

### reset \[#reset]

```cpp showLineNumbers={false}
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 *` — default: ""

The description of the extension.

---

**`tid`** `gxf_tid_t` — default: \{0, 0}

The type ID of the extension to use.

---

---

## Static methods

### create\_random\_tid \[#createrandomtid]

```cpp showLineNumbers={false}
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.

| Name         | Value | Description                              |
| ------------ | ----- | ---------------------------------------- |
| `kExtension` |       | Extension.                               |
| `kComponent` |       | [Component](../../../classes/component). |

---

## Member variables

| Name              | Type                                               | Description |
| ----------------- | -------------------------------------------------- | ----------- |
| `context_`        | `gxf_context_t`                                    |             |
| `factory_`        | `std::unique_ptr< nvidia::gxf::DefaultExtension >` |             |
| `allocated_tids_` | `std::set< gxf_tid_t >`                            |             |
| `extension_tid_`  | `gxf_tid_t`                                        |             |