> 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::ops::VirtualTransmitterOp

> Virtual Transmitter operator.

Virtual [Transmitter](../../../classes/transmitter) operator.

This operator represents a transmitter that is connected to a receiver in another fragment. Although this operator has an input port, the input port (and its name) of this operator represents the output port (and its name) of an operator that is connected to this operator in the same fragment.

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

**Inherits from:** `holoscan::ops::VirtualOperator` (public)

***

## Constructors

### VirtualTransmitterOp \[#virtualtransmitterop]

```cpp showLineNumbers={false}
template <typename StringT,
          typename ArgListT,
          typename = std::enable_if_t<std::is_constructible_v<std::string, StringT> &&                                        std::is_same_v<ArgList, std::decay_t<ArgListT>>>>
holoscan::ops::VirtualTransmitterOp::VirtualTransmitterOp(
    StringT &&output_port_name,
    IOSpec::ConnectorType connector_type,
    ArgListT &&arg_list
)
```

***

## Methods

### setup \[#setup]

```cpp showLineNumbers={false}
void holoscan::ops::VirtualTransmitterOp::setup(
    OperatorSpec &spec
) override
```

Define the operator specification.

**Parameters**

The reference to the operator specification.

### initialize \[#initialize]

```cpp showLineNumbers={false}
void holoscan::ops::VirtualTransmitterOp::initialize() override
```

Initialize the Virtual operator.

This function does not call the Operator::initialize() method that is called when the fragment is initialized by Executor::initialize\_fragment().

Instead, it just sets the operator type to `holoscan::Operator::OperatorType::kVirtual`.

### port\_name \[#portname]

```cpp showLineNumbers={false}
void holoscan::ops::VirtualTransmitterOp::port_name(
    const std::string &port_name
)
```

Set the name of the port of the operator connected to this operator in the same fragment.

**Parameters**

The name of the port of the operator connected to this operator in the same fragment.

const

```cpp showLineNumbers={false}
const std::string & holoscan::ops::VirtualTransmitterOp::port_name() const
```

Get the name of the port of the operator connected to this operator in the same fragment.

**Returns:** The name of the port of the operator connected to this operator in the same fragment.

### connector\_type \[#connectortype]

```cpp showLineNumbers={false}
IOSpec::ConnectorType holoscan::ops::VirtualTransmitterOp::connector_type() const
```

Get the connector type of this operator.

**Returns:** The connector type of this operator.

### arg\_list \[#arglist]

```cpp showLineNumbers={false}
const ArgList & holoscan::ops::VirtualTransmitterOp::arg_list() const
```

Get the argument list of this operator.

**Returns:** The argument list of this operator.

### input\_spec \[#inputspec]

```cpp showLineNumbers={false}
IOSpec * holoscan::ops::VirtualTransmitterOp::input_spec()
```

Get the input specification for this operator.

**Returns:** The pointer to the input specification for this operator.

### output\_spec \[#outputspec]

```cpp showLineNumbers={false}
IOSpec * holoscan::ops::VirtualTransmitterOp::output_spec()
```

Get the output specification for this operator.

**Returns:** The pointer to the output specification for this operator.

### io\_type \[#iotype]

```cpp showLineNumbers={false}
IOSpec::IOType holoscan::ops::VirtualTransmitterOp::io_type() const
```

Get the IO type of this operator.

**Returns:** The IO type of this operator.

### operator\_type \[#operatortype]

```cpp showLineNumbers={false}
OperatorType holoscan::Operator::operator_type() const
```

Get the operator type.

**Returns:** The operator type.

### id \[#id]

```cpp showLineNumbers={false}
Operator & holoscan::Operator::id(
    int64_t id
)
```

Set the [Operator](../../../classes/operator) ID.

**Returns:** The reference to this operator.

**Parameters**

The ID of the operator.

const

```cpp showLineNumbers={false}
int64_t holoscan::ComponentBase::id() const
```

Get the identifier of the component.

By default, the identifier is set to -1. It is set to a valid value when the component is initialized.

With the default executor (GXFExecutor), the identifier is set to the GXF component ID.

**Returns:** The identifier of the component.

### name \[#name]

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

Set the name of the operator.

**Returns:** The reference to this operator.

**Parameters**

The name of the operator.

const

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

Get the name of the component.

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

### fragment \[#fragment]

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

Set the fragment of the operator.

**Returns:** The reference to this operator.

**Parameters**

The pointer to the fragment of the operator.

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

Get a pointer to [Fragment](../../../classes/fragment) object.

**Returns:** The Pointer to [Fragment](../../../classes/fragment) object.

const

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

Get a const pointer to [Fragment](../../../classes/fragment) object.

**Returns:** The const pointer to [Fragment](../../../classes/fragment) object.

### spec \[#spec]

```cpp showLineNumbers={false}
Operator & holoscan::Operator::spec(
    const std::shared_ptr<OperatorSpec> &spec
)
```

Set the operator spec.

**Returns:** The reference to this operator.

**Parameters**

The operator spec.

```cpp showLineNumbers={false}
OperatorSpec * holoscan::Operator::spec()
```

Get the operator spec.

**Returns:** The operator spec.

### spec\_shared \[#specshared]

```cpp showLineNumbers={false}
std::shared_ptr<OperatorSpec> holoscan::Operator::spec_shared()
```

