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

> Application class.

`Application` class.

An application acquires and processes streaming data. An application is a collection of fragments where each fragment can be allocated to execute on a physical node of a Holoscan cluster.

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

**Inherits from:** `holoscan::Fragment` (public)

***

## Constructors

### Application \[#application]

```cpp showLineNumbers={false}
holoscan::Application::Application(
    const std::vector<std::string> &argv = {}
)
```

Construct a new `Application` object.

This constructor parses the command line for flags that are recognized by App Driver/Worker, and removes all recognized flags so users can use the remaining flags for their own purposes.

The command line arguments are retrieved from /proc/self/cmdline so that the single-fragment application works as expected without any command line arguments.

The arguments after processing arguments are stored in the `argv_` member variable and the reference to the vector of arguments can be accessed through the `argv()` method.

Example:

**Parameters**

The command line arguments.

**Example**

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

class MyPingApp : public holoscan::Application {
// ...
};

int main(int argc, char** argv) {
  auto my_argv =
      holoscan::Application({"myapp", "--driver", "my_arg1", "--address=10.0.0.1"}).argv();
  HOLOSCAN_LOG_INFO(" my_argv: {}", fmt::join(my_argv, " "));

  HOLOSCAN_LOG_INFO(
      "    argv: {} (argc: {}) ",
      fmt::join(std::vector<std::string>(argv, argv + argc), " "),
      argc);

  auto app_argv = holoscan::Application().argv();  // do not use reference ('auto&') here
  HOLOSCAN_LOG_INFO("app_argv: {} (size: {})", fmt::join(app_argv, " "), app_argv.size());

  auto app = holoscan::make_application<MyPingApp>();
  HOLOSCAN_LOG_INFO("app->argv() == app_argv: {}", app->argv() == app_argv);

  app->run();
  return 0;
}

// $ ./myapp --driver --input image.dat --address 10.0.0.20

//  my_argv: myapp my_arg1
//     argv: ./myapp --driver --input image.dat --address 10.0.0.20 (argc: 6)
// app_argv: ./myapp --input image.dat (size: 3)
// app->argv() == app_argv: true
```

### Destructor \[#destructor]

### \~Application

```cpp showLineNumbers={false}
holoscan::Application::~Application() override = default
```

***

## Methods

### make\_fragment \[#makefragment]

```cpp showLineNumbers={false}
template <typename FragmentT = Fragment,
          typename StringT,
          typename... ArgsT,
          typename = std::enable_if_t<std::is_constructible_v<std::string, StringT>>>
std::shared_ptr<Fragment> holoscan::Application::make_fragment(
    StringT name,
    ArgsT &&... args
)
```

Create a new fragment.

**Returns:** The shared pointer to the created fragment.

**Template parameters**

The type of the fragment to create.

**Parameters**

The name of the fragment.

The arguments to pass to the fragment constructor.

```cpp showLineNumbers={false}
template <typename FragmentT, typename... ArgsT>
std::shared_ptr<FragmentT> holoscan::Application::make_fragment(
    ArgsT &&... args
)
```

Create a new fragment.

**Returns:** The shared pointer to the created fragment.

**Template parameters**

The type of the fragment to create.

**Parameters**

The arguments to pass to the fragment constructor.

### description \[#description]

```cpp showLineNumbers={false}
std::string & holoscan::Application::description()
```

Get the application description.

**Returns:** The application description.

```cpp showLineNumbers={false}
Application & holoscan::Application::description(
    const std::string &desc
) &
```

Set the application description.

**Returns:** The reference to this application (for chaining).

**Parameters**

The application description

```cpp showLineNumbers={false}
Application && holoscan::Application::description(
    const std::string &desc
) &&
```

Set the application description.

**Returns:** The reference to this application (for chaining).

**Parameters**

The application description

### version \[#version]

```cpp showLineNumbers={false}
std::string & holoscan::Application::version()
```

Get the application version.

**Returns:** The application version.

```cpp showLineNumbers={false}
Application & holoscan::Application::version(
    const std::string &version
) &
```

Set the application version.

**Returns:** The reference to this application (for chaining).

**Parameters**

The application version

```cpp showLineNumbers={false}
Application && holoscan::Application::version(
    const std::string &version
) &&
```

Set the application version.

**Returns:** The reference to this application (for chaining).

**Parameters**

The application version

### argv \[#argv]

```cpp showLineNumbers={false}
std::vector<std::string> & holoscan::Application::argv()
```

Get the reference to the command line arguments after processing flags.

The returned vector includes the executable name as the first element.

**Returns:** The reference to the command line arguments after processing flags.

### options \[#options]

```cpp showLineNumbers={false}
CLIOptions & holoscan::Application::options()
```

Get the reference to the CLI options.

**Returns:** The reference to the CLI options.

### fragment\_graph \[#fragmentgraph]

```cpp showLineNumbers={false}
FragmentFlowGraph & holoscan::Application::fragment_graph()
```

Get the fragment connection graph.

When two operators are connected through `add_flow(Fragment, Fragment)`, the fragment connection graph is automatically updated. The fragment connection graph is used to assign transmitters and receivers to the corresponding [Operator](operator) instances in the fragment so that the application can be executed in a distributed manner.

**Returns:** The reference to the fragment connection graph ([`FragmentFlowGraph`](../typedefs/fragmentflowgraph) object.)

### add\_fragment \[#addfragment]

```cpp showLineNumbers={false}
virtual void holoscan::Application::add_fragment(
    const std::shared_ptr<Fragment> &frag
)
```

Add a fragment to the graph.

The information of the fragment is stored in the [`FragmentFlowGraph`](../typedefs/fragmentflowgraph) object. If the fragment is already added, this method does nothing.

**Parameters**

The fragment to be added.

### add\_flow \[#addflow]

```cpp showLineNumbers={false}
virtual void holoscan::Application::add_flow(
    const std::shared_ptr<Fragment> &upstream_frag,
    const std::shared_ptr<Fragment> &downstream_frag,
    const std::set<std::pair<std::string, std::string>> &port_pairs
)
```

Add a flow between two fragments.

It takes two fragments and a vector of string pairs as arguments. The vector of string pairs is used to connect the output ports of the first fragment to the input ports of the second fragment. The input and output ports of the operators are specified as a string in the format of `<operator `[`name`](#name)`>.<port `[`name`](#name)`>`. If the operator has only one input or output port, the port name can be omitted.

In the above example, the output port of the `blur_image` operator in `fragment1` is connected to the input port of the `sharpen_image` operator in `fragment2`. Since `blur_image` and `sharpen_image` operators have only one output/input port, the port names are omitted.

The information about the flow (edge) is stored in the [`FragmentFlowGraph`](../typedefs/fragmentflowgraph) object and can be accessed through the `fragment_graph()` method.

If the upstream fragment or the downstream fragment is not in the graph, it will be added to the graph.

**Parameters**

The upstream fragment.

The downstream fragment.

The port pairs. The first element of the pair is the output port of the operator in the upstream fragment and the second element is the input port of the operator in the downstream fragment.

**Example**

```cpp showLineNumbers={false}
class App : public holoscan::Application {
 public:
  void compose() override {
    using namespace holoscan;

    auto fragment1 = make_fragment<Fragment1>("fragment1");
    auto fragment2 = make_fragment<Fragment2>("fragment2");

    add_flow(fragment1, fragment2, {{"blur_image", "sharpen_image"}});
  }
};
```

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Operator> &downstream_op
)
```

Add a flow between two operators.

An output port of the upstream operator is connected to an input port of the downstream operator. The information about the flow (edge) is stored in the [`OperatorFlowGraph`](../typedefs/operatorflowgraph) object.

If the upstream operator or the downstream operator is not in the graph, it will be added to the graph.

If there are multiple output ports in the upstream operator or multiple input ports in the downstream operator, it shows an error message.

