> 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::ComponentSpec

> Class to define the specification of a component.

Class to define the specification of a component.

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

---

## Constructors

### ComponentSpec \[#componentspec]

```cpp showLineNumbers={false}
holoscan::ComponentSpec::ComponentSpec(
    Fragment *fragment = nullptr
)
```

Construct a new `ComponentSpec` object.

**Parameters**

**`fragment`** `Fragment *` — default: nullptr

The pointer to the fragment that contains this component.

---

### Destructor \[#destructor]

### \~ComponentSpec

```cpp showLineNumbers={false}
virtual holoscan::ComponentSpec::~ComponentSpec() = default
```

---

## Methods

### fragment \[#fragment]

#### Overload 1

```cpp showLineNumbers={false}
void holoscan::ComponentSpec::fragment(
    Fragment *fragment
)
```

Set the pointer to the fragment that contains this component.

**Parameters**

**`fragment`** `Fragment *`

The pointer to the fragment that contains this component.

---

#### Overload 2

```cpp showLineNumbers={false}
Fragment * holoscan::ComponentSpec::fragment()
```

Get the pointer to the fragment that contains this component.

**Returns:** The pointer to the fragment that contains this component.

### param \[#param]

#### Define a parameter for this component (with flag)

inline

```cpp showLineNumbers={false}
template <typename typeT>
void holoscan::ComponentSpec::param(
    Parameter<typeT> &parameter,
    const char *key,
    ParameterFlag flag = ParameterFlag::kNone
)
```

Define a parameter for this component.

**Template parameters**

**`typeT`** `typename`

The type of the parameter.

---

**Parameters**

**`parameter`** `Parameter<typeT> &`

The parameter to define.

---

**`key`** `const char *`

The key (name) of the parameter.

---

**`flag`** `ParameterFlag` — default: ParameterFlag::kNone

The flag of the parameter (default: ParameterFlag::kNone).

---

#### Define a parameter for this component (with flag and headline)

inline

```cpp showLineNumbers={false}
template <typename typeT>
void holoscan::ComponentSpec::param(
    Parameter<typeT> &parameter,
    const char *key,
    const char *headline,
    ParameterFlag flag = ParameterFlag::kNone
)
```

Define a parameter for this component.

**Template parameters**

**`typeT`** `typename`

The type of the parameter.

---

**Parameters**

**`parameter`** `Parameter<typeT> &`

The parameter to define.

---

**`key`** `const char *`

The key (name) of the parameter.

---

**`headline`** `const char *`

The headline of the parameter.

---

**`flag`** `ParameterFlag` — default: ParameterFlag::kNone

The flag of the parameter (default: ParameterFlag::kNone).

---

#### Define a parameter for this component (with flag and headline and description)

```cpp showLineNumbers={false}
template <typename typeT>
void holoscan::ComponentSpec::param(
    Parameter<typeT> &parameter,
    const char *key,
    const char *headline,
    const char *description,
    ParameterFlag flag = ParameterFlag::kNone
)
```

Define a parameter for this component.

**Template parameters**

**`typeT`** `typename`

The type of the parameter.

---

**Parameters**

**`parameter`** `Parameter<typeT> &`

The parameter to define.

---

**`key`** `const char *`

The key (name) of the parameter.

---

**`headline`** `const char *`

The headline of the parameter.

---

**`description`** `const char *`

The description of the parameter.

---

**`flag`** `ParameterFlag` — default: ParameterFlag::kNone

The flag of the parameter (default: ParameterFlag::kNone).

---

#### Define a parameter for this component (with headline and description and init list)

```cpp showLineNumbers={false}
template <typename typeT>
void holoscan::ComponentSpec::param(
    Parameter<typeT> &parameter,
    const char *key,
    const char *headline,
    const char *description,
    std::initializer_list<void *> init_list
)
```

Define a parameter for this component.

This method is to catch the following case:

Otherwise, `{}` will be treated as `ParameterFlag::kNone` instead of `std::initializer_list`.

**Template parameters**

**`typeT`** `typename`

The type of the parameter.

---

**Parameters**

**`parameter`** `Parameter<typeT> &`

The parameter to define.

---

**`key`** `const char *`

The key (name) of the parameter.

---

**`headline`** `const char *`

The headline of the parameter.

---

**`description`** `const char *`

The description of the parameter.

---

**`init_list`** `std::initializer_list<void *>`

The initializer list of the parameter.

---

**Example**

```cpp showLineNumbers={false}
...
    spec.param(int64_value_, "int64_param", "int64_t param", "Example int64_t parameter.", {});
...
private:
 Parameter<int64_t> int64_param_;
```

#### Define a parameter that has a default value (1)

```cpp showLineNumbers={false}
template <typename typeT>
void holoscan::ComponentSpec::param(
    Parameter<typeT> &parameter,
    const char *key,
    const char *headline,
    const char *description,
    const typeT &default_value,
    ParameterFlag flag = ParameterFlag::kNone
)
```

Define a parameter that has a default value.

**Template parameters**

**`typeT`** `typename`

The type of the parameter.

---

**Parameters**

**`parameter`** `Parameter<typeT> &`

The parameter to get.

---

**`key`** `const char *`

The key (name) of the parameter.

---

**`headline`** `const char *`

The headline of the parameter.

---

**`description`** `const char *`

The description of the parameter.

---

**`default_value`** `const typeT &`

The default value of the parameter.

---

**`flag`** `ParameterFlag` — default: ParameterFlag::kNone

The flag of the parameter (default: ParameterFlag::kNone).

---

#### Define a parameter that has a default value (2)

```cpp showLineNumbers={false}
template <typename typeT>
void holoscan::ComponentSpec::param(
    Parameter<typeT> &parameter,
    const char *key,
    const char *headline,
    const char *description,
    typeT &&default_value,
    ParameterFlag flag = ParameterFlag::kNone
)
```

Define a parameter that has a default value.

**Template parameters**

**`typeT`** `typename`

The type of the parameter.

---

**Parameters**

**`parameter`** `Parameter<typeT> &`

The parameter to get.

---

**`key`** `const char *`

The key (name) of the parameter.

---

**`headline`** `const char *`

The headline of the parameter.

---

**`description`** `const char *`

The description of the parameter.

---

**`default_value`** `typeT &&`

The default value of the parameter.

---

**`flag`** `ParameterFlag` — default: ParameterFlag::kNone

The flag of the parameter (default: ParameterFlag::kNone).

---

### params \[#params]

```cpp showLineNumbers={false}
std::unordered_map<std::string, ParameterWrapper> & holoscan::ComponentSpec::params()
```

Get the parameters of this component.

**Returns:** The reference to the parameters of this component.

### to\_yaml\_node \[#toyamlnode]

```cpp showLineNumbers={false}
virtual YAML::Node holoscan::ComponentSpec::to_yaml_node() const
```

Get a `YAML` representation of the component spec.

**Returns:** `YAML` node including the parameters of this component.

### description \[#description]

```cpp showLineNumbers={false}
std::string holoscan::ComponentSpec::description() const
```

Get a description of the component spec.

**Returns:** `YAML` string.

**See also:**
to\_yaml\_node()

---

## Member variables

| Name        | Type                                                  | Description                                               |
| ----------- | ----------------------------------------------------- | --------------------------------------------------------- |
| `fragment_` | `Fragment *`                                          | The pointer to the fragment that contains this component. |
| `params_`   | `std::unordered_map< std::string, ParameterWrapper >` | The parameters of this component.                         |