Get the shared pointer to the operator spec.

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

### condition \[#condition]

```cpp showLineNumbers={false}
template <typename ConditionT>
std::shared_ptr<ConditionT> holoscan::Operator::condition(
    const std::string &name
)
```

Get a shared pointer to the [Condition](../../../classes/condition) object.

**Returns:** The reference to the [Condition](../../../classes/condition) object. If the condition does not exist, return the nullptr.

**Parameters**

The name of the condition.

### conditions \[#conditions]

```cpp showLineNumbers={false}
std::unordered_map<std::string, std::shared_ptr<Condition>> & holoscan::Operator::conditions()
```

Get the conditions of the operator.

**Returns:** The conditions of the operator.

### resource \[#resource]

```cpp showLineNumbers={false}
template <typename ResourceT>
std::shared_ptr<ResourceT> holoscan::Operator::resource(
    const std::string &name
)
```

Get a shared pointer to the [Resource](../../../classes/resource) object.

**Returns:** The reference to the [Resource](../../../classes/resource) object. If the resource does not exist, returns the nullptr.

**Parameters**

The name of the resource.

### resources \[#resources]

```cpp showLineNumbers={false}
std::unordered_map<std::string, std::shared_ptr<Resource>> & holoscan::Operator::resources()
```

Get the resources of the operator.

**Returns:** The resources of the operator.

### add\_arg \[#addarg]

```cpp showLineNumbers={false}
void holoscan::Operator::add_arg(
    const std::shared_ptr<Condition> &arg
)
```

Add a condition to the operator.

**Parameters**

The condition to add.

```cpp showLineNumbers={false}
void holoscan::Operator::add_arg(
    std::shared_ptr<Condition> &&arg
)
```

Add a condition to the operator.

**Parameters**

The condition to add.

```cpp showLineNumbers={false}
void holoscan::Operator::add_arg(
    const std::shared_ptr<Resource> &arg
)
```

Add a resource to the operator.

**Parameters**

The resource to add.

```cpp showLineNumbers={false}
void holoscan::Operator::add_arg(
    std::shared_ptr<Resource> &&arg
)
```

Add a resource to the operator.

**Parameters**

The resource to add.

```cpp showLineNumbers={false}
void holoscan::ComponentBase::add_arg(
    const Arg &arg
)
```

Add an argument to the component.

**Parameters**

The argument to add.

```cpp showLineNumbers={false}
void holoscan::ComponentBase::add_arg(
    Arg &&arg
)
```

Add an argument to the component.

**Parameters**

The argument to add.

```cpp showLineNumbers={false}
void holoscan::ComponentBase::add_arg(
    const ArgList &arg
)
```

Add a list of arguments to the component.

**Parameters**

The list of arguments to add.

```cpp showLineNumbers={false}
void holoscan::ComponentBase::add_arg(
    ArgList &&arg
)
```

Add a list of arguments to the component.

**Parameters**

The list of arguments to add.

### is\_root \[#isroot]

```cpp showLineNumbers={false}
bool holoscan::Operator::is_root()
```

Returns whether the operator is a root operator based on its fragment's graph.

**Returns:** True, if the operator is a root operator; false, otherwise

### is\_user\_defined\_root \[#isuserdefinedroot]

```cpp showLineNumbers={false}
bool holoscan::Operator::is_user_defined_root()
```

Returns whether the operator is a user-defined root operator i.e., the first operator added to the graph.

**Returns:** True, if the operator is a user-defined root operator; false, otherwise

### is\_leaf \[#isleaf]

```cpp showLineNumbers={false}
bool holoscan::Operator::is_leaf()
```

Returns whether the operator is a leaf operator based on its fragment's graph.

**Returns:** True, if the operator is a leaf operator; false, otherwise

### qualified\_name \[#qualifiedname]

```cpp showLineNumbers={false}
std::string holoscan::Operator::qualified_name() const
```

Returns the fully qualified name of the operator including the name of the fragment.

**Returns:** std::string fully qualified name of the operator in the format: "\<fragment\_name>.\<operator\_name>"

### start \[#start]

```cpp showLineNumbers={false}
virtual void holoscan::Operator::start()
```

Implement the startup logic of the operator.

This method is called multiple times over the lifecycle of the operator according to the order defined in the lifecycle, and used for heavy initialization tasks such as allocating memory resources.

### stop \[#stop]

```cpp showLineNumbers={false}
virtual void holoscan::Operator::stop()
```

Implement the shutdown logic of the operator.

This method is called multiple times over the lifecycle of the operator according to the order defined in the lifecycle, and used for heavy deinitialization tasks such as deallocation of all resources previously assigned in start.

### compute \[#compute]

```cpp showLineNumbers={false}
virtual void holoscan::Operator::compute(
    InputContext &op_input,
    OutputContext &op_output,
    ExecutionContext &context
)
```

Implement the compute method.

This method is called by the runtime multiple times. The runtime calls this method until the operator is stopped.

**Parameters**

The input context of the operator.

The output context of the operator.

The execution context of the operator.

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

```cpp showLineNumbers={false}
YAML::Node holoscan::Operator::to_yaml_node() const override
```

Get a `YAML` representation of the operator.