**Parameters**

The upstream operator.

The downstream operator.

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Operator> &downstream_op,
    std::set<std::pair<std::string, std::string>> port_pairs
)
```

Add a flow between two operators.

An output port of the upstream operator is connected to an input port of the downstream operator. The information about the flow (edge) is stored in the [`OperatorFlowGraph`](../typedefs/operatorflowgraph) object.

If the upstream operator or the downstream operator is not in the graph, it will be added to the graph.

In `port_pairs`, an empty port name ("") can be used for specifying a port name if the operator has only one input/output port.

If a non-existent port name is specified in `port_pairs`, it first checks if there is a parameter with the same name but with a type of `std::vector<`[`holoscan::IOSpec`](iospec)`*>` in the downstream operator. If there is such a parameter (e.g., `receivers`), it creates a new input port with a specific label (`<parameter `[`name`](#name)`>:<index>`. e.g., `receivers:0`), otherwise it shows an error message.

For example, if a parameter `receivers` want to have an arbitrary number of receivers,

class HolovizOp : public holoscan::ops::GXFOperator \{
...
private:
Parameter\<std::vector\<holoscan::IOSpec\*>> receivers\_;
...

Instead of creating a fixed number of input ports (e.g., `source_video` and `tensor`) and assigning them to the parameter (`receivers`):

void HolovizOp::setup(OperatorSpec& spec) \{
...

auto& in\_source\_video = spec.input\<holoscan::gxf::Entity>("source\_video");
auto& in\_tensor = spec.input\<holoscan::gxf::Entity>("tensor");

spec.param(receivers\_,
"receivers",
"Input Receivers",
"List of input receivers.",
\{\&in\_source\_video, \&in\_tensor});
...

You can skip the creation of input ports and assign them to the parameter (`receivers`) as follows:

void HolovizOp::setup(OperatorSpec& spec) \{
...
spec.param(receivers\_,
"receivers",
"Input Receivers",
"List of input receivers.",
\{\&in\_source\_video, \&in\_tensor});
...

This makes the following code possible in the `Application`'s `compose()` method:

add\_flow(source, visualizer\_format\_converter);
add\_flow(visualizer\_format\_converter, visualizer, \{\{"", "receivers"}});

add\_flow(source, format\_converter);
add\_flow(format\_converter, inference);
add\_flow(inference, visualizer, \{\{"", "receivers"}});

Instead of:

add\_flow(source, visualizer\_format\_converter);
add\_flow(visualizer\_format\_converter, visualizer, \{\{"", "source\_video"}});

add\_flow(source, format\_converter);
add\_flow(format\_converter, inference);
add\_flow(inference, visualizer, \{\{"", "tensor"}});

By using the parameter (`receivers`) with `std::vector<`[`holoscan::IOSpec`](iospec)`*>` type, the framework creates input ports (`receivers:0` and `receivers:1`) implicitly and connects them (and adds the references of the input ports to the `receivers` vector).

Since Holoscan SDK v2.3, users can define a multi-receiver input port using `spec.input()` with `IOSpec::kAnySize` instead of using `spec.param()` with [`Parameter`](../typedefs/parameter)`<std::vector<IOSpec*>> receivers_;`. It is now recommended to use this new `spec.input`-based approach and the old "receivers" parameter approach should be considered deprecated.

**Parameters**

The upstream operator.

The downstream operator.

The port pairs. The first element of the pair is the port of the upstream operator and the second element is the port of the downstream operator.

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Operator> &downstream_op,
    const IOSpec::ConnectorType connector_type
)
```

Add a flow between two operators with a connector type.

**Parameters**

The upstream operator.

The downstream operator.

The connector type.

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Operator> &downstream_op,
    std::set<std::pair<std::string, std::string>> port_pairs,
    const IOSpec::ConnectorType connector_type
)
```

Add a flow between two operators with specified port pairs and a connector type.

**Parameters**

The upstream operator.

The downstream operator.

The port pairs. The first element of the pair is the port of the upstream operator and the second element is the port of the downstream operator.

The connector type.

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    std::set<std::pair<std::string, std::string>> port_pairs = {}
)
```

Connect [Operator](operator) to [Subgraph](subgraph).

**Parameters**

The upstream operator

The downstream subgraph

Port connections: \{upstream\_port, subgraph\_interface\_port}

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Operator> &downstream_op,
    std::set<std::pair<std::string, std::string>> port_pairs = {}
)
```

Connect [Subgraph](subgraph) to [Operator](operator).

**Parameters**

The upstream subgraph

The downstream operator

Port connections: \{subgraph\_interface\_port, downstream\_port}

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    std::set<std::pair<std::string, std::string>> port_pairs = {}
)
```

Connect [Subgraph](subgraph) to [Subgraph](subgraph).

**Parameters**

The upstream subgraph

The downstream subgraph

Port connections: \{upstream\_interface\_port, downstream\_interface\_port}

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    const IOSpec::ConnectorType connector_type
)
```

Connect [Operator](operator) to [Subgraph](subgraph) with connector type.

**Parameters**

The upstream operator

The downstream subgraph

The connector type

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    std::set<std::pair<std::string, std::string>> port_pairs,
    const IOSpec::ConnectorType connector_type
)
```

Connect [Operator](operator) to [Subgraph](subgraph) with port pairs and connector type.

**Parameters**

The upstream operator

The downstream subgraph

Port connections: \{upstream\_port, subgraph\_interface\_port}

The connector type

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Operator> &downstream_op,
    const IOSpec::ConnectorType connector_type
)
```

Connect [Subgraph](subgraph) to [Operator](operator) with connector type.

**Parameters**

The upstream subgraph

The downstream operator

The connector type

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Operator> &downstream_op,
    std::set<std::pair<std::string, std::string>> port_pairs,
    const IOSpec::ConnectorType connector_type
)
```

Connect [Subgraph](subgraph) to [Operator](operator) with port pairs and connector type.

**Parameters**

The upstream subgraph

The downstream operator

Port connections: \{subgraph\_interface\_port, downstream\_port}

