Class Operator

Base Type

Derived Type

class Operator : public holoscan::Component

Base class for all operators.

An operator is the most basic unit of work in Holoscan Embedded SDK. An Operator receives streaming data at an input port, processes it, and publishes it to one of its output ports.

This class is the base class for all operators. It provides the basic functionality for all operators.

Note

This class is not intended to be used directly. Inherit from this class to create a new operator.

Subclassed by holoscan::ops::GXFOperator

Public Functions

template<typename ArgT, typename ...ArgsT, typename = std::enable_if_t<!std::is_base_of_v<Operator, std::decay_t<ArgT>> && (std::is_same_v<Arg, std::decay_t<ArgT>> || std::is_same_v<ArgList, std::decay_t<ArgT>> || std::is_base_of_v<holoscan::Condition, typename holoscan::type_info<ArgT>::element_type> || std::is_base_of_v<holoscan::Resource, typename holoscan::type_info<ArgT>::element_type>)>>
inline Operator(ArgT &&arg, ArgsT&&... args)

Construct a new Operator object.

Parameters:

args – The arguments to be passed to the operator.

Operator() = default

~Operator() override = default

inline Operator &name(const std::string &name)

Set the name of the operator.

Parameters:

name – The name of the operator.

Returns:

The reference to this operator.

inline Operator &fragment(Fragment *fragment)

Set the fragment of the operator.

Parameters:

fragment – The pointer to the fragment of the operator.

Returns:

The reference to this operator.

inline Operator &spec(std::unique_ptr<OperatorSpec> spec)

Set the operator spec.

Parameters:

spec – The operator spec.

Returns:

The reference to this operator.

inline OperatorSpec *spec()

Get the operator spec.

Returns:

The operator spec.

inline std::unordered_map<std::string, std::shared_ptr<Condition>> &conditions()

Get the conditions of the operator.

Returns:

The conditions of the operator.

inline std::unordered_map<std::string, std::shared_ptr<Resource>> &resources()

Get the resources of the operator.

Returns:

The resources of the operator.

inline void add_arg(const std::shared_ptr<Condition> &arg)

Add a condition to the operator.

Parameters:

arg – The condition to add.

inline void add_arg(std::shared_ptr<Condition> &&arg)

Add a condition to the operator.

Parameters:

arg – The condition to add.

inline void add_arg(const std::shared_ptr<Resource> &arg)

Add a resource to the operator.

Parameters:

arg – The resource to add.

inline void add_arg(std::shared_ptr<Resource> &&arg)

Add a resource to the operator.

Parameters:

arg – The resource to add.

inline virtual void setup(OperatorSpec &spec)

Define the operator specification.

Parameters:

spec – The reference to the operator specification.

inline virtual void 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.

inline virtual void 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.

inline virtual void 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:
  • op_input – The input context of the operator.

  • op_output – The output context of the operator.

  • context – The execution context of the operator.

inline const std::string &name() const

Get the name of the component.

Returns:

The name of the component.

inline Fragment *fragment()

Get a pointer to Fragment object.

Returns:

The Pointer to Fragment object.

inline void add_arg(const Arg &arg)

Add an argument to the component.

Parameters:

arg – The argument to add.

inline void add_arg(Arg &&arg)

Add an argument to the component.

Parameters:

arg – The argument to add.

inline void add_arg(const ArgList &arg)

Add a list of arguments to the component.

Parameters:

arg – The list of arguments to add.

inline void add_arg(ArgList &&arg)

Add a list of arguments to the component.

Parameters:

arg – The list of arguments to add.

Protected Attributes

std::unique_ptr<OperatorSpec> spec_

The operator spec of the operator.

std::unordered_map<std::string, std::shared_ptr<Condition>> conditions_

The conditions of the operator.

std::unordered_map<std::string, std::shared_ptr<Resource>> resources_

The resources used by the operator.

© Copyright 2022, NVIDIA. Last updated on Jun 28, 2023.