**Returns:** `YAML` node including type, specs, conditions and resources of the operator in addition to the base component properties.

### graph\_entity \[#graphentity]

```cpp showLineNumbers={false}
std::shared_ptr<nvidia::gxf::GraphEntity> holoscan::Operator::graph_entity()
```

Get the GXF GraphEntity object corresponding to this operator.

**Returns:** graph entity corresponding to the operator

### get\_data\_flow\_tracking\_label \[#getdataflowtrackinglabel]

```cpp showLineNumbers={false}
MessageLabel holoscan::Operator::get_data_flow_tracking_label(
    const std::string &input_port_name
)
```

Get the current message label for a given input port.

This method retrieves the [MessageLabel](../../../classes/messagelabel) associated with data received on the specified input port. The [MessageLabel](../../../classes/messagelabel) contains timing and path information for data flow tracking.

This method should ideally be called after receiving data on the input port.

If the input\_port\_name is invalid (not found in the operator's input ports), an error is logged and an empty [MessageLabel](../../../classes/messagelabel) is returned.

**Returns:** [MessageLabel](../../../classes/messagelabel) The current message label for the input port. Returns an empty [MessageLabel](../../../classes/messagelabel) if the port does not have a message label or if the port does not exist (logs an error in the latter case as well).

**Throws:** `std::runtime_error` If the operator backend is not GXF-compatible.

**Throws:** `std::runtime_error` If fragment is not set.

**Throws:** `std::runtime_error` If operator spec is not set.

**Throws:** `std::runtime_error` If fragment flow tracking is not enabled.

**Parameters**

The name of the input port.

### metadata \[#metadata]

```cpp showLineNumbers={false}
std::shared_ptr<MetadataDictionary> holoscan::Operator::metadata()
```

Get a shared pointer to the dynamic metadata of this operator.

Note: currently this metadata dictionary is only active if explicitly enabled for the application by setting `Fragment::is_metadata_enabled(true)`. When metadata is disabled the dictionary will not be populated by receive calls and will not be emitted on emit calls.

This metadata dictionary is always empty at the start of each compute call. It is populated by metadata received on input ports during `InputContext::receive()` calls and can be modified as desired by the operator during the compute call. Any metadata corresponding to this object will be sent on the output ports by any `OutputContext::emit()` calls.

**Returns:** The metadata dictionary for this operator.

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

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

Determine if metadata is enabled for this operator.

**Returns:** Boolean indicating if metadata is enabled (returns `fragment()``->``is_metadata_enabled()` if [`enable_metadata`](../../../classes/gpuresidentoperator#enablemetadata) was not explicitly called for the operator.

### enable\_metadata \[#enablemetadata]

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

Enable or disable metadata for this operator.

If this method has not been used to explicitly enable or disable metadata, the value for `is_metadata_enabled()` will be determined by `Fragment::is_metadata_enabled()` when the operator is initialized.

**Parameters**

Boolean indicating if metadata should be enabled.

### metadata\_policy \[#metadatapolicy]

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

Set the metadata update policy used by this operator.

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).

**Parameters**

The metadata update policy to be used by this operator.

const

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

Get the metadata update policy used by this operator.

**Returns:** The metadata update policy used by this operator.

### receiver \[#receiver]

```cpp showLineNumbers={false}
std::optional<std::shared_ptr<Receiver>> holoscan::Operator::receiver(
    const std::string &port_name
)
```

If no [`CudaStreamPool`](../../../classes/cudastreampool) parameter or argument already exists, add a default one.

This method is available to be called by derived classes to add a default [CudaStreamPool](../../../classes/cudastreampool) in This method is available to be called by derived classes to add a default [`CudaStreamPool`](../../../classes/cudastreampool) in`the case that the user did not pass one in as an argument to`make\_operator\`.

This function will not add an additional CUDA stream pool if one was already passed in as an argument to `make_operator` (i.e. it is in resources\_) or if a "cuda\_stream\_pool" parameter already exists in the operator spec.

/\*\* Return the [Receiver](../../../classes/receiver) corresponding to a specific input port.

**Returns:** The [Receiver](../../../classes/receiver) corresponding to the input port, if it exists. Otherwise, return nullopt.

**Parameters**

The name of the input port.

### transmitter \[#transmitter]

```cpp showLineNumbers={false}
std::optional<std::shared_ptr<Transmitter>> holoscan::Operator::transmitter(
    const std::string &port_name
)
```

Return the [Transmitter](../../../classes/transmitter) corresponding to a specific output port.

**Returns:** The [Transmitter](../../../classes/transmitter) corresponding to the output port, if it exists. Otherwise, return nullopt.

**Parameters**

The name of the output port.

### bind\_input\_topic \[#bindinputtopic]

```cpp showLineNumbers={false}
void holoscan::Operator::bind_input_topic(
    const std::string &port_name,
    const std::string &topic,
    const std::optional<nvidia::gxf::QoSProfile> &qos = std::nullopt,
    bool replace_connector = false
)
```

Bind an input port to a Pub/Sub topic.

This is the programmatic override path for topic-mapped ports and takes precedence over any lower-priority `IOSpec::topic()` default configured in `setup()`.

**Parameters**

The input port to bind.

The topic name to subscribe to.

Optional QoS profile override. When nullopt, any QoS already configured on the port (e.g. in setup()) is preserved.

If true, replace an explicitly non-PubSub connector on this port with a Pub/Sub connector.

### bind\_output\_topic \[#bindoutputtopic]

```cpp showLineNumbers={false}
void holoscan::Operator::bind_output_topic(
    const std::string &port_name,
    const std::string &topic,
    const std::optional<nvidia::gxf::QoSProfile> &qos = std::nullopt,
    bool replace_connector = false
)
```

Bind an output port to a Pub/Sub topic.

This is the programmatic override path for topic-mapped ports and takes precedence over any lower-priority `IOSpec::topic()` default configured in `setup()`.

**Parameters**

The output port to bind.

The topic name to publish to.

Optional QoS profile override. When nullopt, any QoS already configured on the port (e.g. in setup()) is preserved.

If true, replace an explicitly non-PubSub connector on this port with a Pub/Sub connector.

### input\_topic \[#inputtopic]

```cpp showLineNumbers={false}
std::optional<std::string> holoscan::Operator::input_topic(
    const std::string &port_name
) const
```

Get the configured topic name for an input port, if any.

### output\_topic \[#outputtopic]

```cpp showLineNumbers={false}
std::optional<std::string> holoscan::Operator::output_topic(
    const std::string &port_name
) const
```

Get the configured topic name for an output port, if any.

### input\_qos \[#inputqos]

```cpp showLineNumbers={false}
std::optional<nvidia::gxf::QoSProfile> holoscan::Operator::input_qos(
    const std::string &port_name
) const
```

Get the effective QoS profile for an input port, if it is topic-mapped.

### output\_qos \[#outputqos]

```cpp showLineNumbers={false}
std::optional<nvidia::gxf::QoSProfile> holoscan::Operator::output_qos(
    const std::string &port_name
) const
```

Get the effective QoS profile for an output port, if it is topic-mapped.

### queue\_policy \[#queuepolicy]

```cpp showLineNumbers={false}
void holoscan::Operator::queue_policy(
    const std::string &port_name,
    IOSpec::IOType port_type = IOSpec::IOType::kInput,
    IOSpec::QueuePolicy policy = IOSpec::QueuePolicy::kFault
)
```

Set the queue policy to be used by an input or output port.

The following IOSpec::QueuePolicy values are supported:

* QueuePolicy::kPop - If the queue is full, pop the oldest item, then add the new one.
* QueuePolicy::kReject - If the queue is full, reject (discard) the new item.
* QueuePolicy::kFault - If the queue is full, log a warning and reject the new item.

**Parameters**

The name of the port.

Enum flag indicating whether `port_name` specifies an input or output port.

The queue policy to set for the port.

### input\_exec\_spec \[#inputexecspec]

```cpp showLineNumbers={false}
const std::shared_ptr<IOSpec> & holoscan::Operator::input_exec_spec()
```

### output\_exec\_spec \[#outputexecspec]

```cpp showLineNumbers={false}
const std::shared_ptr<IOSpec> & holoscan::Operator::output_exec_spec()
```

### dynamic\_flow\_func \[#dynamicflowfunc]

```cpp showLineNumbers={false}
const std::function<void(
    const std::shared_ptr<Operator> &
)
```

### self\_shared \[#selfshared]

```cpp showLineNumbers={false}
std::shared_ptr<Operator> holoscan::Operator::self_shared()
```

### next\_flows \[#nextflows]

```cpp showLineNumbers={false}
const std::vector<std::shared_ptr<FlowInfo>> & holoscan::Operator::next_flows()
```

Get the list of next flows connected to this operator.

**Returns:** A vector of [FlowInfo](../../../classes/operator#flowinfo) objects representing the flows to downstream operators.

### add\_dynamic\_flow \[#adddynamicflow]

```cpp showLineNumbers={false}
void holoscan::Operator::add_dynamic_flow(
    const std::shared_ptr<FlowInfo> &flow
)
```

Add a dynamic flow from this operator to another operator using a [FlowInfo](../../../classes/operator#flowinfo) object.

**Parameters**

The flow information object describing the connection between operators.

```cpp showLineNumbers={false}
void holoscan::Operator::add_dynamic_flow(
    const std::vector<std::shared_ptr<FlowInfo>> &flows
)
```

Add multiple dynamic flows from this operator using a list of [FlowInfo](../../../classes/operator#flowinfo) objects.

**Parameters**

List of flow information objects describing the connections between operators.

```cpp showLineNumbers={false}
void holoscan::Operator::add_dynamic_flow(
    const std::string &curr_output_port_name,
    const std::shared_ptr<Operator> &next_op,
    const std::string &next_input_port_name = ""
)
```

Add a dynamic flow from this operator to another operator with specified output port.

**Parameters**

The name of the output port on this operator to connect from.

The downstream operator to connect to.

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

```cpp showLineNumbers={false}
void holoscan::Operator::add_dynamic_flow(
    const std::shared_ptr<Operator> &next_op,
    const std::string &next_input_port_name = ""
)
```

Add a dynamic flow from this operator to another operator using default output port.

**Parameters**

The downstream operator to connect to.

The name of the input port on the downstream operator to connect to. If not specified, the first available input port will be used.

### dynamic\_flows \[#dynamicflows]

```cpp showLineNumbers={false}
const std::shared_ptr<std::vector<std::shared_ptr<FlowInfo>>> & holoscan::Operator::dynamic_flows()
```

Get the list of dynamic flows that have been added to this operator.

**Returns:** A shared pointer to a vector of [FlowInfo](../../../classes/operator#flowinfo) objects representing the dynamic flows.

### find\_flow\_info \[#findflowinfo]

```cpp showLineNumbers={false}
const std::shared_ptr<Operator::FlowInfo> & holoscan::Operator::find_flow_info(
    const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &predicate
)
```

Locate a flow info in the operator's next flows based on a given predicate.

**Returns:** Shared pointer to the matching [FlowInfo](../../../classes/operator#flowinfo), or nullptr if not found.

**Parameters**

Lambda function that takes a [FlowInfo](../../../classes/operator#flowinfo) shared pointer and returns a boolean.

### find\_all\_flow\_info \[#findallflowinfo]

```cpp showLineNumbers={false}
std::vector<std::shared_ptr<Operator::FlowInfo>> holoscan::Operator::find_all_flow_info(
    const std::function<bool(const std::shared_ptr<Operator::FlowInfo> &)> &predicate
)
```

Find all [FlowInfo](../../../classes/operator#flowinfo) objects in the operator's next flows that match a given condition.

**Returns:** A vector of shared pointers to the matching [FlowInfo](../../../classes/operator#flowinfo) objects.

**Parameters**

A lambda function that takes a shared pointer to a [FlowInfo](../../../classes/operator#flowinfo) object and returns a boolean.

### async\_condition \[#asynccondition]

```cpp showLineNumbers={false}
std::shared_ptr<holoscan::AsynchronousCondition> holoscan::Operator::async_condition()
```

Get the internal asynchronous condition for the operator.

Note: This object is only accessible after the executor has called `Operator::initialize()` via `run()` or `run_async()`. If accessed during `Application::compose()`, it will return nullptr.

**Returns:** A shared pointer to the internal asynchronous condition.

### stop\_execution \[#stopexecution]

```cpp showLineNumbers={false}
void holoscan::Operator::stop_execution()
```

Stop the execution of the operator.

This method is used to stop the execution of the operator by setting the internal async condition to EVENT\_NEVER state, which sets the scheduling condition to NEVER. Once stopped, the operator will not be scheduled for execution (the `compute()` method will not be called).

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

### execution\_context \[#executioncontext]

```cpp showLineNumbers={false}
virtual std::shared_ptr<holoscan::ExecutionContext> holoscan::Operator::execution_context() const
```

Get the [ExecutionContext](../../../classes/executioncontext) object.

**Returns:** The shared pointer to the [ExecutionContext](../../../classes/executioncontext) object.

### ensure\_contexts \[#ensurecontexts]

```cpp showLineNumbers={false}
void holoscan::Operator::ensure_contexts()
```

Ensure the contexts (input/output/execution) for the operator.

This method is called by the GXFExecutor when the operator is initialized.

### release\_internal\_resources \[#releaseinternalresources]

```cpp showLineNumbers={false}
virtual void holoscan::Operator::release_internal_resources()
```

Internal method to clean up operator resources and prevent circular references.

This is an internal method called automatically by the GXFWrapper during operator shutdown (in `GXFWrapper::stop()` method). It resets std::shared\_ptr fields and std::function objects such as `input_exec_spec_`, `output_exec_spec_`, `next_flows_`, `dynamic_flows_`, and `dynamic_flow_func_` to break potential circular references between connected [Operator](../../../classes/operator) objects.

This is an internal method that should never be called directly by user code. Improper use can lead to undefined behavior.

### operator \[#operator]

```cpp showLineNumbers={false}
*List of restricted substrings that cannot be used in holoscan::Operator::operator(
    e.g. GXF GraphEntity
) override
```

### defaults \[#defaults]

```cpp showLineNumbers={false}
*Set the parameters based on holoscan::Operator::defaults(
    sets GXF parameters for GXF operators
)
```

### is\_gxf\_compatible\_operator\_type \[#isgxfcompatibleoperatortype]

```cpp showLineNumbers={false}
bool holoscan::Operator::is_gxf_compatible_operator_type() const
```

Check if the operator is a GXF compatible operator type.

This checks the OperatorType and returns true if it is one of \{kNative, kGXF, kVirtual}.

**Returns:** True if the operator is a GXF compatible operator type, false otherwise.

### operator std::shared\_ptr\< Executor > executor \[#operatorstdsharedptrexecutorexecutor]

```cpp showLineNumbers={false}
*Get the executor of the holoscan::Operator::operator std::shared_ptr<Executor> executor()
```

### has\_pubsub\_connector \[#haspubsubconnector]

```cpp showLineNumbers={false}
*name Connector type queries *bool holoscan::Operator::has_pubsub_connector()
```

Check if the operator has any UCX connectors.

Check if the operator has any PubSub connectors.

### has\_network\_connector \[#hasnetworkconnector]

```cpp showLineNumbers={false}
bool holoscan::Operator::has_network_connector()
```

Check if the operator has any network (UCX or PubSub) connectors.

### args \[#args]

```cpp showLineNumbers={false}
std::vector<Arg> & holoscan::ComponentBase::args()
```

Get the list of arguments.

**Returns:** The vector of arguments.

### description \[#description]

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

Get a description of the component.

**Returns:** `YAML` string.

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

### service \[#service]

```cpp showLineNumbers={false}
template <typename ServiceT = DefaultFragmentService>
std::shared_ptr<ServiceT> holoscan::ComponentBase::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 `Fragment::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](../../../classes/resource) or [FragmentService](../../../classes/fragmentservice). Defaults to [DefaultFragmentService](../../../classes/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::ComponentBase::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.

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

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

Reset any backend-specific objects (e.g. GXF GraphEntity).

### initialize\_graph\_entity \[#initializegraphentity]

```cpp showLineNumbers={false}
gxf_uid_t holoscan::Operator::initialize_graph_entity(
    void *context,
    const std::string &entity_prefix = ""
)
```

This function creates a GraphEntity corresponding to the operator.

**Returns:** The GXF entity eid corresponding to the graph entity.

**Parameters**

The GXF context.

Prefix to add to the operator's name when creating the GraphEntity.

### initialize\_async\_condition \[#initializeasynccondition]

```cpp showLineNumbers={false}
void holoscan::Operator::initialize_async_condition()
```

Initialize the internal asynchronous condition to control the operator execution.

This method is called by the GXFExecutor when the operator is initialized.

### add\_codelet\_to\_graph\_entity \[#addcodelettographentity]

```cpp showLineNumbers={false}
virtual gxf_uid_t holoscan::Operator::add_codelet_to_graph_entity()
```

Add this operator as the codelet in the GXF GraphEntity.

**Returns:** The codelet component id corresponding to GXF codelet.

### initialize\_conditions \[#initializeconditions]

```cpp showLineNumbers={false}
*Initialize conditions and add GXF conditions to graph_entity_ void holoscan::Operator::initialize_conditions()
```

### initialize\_resources \[#initializeresources]

```cpp showLineNumbers={false}
*Initialize resources and add GXF resources to graph_entity_ void holoscan::Operator::initialize_resources()
```

### update\_params\_from\_args \[#updateparamsfromargs]

```cpp showLineNumbers={false}
*Update parameters based on the specified arguments void holoscan::Operator::update_params_from_args()
```

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

Update parameters based on the specified arguments.

### update\_connector\_arguments \[#updateconnectorarguments]

```cpp showLineNumbers={false}
void holoscan::Operator::update_connector_arguments()
```

Replace any "receiver" supplied as a string with the actual receiver of that name.

Can only be called after GXFExecutor::create\_input\_port so the input ports (receivers) exist.

### find\_ports\_used\_by\_condition\_args \[#findportsusedbyconditionargs]

```cpp showLineNumbers={false}
void holoscan::Operator::find_ports_used_by_condition_args()
```

Determine ports whose transmitter or receiver are associated with an [Arg](../../../classes/arg) for a [Condition](../../../classes/condition).

Should be called before GXFExecutor::create\_input\_port or GXFExecutor::create\_output\_port.

### get\_consolidated\_input\_label \[#getconsolidatedinputlabel]

```cpp showLineNumbers={false}
MessageLabel holoscan::Operator::get_consolidated_input_label()
```

This function returns a consolidated [MessageLabel](../../../classes/messagelabel) for all the input ports of an [Operator](../../../classes/operator).

If there is no input port (root [Operator](../../../classes/operator)), then a new [MessageLabel](../../../classes/messagelabel) with the current [Operator](../../../classes/operator) and default receive timestamp is returned.

**Returns:** The consolidated [MessageLabel](../../../classes/messagelabel)

### update\_input\_message\_label \[#updateinputmessagelabel]

```cpp showLineNumbers={false}
void holoscan::Operator::update_input_message_label(
    std::string input_name,
    MessageLabel m
)
```

Update the input\_message\_labels map with the given [MessageLabel](../../../classes/messagelabel) a corresponding input\_name.

**Parameters**

The input port name for which the [MessageLabel](../../../classes/messagelabel) is updated

The new [MessageLabel](../../../classes/messagelabel) that will be set for the input port

### delete\_input\_message\_label \[#deleteinputmessagelabel]

```cpp showLineNumbers={false}
void holoscan::Operator::delete_input_message_label(
    const std::string &input_name
)
```

Delete the input\_message\_labels map entry for the given input\_name.

**Parameters**

The input port name for which the [MessageLabel](../../../classes/messagelabel) is deleted

### reset\_input\_message\_labels \[#resetinputmessagelabels]

```cpp showLineNumbers={false}
void holoscan::Operator::reset_input_message_labels()
```

Reset the input message labels to clear all its contents.

This is done for a leaf operator when it finishes its execution as it is assumed that all its inputs are processed.

### has\_input\_message\_labels \[#hasinputmessagelabels]

```cpp showLineNumbers={false}
bool holoscan::Operator::has_input_message_labels()
```

Check if the operator has any input message labels.

### num\_published\_messages\_map \[#numpublishedmessagesmap]

```cpp showLineNumbers={false}
std::map<std::string, uint64_t> holoscan::Operator::num_published_messages_map()
```

Get the number of published messages for each output port indexed by the output port name.

The function is utilized by the [DFFTCollector](../../../classes/dfftcollector) to update the [DataFlowTracker](../../../classes/dataflowtracker) with the number of published messages for root operators.

**Returns:** The map of the number of published messages for every output name.

### update\_published\_messages \[#updatepublishedmessages]

```cpp showLineNumbers={false}
void holoscan::Operator::update_published_messages(
    const std::string &output_name
)
```

This function updates the number of published messages for a given output port.

**Parameters**

The name of the output port

### operator.void initialize\_next\_flows \[#operatorvoidinitializenextflows]

```cpp showLineNumbers={false}
*Initialize the next flows for the holoscan::Operator::operator.void initialize_next_flows()
```

### non\_default\_input\_ports \[#nondefaultinputports]

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

### non\_default\_output\_ports \[#nondefaultoutputports]

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

### set\_input\_exec\_spec \[#setinputexecspec]

```cpp showLineNumbers={false}
void holoscan::Operator::set_input_exec_spec(
    const std::shared_ptr<IOSpec> &input_exec_spec
)
```

### set\_output\_exec\_spec \[#setoutputexecspec]

```cpp showLineNumbers={false}
void holoscan::Operator::set_output_exec_spec(
    const std::shared_ptr<IOSpec> &output_exec_spec
)
```

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

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

### set\_self\_shared \[#setselfshared]

```cpp showLineNumbers={false}
void holoscan::Operator::set_self_shared(
    const std::shared_ptr<Operator> &this_op
)
```

### initialize\_execution\_context \[#initializeexecutioncontext]

```cpp showLineNumbers={false}
virtual std::shared_ptr<ExecutionContext> holoscan::Operator::initialize_execution_context()
```

### service\_provider \[#serviceprovider]

```cpp showLineNumbers={false}
void holoscan::ComponentBase::service_provider(
    FragmentServiceProvider *provider
)
```

Set the service provider that owns this component.

***

## Static methods

### is\_all\_operator\_successor\_virtual \[#isalloperatorsuccessorvirtual]

```cpp showLineNumbers={false}
static bool holoscan::Operator::is_all_operator_successor_virtual(
    const OperatorNodeType &op,
    OperatorFlowGraph &graph
)
```

Returns whether all the successors of an operator are virtual operators.

**Returns:** true if the operator has all virtual operator successors, false otherwise

**Parameters**

The shared\_ptr to the operator for which the check is to be performed

The graph of operators. fragment()->graph() can usually be used to get this graph.

### is\_all\_operator\_predecessor\_virtual \[#isalloperatorpredecessorvirtual]

```cpp showLineNumbers={false}
static bool holoscan::Operator::is_all_operator_predecessor_virtual(
    const OperatorNodeType &op,
    OperatorFlowGraph &graph
)
```

Returns whether all the predecessors of an operator are virtual operators.

**Returns:** true if the operator has all virtual operator predecessors, false otherwise

**Parameters**

The shared\_ptr to the operator for which the check is to be performed

The graph of operators. fragment()->graph() can usually be used to get this graph.

### parse\_port\_name \[#parseportname]

```cpp showLineNumbers={false}
static std::pair<std::string, std::string> holoscan::Operator::parse_port_name(
    const std::string &op_port_name
)
```

Return operator name and port name from a string in the format of "\<op\_name>\[.\<port\_name>]".

### parse\_operator\_port\_key \[#parseoperatorportkey]

```cpp showLineNumbers={false}
static std::pair<std::string, std::string> holoscan::Operator::parse_operator_port_key(
    const std::string &operator_port_key
)
```

Return operator name and port name from a string in the format of "\<op\_name>-\<port\_name>".

### register\_codec \[#registercodec]

```cpp showLineNumbers={false}
template <typename typeT>
static void holoscan::Operator::register_codec(
    const std::string &codec_name,
    bool overwrite = true
)
```

Register the codec for serialization/deserialization of a custom type.

Use [holoscan::gxf::GXFExecutor::register\_codec](../../gxf/classes/gxfexecutor#registercodec) instead.

### validate\_operator\_name \[#validateoperatorname]

```cpp showLineNumbers={false}
static void holoscan::Operator::validate_operator_name(
    const std::string &name
)
```

Validate operator name against restricted keywords and patterns.

**Throws:** `std::invalid_argument` if the name contains restricted patterns.

**Parameters**

The name to validate.

### register\_converter \[#registerconverter]

```cpp showLineNumbers={false}
template <typename typeT>
static void holoscan::ComponentBase::register_converter()
```

Register the argument setter for the given type.

If an operator or resource has an argument with a custom type, the argument setter must be registered using this method.

The argument setter is used to set the value of the argument from the `YAML` configuration.

This method can be called in the initialization phase of the operator/resource (e.g., `initialize()`). The example below shows how to register the argument setter for the custom type (`Vec3`):

It is assumed that `YAML::convert<T>::encode` and `YAML::convert<T>::decode` are implemented for the given type. You need to specialize the `YAML::convert<>` template class.

For example, suppose that you had a `Vec3` class with the following members:

You can define the `YAML::convert<Vec3>` as follows in a '.cpp' file:

Please refer to the [yaml-cpp documentation](https://github.com/jbeder/yaml-cpp/wiki/Tutorial#converting-tofrom-native-data-types) for more details.

**Template parameters**

The type of the argument to register.

**Example**

```cpp showLineNumbers={false}
void MyOp::initialize() {
  register_converter<Vec3>();
}
```

**Example**

```cpp showLineNumbers={false}
struct Vec3 {
  // make sure you have overloaded operator==() for the comparison
  double x, y, z;
};
```

**Example**

```cpp showLineNumbers={false}
namespace YAML {
template<>
struct convert<Vec3> {
  static Node encode(const Vec3& rhs) {
    Node node;
    node.push_back(rhs.x);
    node.push_back(rhs.y);
    node.push_back(rhs.z);
    return node;
  }

  static bool decode(const Node& node, Vec3& rhs) {
    if(!node.IsSequence() || node.size() != 3) {
      return false;
    }

    rhs.x = node[0].as<double>();
    rhs.y = node[1].as<double>();
    rhs.z = node[2].as<double>();
    return true;
  }
};
}
```

### register\_argument\_setter \[#registerargumentsetter]

```cpp showLineNumbers={false}
template <typename typeT>
void holoscan::ComponentBase::register_argument_setter()
```

Register the argument setter for the given type.

Please refer to the documentation of `register_converter()` for more details.

**Template parameters**

The type of the argument to register.

***

## Types

### OperatorType

[Operator](../../../classes/operator) type used by the executor.

| Name           | Value | Description                            |
| -------------- | ----- | -------------------------------------- |
| `kNative`      |       | Native operator.                       |
| `kGXF`         |       | GXF operator.                          |
| `kVirtual`     |       | Virtual operator.                      |
| `kGPUResident` |       | GPU-resident operator.                 |
| `kUnknown`     |       | Placeholder for unknown operator type. |

***

## Member variables

| Name                                   | Type                                                                                                                                | Description                                                                           |
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `port_name_`                           | `std::string`                                                                                                                       | The name of the port of the operator connected to this operator in the same fragment. |
| `connector_type_`                      | `IOSpec::ConnectorType`                                                                                                             | The connector type of this operator.                                                  |
| `arg_list_`                            | `ArgList`                                                                                                                           | The argument list of this operator.                                                   |
| `input_spec_`                          | `IOSpec *`                                                                                                                          | The pointer to the input specification for this operator.                             |
| `output_spec_`                         | `IOSpec *`                                                                                                                          | The pointer to the output specification for this operator.                            |
| `io_type_`                             | `IOSpec::IOType`                                                                                                                    |                                                                                       |
| `is_initialized_`                      | `bool`                                                                                                                              | Whether the operator is initialized.                                                  |
| `operator_type_`                       | `OperatorType`                                                                                                                      | The type of the operator.                                                             |
| `spec_`                                | `std::shared_ptr< OperatorSpec >`                                                                                                   | The operator spec of the operator.                                                    |
| `conditions_`                          | `std::unordered_map< std::string, std::shared_ptr< Condition > >`                                                                   | The conditions of the operator.                                                       |
| `resources_`                           | `std::unordered_map< std::string, std::shared_ptr< Resource > >`                                                                    | The resources used by the operator.                                                   |
| `graph_entity_`                        | `std::shared_ptr< nvidia::gxf::GraphEntity >`                                                                                       | GXF graph entity corresponding to.                                                    |
| `internal_async_condition_`            | `*< the Operator *The asynchronous condition to control the operator execution. std::shared_ptr< holoscan::AsynchronousCondition >` |                                                                                       |
| `dynamic_metadata_`                    | `std::shared_ptr< MetadataDictionary >`                                                                                             | The metadata dictionary for the operator.                                             |
| `is_metadata_enabled_`                 | `std::optional< bool >`                                                                                                             | Flag to enable or disable metadata for the operator.                                  |
| `input_exec_spec_`                     | `*< If not set, the value from the Fragment is used. std::shared_ptr< IOSpec >`                                                     | The input execution port specification.                                               |
| `output_exec_spec_`                    | `std::shared_ptr< IOSpec >`                                                                                                         | The output execution port specification.                                              |
| `dynamic_flow_func_`                   | `std::function< void(const std::shared_ptr< Operator > &)>`                                                                         |                                                                                       |
| `self_shared_`                         | `std::weak_ptr< Operator >`                                                                                                         |                                                                                       |
| `next_flows_`                          | `std::shared_ptr< std::vector< std::shared_ptr< FlowInfo > > >`                                                                     |                                                                                       |
| `dynamic_flows_`                       | `std::shared_ptr< std::vector< std::shared_ptr< FlowInfo > > >`                                                                     |                                                                                       |
| `id_`                                  | `int64_t`                                                                                                                           | The ID of the component.                                                              |
| `name_`                                | `std::string`                                                                                                                       | Name of the component.                                                                |
| `fragment_`                            | `Fragment *`                                                                                                                        | Pointer to the fragment that owns this component.                                     |
| `args_`                                | `std::vector< Arg >`                                                                                                                | List of arguments.                                                                    |
| `service_provider_`                    | `FragmentServiceProvider *`                                                                                                         | Pointer to the service provider.                                                      |
| `kInputExecPortName` static constexpr  | `const char *`                                                                                                                      | Default input execution port name.                                                    |
| `kOutputExecPortName` static constexpr | `const char *`                                                                                                                      | Default output execution port name.                                                   |