The connector type

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    const IOSpec::ConnectorType connector_type
)
```

Connect [Subgraph](subgraph) to [Subgraph](subgraph) with connector type.

**Parameters**

The upstream subgraph

The downstream subgraph

The connector type

```cpp showLineNumbers={false}
virtual void holoscan::Fragment::add_flow(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    std::set<std::pair<std::string, std::string>> port_pairs,
    const IOSpec::ConnectorType connector_type
)
```

Connect [Subgraph](subgraph) to [Subgraph](subgraph) with port pairs and connector type.

**Parameters**

The upstream subgraph

The downstream subgraph

Port connections: \{upstream\_interface\_port, downstream\_interface\_port}

The connector type

### compose\_graph \[#composegraph]

```cpp showLineNumbers={false}
void holoscan::Application::compose_graph() override
```

Calls compose() if the fragment graph is not composed yet.

### run \[#run]

```cpp showLineNumbers={false}
void holoscan::Application::run() override
```

Initialize the graph and run the graph.

This method calls `compose()` to compose the graph, and runs the graph.

### run\_async \[#runasync]

```cpp showLineNumbers={false}
std::future<void> holoscan::Application::run_async() override
```

Initialize the graph and run the graph asynchronously.

This method calls `compose()` to compose the graph, and runs the graph asynchronously.

**Returns:** The future object.

### track\_distributed \[#trackdistributed]

```cpp showLineNumbers={false}
std::unordered_map<std::string, DataFlowTracker *> holoscan::Application::track_distributed(
    uint64_t num_start_messages_to_skip = kDefaultNumStartMessagesToSkip,
    uint64_t num_last_messages_to_discard = kDefaultNumLastMessagesToDiscard,
    int latency_threshold = kDefaultLatencyThreshold,
    bool is_limited_tracking = false
)
```

Returns a map of fragment names to DataFlowTracker\* corresponding to respective fragments.

The trackers will store cumulatively progressive timestamps, meaning a fragment tracker will store the timestamps of operators in the previous fragments as well.

**Returns:** std::unordered\_map\<std::string, DataFlowTracker\*> [Fragment](fragment) name to DataFlowTracker\* mapping.

**Parameters**

The number of start messages to skip.

The number of last messages to discard.

The latency threshold.

Whether to enable limited tracking for performance.

### is\_metadata\_enabled \[#ismetadataenabled]

```cpp showLineNumbers={false}
void holoscan::Application::is_metadata_enabled(
    bool enable
) override
```

Deprecated method to enable or disable metadata for the application.

Please use [`enable_metadata`](#enablemetadata) instead.

**Parameters**

Boolean indicating whether metadata should be enabled.

const

```cpp showLineNumbers={false}
bool holoscan::Application::is_metadata_enabled() const override
```

Determine whether metadata is enabled by default for operators in this application.

Note that individual fragments may override the application-level default via [`Fragment::enable_metadata`](fragment#enablemetadata) and individual operators may override their fragment's default via [`Operator::enable_metadata`](gpuresidentoperator#enablemetadata).

**Returns:** Boolean indicating whether metadata is enabled.

### enable\_metadata \[#enablemetadata]

```cpp showLineNumbers={false}
void holoscan::Application::enable_metadata(
    bool enable
) override
```

Enable or disable metadata for the application.

Controls whether metadata is enabled or disabled by default for fragments in this application. Individual fragments of a distributed application can override this setting using the `Fragment::enable_metadata()` method. Similarly, individual operators can override the default for their fragment by using the `Operator::enable_metadata()` method.

**Parameters**

Boolean indicating whether metadata should be enabled.

### metadata\_policy \[#metadatapolicy]

```cpp showLineNumbers={false}
void holoscan::Application::metadata_policy(
    MetadataPolicy policy
) override
```

Set the default metadata update policy to be used for fragments within this application.

The metadata policy determines how metadata is merged across multiple receive calls:

* `MetadataPolicy::kUpdate`: Update the existing value when a key already exists.
* `MetadataPolicy::kInplaceUpdate`: Update the existing [MetadataObject](../typedefs/metadataobject)'s value in-place when a key already exists.
* `MetadataPolicy::kReject`: Do not modify the existing value if a key already exists.
* `MetadataPolicy::kRaise`: Raise an exception if a key already exists (default).

For distributed applications, individual fragments can override the application-level default via [`Fragment::metadata_policy`](fragment#metadatapolicy).

**Parameters**

The metadata update policy to be used by this operator.

const

```cpp showLineNumbers={false}
MetadataPolicy holoscan::Application::metadata_policy() const override
```

Get the default metadata update policy used for fragments within this application.

If a value was set for a specific fragment via [`Fragment::metadata_policy`](fragment#metadatapolicy) that value will take precedence over this application default. Similarly individual operators can override the default policy for their fragment via [`Operator::metadata_policy`](gpuresidentoperator#metadatapolicy).

**Returns:** The default metadata update policy used by operators in this fragment.

### app\_driver\_client \[#appdriverclient]

```cpp showLineNumbers={false}
std::shared_ptr<distributed::AppDriverClient> holoscan::Application::app_driver_client() const
```

Get the AppDriverClient for the application.

**Returns:** The shared pointer to the AppDriverClient.

### initiate\_distributed\_app\_shutdown \[#initiatedistributedappshutdown]

```cpp showLineNumbers={false}
void holoscan::Application::initiate_distributed_app_shutdown(
    const std::string &fragment_name
)
```

Initiate shutdown of the distributed application.

This method initiates a shutdown of the distributed application by calling the `initiate_shutdown` method on the AppDriverClient.

**Parameters**

The name of the fragment initiating the shutdown.

### add\_data\_logger \[#adddatalogger]

```cpp showLineNumbers={false}
void holoscan::Application::add_data_logger(
    const std::shared_ptr<DataLogger> &logger
)
```

Add a data logger to the application.

This method adds a data logger to the application. For distributed applications, the data logger is added to each fragment in the fragment graph.

**Parameters**

The data logger to add.

### name \[#name]

```cpp showLineNumbers={false}
Fragment & holoscan::Application::name(
    const std::string &name
) &
```

Set the name of the operator.

**Returns:** The reference to this fragment (for chaining).

**Parameters**

The name of the operator.

```cpp showLineNumbers={false}
Fragment && holoscan::Application::name(
    const std::string &name
) &&
```

Set the name of the operator.

**Returns:** The reference to this fragment (for chaining).

**Parameters**

The name of the operator.

const

```cpp showLineNumbers={false}
const std::string & holoscan::Application::name() const
```

Get the name of the fragment.

**Returns:** The name of the fragment.

### application \[#application]

```cpp showLineNumbers={false}
Fragment & holoscan::Application::application(
    Application *app
)
```

Set the application of the fragment.

**Returns:** The reference to this fragment (for chaining).

**Parameters**

The pointer to the application of the fragment.

const

```cpp showLineNumbers={false}
Application * holoscan::Application::application() const
```

Get the application of the fragment.

**Returns:** The pointer to the application of the fragment.

### config \[#config]

```cpp showLineNumbers={false}
void holoscan::Application::config(
    const std::string &config_file,
    const std::string &prefix = ""
)
```

Set the configuration of the fragment.

The configuration file is a `YAML` file that has the information of GXF extension paths and some parameter values for operators.

The `extensions` field in the `YAML` configuration file is a list of GXF extension paths. The paths can be absolute or relative to the current working directory, considering paths in `LD_LIBRARY_PATH` environment variable.

The paths can consist of the following parts:

* GXF core extensions
  built-in extensions such as libgxf\_std.so and libgxf\_cuda.so.
  libgxf\_std.so, libgxf\_cuda.so, libgxf\_multimedia.so, libgxf\_serialization.so are always loaded by default.
  GXF core extensions are copied to the lib directory of the build/installation directory.
  * built-in extensions such as `libgxf_std.so` and `libgxf_cuda.so`.
  * `libgxf_std.so`, `libgxf_cuda.so`, `libgxf_multimedia.so`, `libgxf_serialization.so` are always loaded by default.
  * GXF core extensions are copied to the `lib` directory of the build/installation directory.
* Other GXF extensions
  GXF extensions that are required for operators that this fragment uses.
  some core GXF extensions such as libgxf\_stream\_playback.so are always loaded by default.
  these paths are usually relative to the build/installation directory.
  * GXF extensions that are required for operators that this fragment uses.
  * some core GXF extensions such as `libgxf_stream_playback.so` are always loaded by default.
  * these paths are usually relative to the build/installation directory.

The extension paths are used to load dependent GXF extensions at runtime when `::run()` method is called.

For other fields in the `YAML` file, you can freely define the parameter values for operators/fragments.

For example:

You can get the value of this configuration file by calling `::from_config()` method.

If the application is executed with `--`[`config`](#config) option or HOLOSCAN\_CONFIG\_PATH environment, the configuration file is overridden by the configuration file specified by the option or environment variable.

**Throws:** `RuntimeError` if the config\_file is non-empty and the file doesn't exist.

**Parameters**

The path to the configuration file.

The prefix string that is prepended to the key of the configuration. (not implemented yet)

**Example**

```cpp showLineNumbers={false}
extensions:
  - libmy_recorder.so

replayer:
  directory: "../data/racerx"
  basename: "racerx"
  frame_rate: 0   # as specified in timestamps
  repeat: false   # default: false
  realtime: true  # default: true
  count: 0        # default: 0 (no frame count restriction)

recorder:
  out_directory: "/tmp"
  basename: "tensor_out"
```

```cpp showLineNumbers={false}
void holoscan::Application::config(
    std::shared_ptr<Config> &config
)
```

Set the configuration of the fragment.

If you want to set the configuration of the fragment manually, you can use this method. However, it is recommended to use `::config(const std::string&, const std::string&)` method because once you set the configuration manually, you cannot get the configuration from the override file (through `--`[`config`](#config) option or HOLOSCAN\_CONFIG\_PATH environment variable).

**Parameters**

The shared pointer to the configuration of the fragment ([`Config`](config) object).

```cpp showLineNumbers={false}
Config & holoscan::Application::config()
```

Get the configuration of the fragment.

**Returns:** The reference to the configuration of the fragment ([`Config`](config) object.)

### config\_shared \[#configshared]

```cpp showLineNumbers={false}
std::shared_ptr<Config> holoscan::Application::config_shared()
```

Get the shared pointer to the configuration of the fragment.

**Returns:** The shared pointer to the configuration of the fragment.

### graph \[#graph]

```cpp showLineNumbers={false}
OperatorFlowGraph & holoscan::Application::graph()
```

Get the graph of the fragment.

**Returns:** The reference to the graph of the fragment ([`OperatorFlowGraph`](../typedefs/operatorflowgraph) object.)

### graph\_shared \[#graphshared]

```cpp showLineNumbers={false}
std::shared_ptr<OperatorFlowGraph> holoscan::Application::graph_shared()
```

Get the shared pointer to the graph of the fragment.

**Returns:** The shared pointer to the graph of the fragment.

### executor \[#executor]

```cpp showLineNumbers={false}
void holoscan::Application::executor(
    const std::shared_ptr<Executor> &executor
)
```

Set the executor of the fragment.

**Parameters**

The executor to be added.

```cpp showLineNumbers={false}
Executor & holoscan::Application::executor()
```

Get the executor of the fragment.

**Returns:** The reference to the executor of the fragment ([`Executor`](executor) object.)

### executor\_shared \[#executorshared]

```cpp showLineNumbers={false}
std::shared_ptr<Executor> holoscan::Application::executor_shared()
```

Get the shared pointer to the executor of the fragment.

**Returns:** The shared pointer to the executor of the fragment.

### scheduler \[#scheduler]

```cpp showLineNumbers={false}
std::shared_ptr<Scheduler> holoscan::Application::scheduler()
```

Get the scheduler used by the executor.

**Returns:** The reference to the scheduler of the fragment's executor ([`Scheduler`](scheduler) object.)

const

```cpp showLineNumbers={false}
std::shared_ptr<Scheduler> holoscan::Application::scheduler() const
```

Get the scheduler used by the executor.

**Returns:** The reference to the scheduler of the fragment's executor ([`Scheduler`](scheduler) object.)

```cpp showLineNumbers={false}
void holoscan::Application::scheduler(
    const std::shared_ptr<Scheduler> &scheduler
)
```

Set the scheduler used by the executor.

**Parameters**

The scheduler to be added.

### network\_context \[#networkcontext]

```cpp showLineNumbers={false}
std::shared_ptr<NetworkContext> holoscan::Application::network_context()
```

Get the network context used by the executor.

**Returns:** The reference to the network context of the fragment's executor ([`NetworkContext`](networkcontext) object.)

```cpp showLineNumbers={false}
void holoscan::Application::network_context(
    const std::shared_ptr<NetworkContext> &network_context
)
```

Set the network context used by the executor.

**Parameters**

The network context to be added.

### create\_pubsub\_network\_context \[#createpubsubnetworkcontext]

```cpp showLineNumbers={false}
virtual std::shared_ptr<NetworkContext> holoscan::Application::create_pubsub_network_context()
```

Create the [NetworkContext](networkcontext) for PubSub connectors.

Called by the executor when PubSub connectors are detected and no [NetworkContext](networkcontext) has been explicitly set via `network_context()`.

Override in your `Application` subclass to return a custom [PubSubContext](pubsubcontext) subclass with a concrete backend:

**Returns:** A new [NetworkContext](networkcontext) to use for PubSub connectors.

**Example**

```cpp showLineNumbers={false}
std::shared_ptr<NetworkContext> create_pubsub_network_context() override {
  return make_network_context<MyCustomPubSubContext>("pubsub_context");
}
```

### from\_config \[#fromconfig]

```cpp showLineNumbers={false}
ArgList holoscan::Application::from_config(
    const std::string &key
)
```

Get the Argument(s) from the configuration file.

For the given key, this method returns the value of the configuration file.

For example:

[`from_config`](#fromconfig)`("capture_card")` returns an [ArgList](arglist) (vector-like) object that contains the following items:

* [`Arg`](arg)`("width") = 1920`
* [`Arg`](arg)`("height") = 1080`
* [`Arg`](arg)`("rdma") = true`

You can use '.' (dot) to access nested fields.

[`from_config`](#fromconfig)`("capture_card.rdma")` returns an [ArgList](arglist) object that contains only one item and it can be converted to `bool` through `ArgList::as()` method:

**Returns:** The argument list of the configuration for the key.

**Parameters**

The key of the configuration.

**Example**

```cpp showLineNumbers={false}
source: "replayer"
do_record: false   # or 'true' if you want to record input video stream.

capture_card:
  width: 1920
  height: 1080
  rdma: true
```

**Example**

```cpp showLineNumbers={false}
auto is_rdma = from_config("capture_card.rdma").as<bool>();
```

### config\_keys \[#configkeys]

```cpp showLineNumbers={false}
std::unordered_set<std::string> holoscan::Application::config_keys()
```

Determine the set of keys present in a [Fragment](fragment)'s config.

**Returns:** The set of valid keys.

### make\_operator \[#makeoperator]

```cpp showLineNumbers={false}
template <typename OperatorT,
          typename StringT,
          typename... ArgsT,
          typename = std::enable_if_t<std::is_constructible_v<std::string, StringT>>>
std::shared_ptr<OperatorT> holoscan::Application::make_operator(
    StringT name,
    ArgsT &&... args
)
```

Create a new operator.

**Returns:** The shared pointer to the operator.

**Template parameters**

The type of the operator.

**Parameters**

The name of the operator.

The arguments for the operator.

```cpp showLineNumbers={false}
template <typename OperatorT, typename... ArgsT>
std::shared_ptr<OperatorT> holoscan::Application::make_operator(
    ArgsT &&... args
)
```

Create a new operator.

**Returns:** The shared pointer to the operator.

**Template parameters**

The type of the operator.

**Parameters**

The arguments for the operator.

### make\_resource \[#makeresource]

```cpp showLineNumbers={false}
template <typename ResourceT,
          typename StringT,
          typename... ArgsT,
          typename = std::enable_if_t<std::is_constructible_v<std::string, StringT>>>
std::shared_ptr<ResourceT> holoscan::Application::make_resource(
    StringT name,
    ArgsT &&... args
)
```

Create a new (operator) resource.

**Returns:** The shared pointer to the resource.

**Template parameters**

The type of the resource.

**Parameters**

The name of the resource.

The arguments for the resource.

```cpp showLineNumbers={false}
template <typename ResourceT, typename... ArgsT>
std::shared_ptr<ResourceT> holoscan::Application::make_resource(
    ArgsT &&... args
)
```

Create a new (operator) resource.

**Returns:** The shared pointer to the resource.

**Template parameters**

The type of the resource.

**Parameters**

The arguments for the resource.

### make\_condition \[#makecondition]

```cpp showLineNumbers={false}
template <typename ConditionT,
          typename StringT,
          typename... ArgsT,
          typename = std::enable_if_t<std::is_constructible_v<std::string, StringT>>>
std::shared_ptr<ConditionT> holoscan::Application::make_condition(
    StringT name,
    ArgsT &&... args
)
```

Create a new condition.

**Returns:** The shared pointer to the condition.

**Template parameters**

The type of the condition.

**Parameters**

The name of the condition.

The arguments for the condition.

```cpp showLineNumbers={false}
template <typename ConditionT, typename... ArgsT>
std::shared_ptr<ConditionT> holoscan::Application::make_condition(
    ArgsT &&... args
)
```

Create a new condition.

**Returns:** The shared pointer to the condition.

**Template parameters**

The type of the condition.

**Parameters**

The arguments for the condition.

### make\_scheduler \[#makescheduler]

```cpp showLineNumbers={false}
template <typename SchedulerT,
          typename StringT,
          typename... ArgsT,
          typename = std::enable_if_t<std::is_constructible_v<std::string, StringT>>>
std::shared_ptr<SchedulerT> holoscan::Application::make_scheduler(
    StringT name,
    ArgsT &&... args
)
```

Create a new scheduler.

**Returns:** The shared pointer to the scheduler.

**Template parameters**

The type of the scheduler.

**Parameters**

The name of the scheduler.

The arguments for the scheduler.

```cpp showLineNumbers={false}
template <typename SchedulerT, typename... ArgsT>
std::shared_ptr<SchedulerT> holoscan::Application::make_scheduler(
    ArgsT &&... args
)
```

Create a new scheduler.

**Returns:** The shared pointer to the scheduler.

**Template parameters**

The type of the scheduler.

**Parameters**

The arguments for the scheduler.

### make\_network\_context \[#makenetworkcontext]

```cpp showLineNumbers={false}
template <typename NetworkContextT,
          typename StringT,
          typename... ArgsT,
          typename = std::enable_if_t<std::is_constructible_v<std::string, StringT>>>
std::shared_ptr<NetworkContextT> holoscan::Application::make_network_context(
    StringT name,
    ArgsT &&... args
)
```

Create a new network context.

**Returns:** The shared pointer to the network context.

**Template parameters**

The type of the network context.

**Parameters**

The name of the network context.

The arguments for the network context.

```cpp showLineNumbers={false}
template <typename NetworkContextT, typename... ArgsT>
std::shared_ptr<NetworkContextT> holoscan::Application::make_network_context(
    ArgsT &&... args
)
```

Create a new network context.

**Returns:** The shared pointer to the network context.

**Template parameters**

The type of the network context.

**Parameters**

The arguments for the network context.

### make\_thread\_pool \[#makethreadpool]

```cpp showLineNumbers={false}
std::shared_ptr<ThreadPool> holoscan::Application::make_thread_pool(
    const std::string &name,
    int64_t initial_size = 1
)
```

Create a new thread pool resource.

**Returns:** The shared pointer to the thread pool resource.

**Parameters**

The name of the thread pool.

The initial number of threads in the thread pool.

### add\_default\_green\_context\_pool \[#adddefaultgreencontextpool]

```cpp showLineNumbers={false}
std::shared_ptr<CudaGreenContextPool> holoscan::Application::add_default_green_context_pool(
    int32_t dev_id,
    std::vector<uint32_t> sms_per_partition = {},
    int32_t default_context_index = -1,
    uint32_t min_sm_size = 2
)
```

Add default green context pool.

**Returns:** The shared pointer to the green context pool resource.

**Parameters**

The device id.

The number of SMs per partition.

The index of the default green context.

The minimum number of SMs per partition.

### get\_default\_green\_context\_pool \[#getdefaultgreencontextpool]

```cpp showLineNumbers={false}
std::shared_ptr<CudaGreenContextPool> holoscan::Application::get_default_green_context_pool()
```

Get the default green context pool.

**Returns:** The shared pointer to the default green context pool.

### get\_service\_erased \[#getserviceerased]

```cpp showLineNumbers={false}
std::shared_ptr<FragmentService> holoscan::Application::get_service_erased(
    const std::type_info &service_type,
    std::string_view id
) const override
```

Get a fragment service by type information and identifier.

Implementation of the [FragmentServiceProvider](fragmentserviceprovider) interface method for retrieving registered fragment services using runtime type information. This method provides type-erased access to services and is thread-safe.

**Returns:** The shared pointer to the fragment service, or nullptr if not found.

**Parameters**

The type information of the service to retrieve.

The identifier of the service. If empty, retrieves by type only.

### get\_service\_resource\_by\_name \[#getserviceresourcebyname]

```cpp showLineNumbers={false}
std::shared_ptr<Resource> holoscan::Application::get_service_resource_by_name(
    std::string_view id
) const override
```

Retrieve a resource registered as a fragment service by name.

**Returns:** The shared pointer to the service resource, or nullptr if not found.

**Parameters**

The service id (name) used during service registration.

### get\_services\_by\_id \[#getservicesbyid]

```cpp showLineNumbers={false}
std::vector<std::shared_ptr<FragmentService>> holoscan::Application::get_services_by_id(
    std::string_view id
) const override
```

Retrieve all fragment services with a matching id, regardless of registered type.

This method is used as a fallback when exact type lookup fails, enabling retrieval of services registered with a derived type when looking up by a base type.

**Returns:** A vector of shared\_ptrs to matching FragmentServices. Empty if none found.

**Parameters**

The service id (name) used during service registration.

### register\_service \[#registerservice]

```cpp showLineNumbers={false}
template <typename ServiceT>
bool holoscan::Application::register_service(
    const std::shared_ptr<ServiceT> &svc,
    std::string_view id = ""
)
```

Register an existing fragment service instance.

Registers an already created fragment service instance with the specified identifier. This allows the fragment service to be retrieved later using the service() method.

**Returns:** true if the service was successfully registered, false otherwise.

**Template parameters**

The type of the fragment service.

**Parameters**

The shared pointer to the fragment service instance to register.

The identifier for the fragment service registration. If empty, uses the fragment service type as identifier.

### register\_service\_from \[#registerservicefrom]

```cpp showLineNumbers={false}
virtual bool holoscan::Application::register_service_from(
    Fragment *fragment,
    std::string_view id
)
```

### service \[#service]

```cpp showLineNumbers={false}
template <typename ServiceT = DefaultFragmentService>
std::shared_ptr<ServiceT> holoscan::Application::service(
    std::string_view id = ""
) const
```

Retrieve a registered fragment service or resource.

Retrieves a previously registered fragment service or resource by its type and optional identifier. Returns nullptr if no service/resource is found with the specified type and identifier.

Note that any changes to the service retrieval logic in this method should be synchronized with the implementation in `ComponentBase::service()` method to maintain consistency.

**Returns:** The shared pointer to the service/resource, or nullptr if not found or if type casting fails.

**Template parameters**

The type of the service/resource to retrieve. Must inherit from either [Resource](resource) or [FragmentService](fragmentservice). Defaults to [DefaultFragmentService](defaultfragmentservice) if not specified.

**Parameters**

The identifier of the service/resource. If empty, retrieves by type only.

### get\_service\_by\_type\_info \[#getservicebytypeinfo]

```cpp showLineNumbers={false}
std::shared_ptr<FragmentService> holoscan::Application::get_service_by_type_info(
    const std::type_info &service_type,
    std::string_view id = ""
) const
```

Retrieve a registered fragment service or resource for Python bindings.

This is a helper method for Python bindings to retrieve a service by its C++ type info.

**Returns:** The shared pointer to the base service, or nullptr if not found.

**Parameters**

The type info of the service/resource to retrieve.

The identifier of the service/resource. If empty, retrieves by type only.

### fragment\_services\_by\_key \[#fragmentservicesbykey]

```cpp showLineNumbers={false}
const std::unordered_map<ServiceKey, std::shared_ptr<FragmentService>, ServiceKeyHash> & holoscan::Application::fragment_services_by_key() const
```

Get the fragment services by key.

**Returns:** The fragment services by key.

### start\_op \[#startop]

```cpp showLineNumbers={false}
virtual const std::shared_ptr<Operator> & holoscan::Application::start_op()
```

Get or create the start operator for this fragment.

This operator is nothing but the first operator that was added to the fragment. It has the name of `<|start|>` and has a condition of `CountCondition(1)`. This [Operator](operator) is used to start the execution of the fragment. Entry operators who want to start the execution of the fragment should connect to this operator.

If this method is not called, no start operator is created. Otherwise, the start operator is created if it does not exist, and the shared pointer to the start operator is returned.

**Returns:** The shared pointer to the start operator.

### add\_operator \[#addoperator]

```cpp showLineNumbers={false}
virtual void holoscan::Application::add_operator(
    const std::shared_ptr<Operator> &op
)
```

Add an operator to the graph.

The information of the operator is stored in the [`OperatorFlowGraph`](../typedefs/operatorflowgraph) object. If the operator is already added, this method does nothing.

**Parameters**

The operator to be added.

### add\_subgraph \[#addsubgraph]

```cpp showLineNumbers={false}
virtual void holoscan::Application::add_subgraph(
    const std::shared_ptr<Subgraph> &subgraph
)
```

Add a subgraph to the fragment, taking ownership.

This method takes ownership of the subgraph by storing the shared pointer, registers the subgraph name for duplicate detection, and ensures the subgraph is composed.

This is the recommended way to add a pre-constructed subgraph (e.g. from a factory method) to a [Fragment](fragment). The [Fragment](fragment) will keep the subgraph alive for the duration of its lifetime.

This method is also called automatically by add\_flow() overloads that take [Subgraph](subgraph) arguments, so explicit calls are only needed when a subgraph has no flows (self-contained).

Calling this on a subgraph that is already owned (e.g. after make\_subgraph) is a safe no-op.

**Throws:** `std::runtime_error` if a subgraph with the same name has already been added.

**Parameters**

The subgraph to be added.

### set\_dynamic\_flows \[#setdynamicflows]

```cpp showLineNumbers={false}
virtual void holoscan::Application::set_dynamic_flows(
    const std::shared_ptr<Operator> &op,
    const std::function<void(const std::shared_ptr<Operator> &)> &dynamic_flow_func
)
```

Set a callback function to define dynamic flows for an operator at runtime.

This method allows operators to modify their connections with other operators during execution. The callback function is called after the operator executes and can add dynamic flows using the operator's `add_dynamic_flow()` methods.

**Parameters**

The operator to set dynamic flows for

The callback function that defines the dynamic flows. Takes a shared pointer to the operator as input and returns void.

### make\_subgraph \[#makesubgraph]

```cpp showLineNumbers={false}
template <typename SubgraphT, typename... ArgsT>
std::shared_ptr<SubgraphT> holoscan::Application::make_subgraph(
    const std::string &name,
    ArgsT &&... args
)
```

Create and compose a [Subgraph](subgraph).

Creates a [Subgraph](subgraph) that directly populates this [Fragment](fragment)'s operator graph. The [Subgraph](subgraph) is composed immediately and its operators are added with qualified names to the [Fragment](fragment)'s main graph.

**Returns:** Shared pointer to the composed [Subgraph](subgraph)

**Template parameters**

The subgraph class type (must inherit from [Subgraph](subgraph))

**Parameters**

Unique name for this instance (used for operator qualification)

Additional arguments to pass to the subgraph constructor

### compose \[#compose]

```cpp showLineNumbers={false}
virtual void holoscan::Application::compose()
```

Compose a graph.

The graph is composed by adding operators and flows in this method.

### track \[#track]

```cpp showLineNumbers={false}
DataFlowTracker & holoscan::Application::track(
    uint64_t num_start_messages_to_skip = kDefaultNumStartMessagesToSkip,
    uint64_t num_last_messages_to_discard = kDefaultNumLastMessagesToDiscard,
    int latency_threshold = kDefaultLatencyThreshold,
    bool is_limited_tracking = false
)
```

Turn on data frame flow tracking.

A reference to a [DataFlowTracker](dataflowtracker) object is returned rather than a pointer so that the developers can use it as an object without unnecessary pointer dereferencing.

**Returns:** A reference to the [DataFlowTracker](dataflowtracker) object in which results will be stored.

**Parameters**

The number of messages to skip at the beginning.

The number of messages to discard at the end.

The minimum end-to-end latency in milliseconds to account for in the end-to-end latency metric calculations.

If true, the tracking is limited to root and leaf nodes, minimizing the timestamps by avoiding intermediate operators.

### data\_flow\_tracker \[#dataflowtracker]

```cpp showLineNumbers={false}
DataFlowTracker * holoscan::Application::data_flow_tracker()
```

Get the [DataFlowTracker](dataflowtracker) object for this fragment.

**Returns:** The pointer to the [DataFlowTracker](dataflowtracker) object.

### port\_info \[#portinfo]

```cpp showLineNumbers={false}
FragmentPortMap holoscan::Application::port_info() const
```

Get an easily serializable summary of port information.

The [FragmentPortMap](../typedefs/fragmentportmap) class is used by distributed applications to send port information between application workers and the driver.

**Returns:** An unordered\_map of the fragment's port information where the keys are operator names and the values are a 3-tuple. The first two elements of the tuple are the set of input and output port names, respectively. The third element of the tuple is the set of "receiver" parameters (those with type std::vector\<IOSpec\*>).

### stop\_execution \[#stopexecution]

```cpp showLineNumbers={false}
virtual void holoscan::Application::stop_execution(
    const std::string &op_name = ""
)
```

Stop the execution of all operators in the fragment.

This method is used to stop the execution of all operators in the fragment by setting the internal async condition of each operator to EVENT\_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operators will not be scheduled for execution (the `compute()` method will not be called), which may lead to application termination depending on the application's design.

Note that executing this method does not trigger the operators' `stop()` method. The `stop()` method is called only when the scheduler deactivates all operators together.

**Parameters**

The name of the operator to stop. If empty, all operators will be stopped.

### data\_loggers \[#dataloggers]

```cpp showLineNumbers={false}
const std::vector<std::shared_ptr<DataLogger>> & holoscan::Application::data_loggers() const
```

Get the data loggers associated with this fragment.

**Returns:** A const reference to the vector of data loggers.

### subgraphs \[#subgraphs]

```cpp showLineNumbers={false}
const std::vector<std::shared_ptr<Subgraph>> & holoscan::Application::subgraphs() const
```

Get the top-level subgraphs owned by this fragment.

Returns subgraphs added via make\_subgraph() or add\_subgraph(). Nested subgraphs within these are accessible via Subgraph::nested\_subgraphs().

**Returns:** A const reference to the vector of owned subgraphs.

### is\_gpu\_resident \[#isgpuresident]

```cpp showLineNumbers={false}
bool holoscan::Application::is_gpu_resident() const
```

Check if the fragment has GPU-resident operators.

**Returns:** True if the fragment has GPU-resident operators, false otherwise.

### gpu\_resident \[#gpuresident]

```cpp showLineNumbers={false}
GPUResidentAccessor holoscan::Application::gpu_resident()
```

Get an accessor for GPU-resident specific functions.

This method returns a [GPUResidentAccessor](fragment#gpuresidentaccessor) object that provides convenient access to GPU-resident specific functionality. For example:

**Returns:** A [GPUResidentAccessor](fragment#gpuresidentaccessor) object for accessing GPU-resident functions.

**Throws:** `RuntimeError` if the fragment does not have GPU-resident operators.

**Example**

```cpp showLineNumbers={false}
fragment->gpu_resident().timeout_ms(1000);
fragment->gpu_resident().sync_with_host();
fragment->gpu_resident().data_ready();
fragment->gpu_resident().result_ready();
fragment->gpu_resident().is_launched();
fragment->gpu_resident().tear_down();
```

### setup\_component\_internals \[#setupcomponentinternals]

```cpp showLineNumbers={false}
void holoscan::Application::setup_component_internals(
    ComponentBase *component
)
```

Set up internal state for a component.

Configures the component's internal references to this fragment and its service provider. This method is called internally when creating operators, resources, conditions, and other components to ensure they have proper access to fragment services.

**Parameters**

Pointer to the [ComponentBase](componentbase) instance to configure. Must not be nullptr.

### driver \[#driver]

```cpp showLineNumbers={false}
AppDriver & holoscan::Application::driver()
```

Get the application driver.

**Returns:** The reference to the application driver.

### worker \[#worker]

```cpp showLineNumbers={false}
AppWorker & holoscan::Application::worker()
```

Get the application worker.

**Returns:** The reference to the application worker.

### process\_arguments \[#processarguments]

```cpp showLineNumbers={false}
void holoscan::Application::process_arguments()
```

### reset\_state \[#resetstate]

```cpp showLineNumbers={false}
void holoscan::Application::reset_state() override
```

Reset internal application state to allow for multiple run calls.

This method resets the necessary internal state to allow multiple consecutive calls to run() or run\_async() without requiring manual cleanup.

### attach\_services\_to\_fragment \[#attachservicestofragment]

```cpp showLineNumbers={false}
virtual void holoscan::Application::attach_services_to_fragment(
    const std::shared_ptr<Fragment> &fragment
)
```

Attach application services to a specified fragment.

**Parameters**

The fragment to which services will be attached.

### make\_config \[#makeconfig]

```cpp showLineNumbers={false}
template <typename ConfigT, typename... ArgsT>
std::shared_ptr<Config> holoscan::Application::make_config(
    ArgsT &&... args
)
```

### make\_graph \[#makegraph]

```cpp showLineNumbers={false}
template <typename GraphT>
std::shared_ptr<GraphT> holoscan::Application::make_graph()
```

### make\_executor \[#makeexecutor]

```cpp showLineNumbers={false}
template <typename ExecutorT, typename... ArgsT>
std::shared_ptr<Executor> holoscan::Application::make_executor(
    ArgsT &&... args
)
```

Create and assign an [Executor](executor) to the fragment.

### reset\_backend\_objects \[#resetbackendobjects]

```cpp showLineNumbers={false}
void holoscan::Application::reset_backend_objects()
```

Cleanup helper that will be called by the executor prior to destroying any backend context.

### shutdown\_data\_loggers \[#shutdowndataloggers]

```cpp showLineNumbers={false}
void holoscan::Application::shutdown_data_loggers()
```

Shutdown data loggers to ensure async loggers complete before GXF context destruction.

This method is thread-safe and idempotent - multiple calls will block until the first completes, then return immediately. This ensures proper synchronization between signal handlers and normal shutdown paths.

### load\_extensions\_from\_config \[#loadextensionsfromconfig]

```cpp showLineNumbers={false}
void holoscan::Application::load_extensions_from_config()
```

Load the GXF extensions specified in the configuration.

### thread\_pools \[#threadpools]

```cpp showLineNumbers={false}
std::vector<std::shared_ptr<ThreadPool>> & holoscan::Application::thread_pools()
```

### resolve\_subgraph\_port \[#resolvesubgraphport]

```cpp showLineNumbers={false}
std::pair<std::shared_ptr<Operator>, std::string> holoscan::Application::resolve_subgraph_port(
    const std::shared_ptr<Subgraph> &subgraph,
    const std::string &interface_port
)
```

Resolve [Subgraph](subgraph) interface port to actual operator and port.

**Returns:** Pair of (operator, actual\_port\_name) or (nullptr, "") if not found

**Parameters**

The [Subgraph](subgraph) to resolve the port in

The interface port name

### get\_operator\_output\_ports \[#getoperatoroutputports]

```cpp showLineNumbers={false}
std::vector<std::string> holoscan::Application::get_operator_output_ports(
    const std::shared_ptr<Operator> &op
)
```

Get output port names from an operator.

### get\_operator\_input\_ports \[#getoperatorinputports]

```cpp showLineNumbers={false}
std::vector<std::string> holoscan::Application::get_operator_input_ports(
    const std::shared_ptr<Operator> &op
)
```

Get input port names from an operator.

### get\_subgraph\_output\_ports \[#getsubgraphoutputports]

```cpp showLineNumbers={false}
std::vector<std::string> holoscan::Application::get_subgraph_output_ports(
    const std::shared_ptr<Subgraph> &subgraph
)
```

Get output interface port names from a subgraph.

### get\_subgraph\_input\_ports \[#getsubgraphinputports]

```cpp showLineNumbers={false}
std::vector<std::string> holoscan::Application::get_subgraph_input_ports(
    const std::shared_ptr<Subgraph> &subgraph
)
```

Get input interface port names from a subgraph.

### try\_auto\_resolve\_ports \[#tryautoresolveports]

```cpp showLineNumbers={false}
void holoscan::Application::try_auto_resolve_ports(
    const std::vector<std::string> &upstream_ports,
    const std::vector<std::string> &downstream_ports,
    const std::string &upstream_name,
    const std::string &downstream_name,
    std::set<std::pair<std::string, std::string>> &port_pairs
)
```

Attempt auto-resolution of port pairs between two entities.

**Throws:** `std::runtime_error` if auto-resolution fails

**Parameters**

Output ports from upstream entity

Input ports from downstream entity

Name of upstream entity (for error messages)

Name of downstream entity (for error messages)

Output parameter: will contain the resolved port pair if successful

### resolve\_and\_create\_op\_to\_subgraph\_flows \[#resolveandcreateoptosubgraphflows]

```cpp showLineNumbers={false}
void holoscan::Application::resolve_and_create_op_to_subgraph_flows(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    const std::set<std::pair<std::string, std::string>> &port_pairs,
    const IOSpec::ConnectorType connector_type
)
```

Resolve and create flows for operator-to-subgraph connections.

### resolve\_and\_create\_subgraph\_to\_op\_flows \[#resolveandcreatesubgraphtoopflows]

```cpp showLineNumbers={false}
void holoscan::Application::resolve_and_create_subgraph_to_op_flows(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Operator> &downstream_op,
    const std::set<std::pair<std::string, std::string>> &port_pairs,
    const IOSpec::ConnectorType connector_type
)
```

Resolve and create flows for subgraph-to-operator connections.

### resolve\_and\_create\_subgraph\_to\_subgraph\_flows \[#resolveandcreatesubgraphtosubgraphflows]

```cpp showLineNumbers={false}
void holoscan::Application::resolve_and_create_subgraph_to_subgraph_flows(
    const std::shared_ptr<Subgraph> &upstream_subgraph,
    const std::shared_ptr<Subgraph> &downstream_subgraph,
    const std::set<std::pair<std::string, std::string>> &port_pairs,
    const IOSpec::ConnectorType connector_type
)
```

Resolve and create flows for subgraph-to-subgraph connections.

### validate\_control\_flow\_prerequisites \[#validatecontrolflowprerequisites]

```cpp showLineNumbers={false}
bool holoscan::Application::validate_control_flow_prerequisites(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Operator> &downstream_op,
    const IOSpec::ConnectorType connector_type
)
```

Validate prerequisites for establishing a control flow connection.

**Returns:** true if validation passes, false otherwise (error message will be logged)

**Parameters**

The upstream operator

The downstream operator

The connector type (cannot be kAsyncBuffer for control flow)

### create\_control\_flow\_connection \[#createcontrolflowconnection]

```cpp showLineNumbers={false}
void holoscan::Application::create_control_flow_connection(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Operator> &downstream_op
)
```

Create and register a control flow connection between two operators.

This helper creates the port map, sets self\_shared on both operators, adds the flow to the graph, and registers it with the executor.

**Parameters**

The upstream operator

The downstream operator

### initiate\_local\_app\_shutdown \[#initiatelocalappshutdown]

```cpp showLineNumbers={false}
void holoscan::Application::initiate_local_app_shutdown(
    const std::string &fragment_name
)
```

Initiate shutdown of a local multi-fragment application.

This method initiates an orderly shutdown of fragments running in local mode (multiple fragments in one process). Fragments are terminated in topological order (root/upstream fragments first) to avoid connection errors.

**Parameters**

The name of the fragment initiating the shutdown (currently unused but kept for API consistency).

### is\_any\_fragment\_gpu\_resident \[#isanyfragmentgpuresident]

```cpp showLineNumbers={false}
bool holoscan::Application::is_any_fragment_gpu_resident()
```

Check if any fragment in the application's fragment graph is GPU-resident.

**Returns:** true if any fragment in the application's fragment graph is GPU-resident, false otherwise.

### set\_ucx\_env \[#setucxenv]

```cpp showLineNumbers={false}
void holoscan::Application::set_ucx_env()
```

Configure UCX environment variables.

### set\_v4l2\_env \[#setv4l2env]

```cpp showLineNumbers={false}
void holoscan::Application::set_v4l2_env()
```

### check\_stack\_size \[#checkstacksize]

```cpp showLineNumbers={false}
void holoscan::Application::check_stack_size()
```

Check stack size and warn if below recommended minimum.

***

## Static methods

### get\_distributed\_app\_scheduler\_env \[#getdistributedappschedulerenv]

```cpp showLineNumbers={false}
static expected<SchedulerType, ErrorCode> holoscan::Application::get_distributed_app_scheduler_env()
```

### get\_stop\_on\_deadlock\_env \[#getstopondeadlockenv]

```cpp showLineNumbers={false}
static expected<bool, ErrorCode> holoscan::Application::get_stop_on_deadlock_env()
```

### get\_stop\_on\_deadlock\_timeout\_env \[#getstopondeadlocktimeoutenv]

```cpp showLineNumbers={false}
static expected<int64_t, ErrorCode> holoscan::Application::get_stop_on_deadlock_timeout_env()
```

### get\_ucx\_network\_connection\_timeout\_env \[#getucxnetworkconnectiontimeoutenv]

```cpp showLineNumbers={false}
static expected<int64_t, ErrorCode> holoscan::Application::get_ucx_network_connection_timeout_env()
```

### get\_max\_duration\_ms\_env \[#getmaxdurationmsenv]

```cpp showLineNumbers={false}
static expected<int64_t, ErrorCode> holoscan::Application::get_max_duration_ms_env()
```

### get\_check\_recession\_period\_ms\_env \[#getcheckrecessionperiodmsenv]

```cpp showLineNumbers={false}
static expected<double, ErrorCode> holoscan::Application::get_check_recession_period_ms_env()
```

### set\_scheduler\_for\_fragments \[#setschedulerforfragments]

```cpp showLineNumbers={false}
static void holoscan::Application::set_scheduler_for_fragments(
    std::vector<FragmentNodeType> &target_fragments,
    const std::shared_ptr<Scheduler> &app_scheduler = nullptr
)
```

Set the scheduler for fragments object.

Set scheduler for each fragment to use multi-thread scheduler by default because UcxTransmitter/UcxReceiver doesn't work with [GreedyScheduler](greedyscheduler) with the following graph.

* [Fragment](fragment) (fragment1)
  Operator (op1)
  Output port: out

Operator (op2)
Output port: out

* [Operator](operator) (op1)
  Output port: out
  * Output port: out
* [Operator](operator) (op2)
  Output port: out
  * Output port: out
* [Fragment](fragment) (fragment2)
  Operator (op3)
  Input ports
  in1
  in2
  * [Operator](operator) (op3)
    Input ports
    in1
    in2
    * Input ports
      in1
      in2
      * in1
      * in2

With the following graph connections, due to how UcxTransmitter/UcxReceiver works, UCX connections between op1 and op3 and between op2 and op3 are not established (resulting in a deadlock).

* op1.out -> op3.in1
* op2.out -> op3.in2

**Parameters**

The fragments to set the scheduler.

Optional scheduler set on the `Application`. If provided and a fragment doesn't have its own scheduler set, this scheduler will be used for that fragment.

***

## Member variables

| Name                                    | Type                                                                                   | Description                                              |
| --------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| `app_description_`                      | `std::string`                                                                          | The description of the application.                      |
| `app_version_`                          | `std::string`                                                                          | The version of the application.                          |
| `cli_parser_`                           | `CLIParser`                                                                            | The command line parser.                                 |
| `argv_`                                 | `std::vector< std::string >`                                                           | The command line arguments after processing flags.       |
| `fragment_graph_`                       | `std::shared_ptr< FragmentFlowGraph >`                                                 | The fragment connection graph.                           |
| `app_driver_`                           | `std::shared_ptr< AppDriver >`                                                         | The application driver.                                  |
| `app_worker_`                           | `std::shared_ptr< AppWorker >`                                                         | The application worker.                                  |
| `is_fragment_graph_composed_`           | `bool`                                                                                 |                                                          |
| `name_`                                 | `std::string`                                                                          | The name of the fragment.                                |
| `app_`                                  | `Application *`                                                                        | The application that this fragment belongs to.           |
| `config_`                               | `std::shared_ptr< Config >`                                                            | The configuration of the fragment.                       |
| `executor_`                             | `std::shared_ptr< Executor >`                                                          | The executor for the fragment.                           |
| `graph_`                                | `std::shared_ptr< OperatorFlowGraph >`                                                 | The graph of the fragment.                               |
| `scheduler_`                            | `std::shared_ptr< Scheduler >`                                                         | Lazily initialized scheduler (mutable for const access). |
| `network_context_`                      | `std::shared_ptr< NetworkContext >`                                                    | The network\_context used by the executor.               |
| `data_flow_tracker_`                    | `std::shared_ptr< DataFlowTracker >`                                                   | The [DataFlowTracker](dataflowtracker) for the fragment. |
| `thread_pools_`                         | `std::vector< std::shared_ptr< ThreadPool > >`                                         | Any thread pools used by the fragment.                   |
| `is_composed_`                          | `bool`                                                                                 | Whether the graph is composed or not.                    |
| `is_run_called_`                        | `bool`                                                                                 | Whether run() or run\_async() has been called.           |
| `start_op_`                             | `std::shared_ptr< Operator >`                                                          | The start operator of the fragment (optional).           |
| `data_loggers_`                         | `std::vector< std::shared_ptr< DataLogger > >`                                         | Data loggers (optional).                                 |
| `data_loggers_shutdown_mutex_`          | `std::mutex`                                                                           | Mutex to serialize shutdown\_data\_loggers() calls.      |
| `data_loggers_shutdown_complete_`       | `bool`                                                                                 | Flag to track if shutdown has completed.                 |
| `fragment_service_registry_mutex_`      | `std::shared_mutex`                                                                    | Mutex for thread-safe service registry access.           |
| `fragment_services_by_key_`             | `std::unordered_map< ServiceKey, std::shared_ptr< FragmentService >, ServiceKeyHash >` | service registry map                                     |
| `fragment_resource_services_by_name_`   | `std::unordered_map< std::string, std::shared_ptr< Resource > >`                       | service resource registry map                            |
| `fragment_resource_to_service_key_map_` | `std::unordered_map< std::shared_ptr< Resource >, ServiceKey >`                        | service resource registry map                            |
| `green_context_pools_`                  | `std::vector< std::shared_ptr< CudaGreenContextPool > >`                               |                                                          |
| `subgraph_names_`                       | `std::unordered_set< std::string >`                                                    |                                                          |
| `subgraphs_`                            | `std::vector< std::shared_ptr< Subgraph > >`                                           |                                                          |
| `metadata_policy_`                      | `MetadataPolicy`                                                                       |                                                          |
| `is_metadata_enabled_`                  | `bool`                                                                                 |                                                          |