What can I help you with?
NVIDIA Holoscan SDK v3.1.0

Class Condition

Base Type

Derived Type

class Condition : public holoscan::Component

Base class for all conditions.

A condition is a predicate that can be evaluated at runtime to determine if an operator should execute. This matches the semantics of GXF’s Scheduling Term.

Subclassed by holoscan::gxf::GXFCondition

Public Types

enum class ConditionComponentType

Resource type used for the initialization of the resource.

Values:

enumerator kNative

Native condition.

enumerator kGXF

GXF condition (scheduling term).

Public Functions

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

Construct a new Condition object.

~Condition() override = default
inline virtual void check(int64_t timestamp, SchedulingStatusType *status_type, int64_t *target_timestamp) const

Check the condition status before allowing execution.

If the condition is waiting for a time event ‘target_timestamp’ will contain the target timestamp.

Parameters
  • timestamp – The current timestamp

  • type – The status of the condition

  • target_timestamp – The target timestamp (used if the term is waiting for a time event).

inline virtual void on_execute(int64_t timestamp)

Called each time after the entity of this term was executed.

Parameters

timestamp – The current timestamp

inline virtual void update_state(int64_t timestamp)

Checks if the state of the condition can be updated and updates it.

Parameters

timestamp – The current timestamp

inline ConditionComponentType condition_type() const

Get the condition type.

Returns

The condition type.

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

Set the name of the condition.

Parameters

name – The name of the condition.

Returns

The reference to the condition.

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

Set the name of the condition.

Parameters

name – The name of the condition.

Returns

The reference to the condition.

inline Condition &fragment(Fragment *fragment)

Set the fragment of the condition.

Parameters

fragment – The pointer to the fragment of the condition.

Returns

The reference to the condition.

inline Condition &spec(const std::shared_ptr<ComponentSpec> &spec)

Set the component specification to the condition.

Parameters

spec – The component specification.

Returns

The reference to the condition.

inline ComponentSpec *spec()

Get the component specification of the condition.

Returns

The pointer to the component specification.

inline std::shared_ptr<ComponentSpec> spec_shared()

Get the shared pointer to the component spec.

Returns

The shared pointer to the component spec.

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

Add a resource to the condition.

Parameters

arg – The resource to add.

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

Add a resource to the condition.

Parameters

arg – The resource to add.

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

Get the resources of the condition.

Returns

The resources of the condition.

inline virtual void setup(ComponentSpec &spec)

Define the condition specification.

Parameters

spec – The reference to the component specification.

virtual void initialize() override

Initialize the component.

This method is called only once when the component is created for the first time, and use of light-weight initialization.

virtual YAML::Node to_yaml_node() const override

Get a YAML representation of the condition.

Returns

YAML node including spec of the condition in addition to the base component properties.

std::optional<std::shared_ptr<Receiver>> receiver(const std::string &port_name)

Return the Receiver corresponding to a specific input port of the Operator associated with this condition.

Parameters

port_name – The name of the input port.

Returns

The Receiver corresponding to the input port, if it exists. Otherwise, return nullopt.

std::optional<std::shared_ptr<Transmitter>> transmitter(const std::string &port_name)

Return the Transmitter corresponding to a specific output port of the Operator associated with this condition.

Parameters

port_name – The name of the output port.

Returns

The Transmitter corresponding to the output port, if it exists. Otherwise, return nullopt.

gxf_uid_t wrapper_cid() const

Get the GXF component ID of the underlying GXFSchedulingTermWrapper

This method is only relevant for native conditions. For conditions inheriting from GXFCondition, please use GXFCondition::gxf_cid() instead.

Returns

The unique GXF component id for this condition.

Protected Functions

inline void set_operator(Operator *op)

Set the Operator this condition is associated with.

Parameters

op – The pointer to the Operator object.

void wrapper_cid(gxf_uid_t cid)

Store GXF component ID of underlying GXFSchedulingTermWrapper

Parameters

GXF – component id.

void update_params_from_args()

Update parameters based on the specified arguments.

virtual void set_parameters()

Set the parameters based on defaults (sets GXF parameters for GXF components)

void update_params_from_args(std::unordered_map<std::string, ParameterWrapper> &params)

Update parameters based on the specified arguments.

Protected Attributes

bool is_initialized_ = false

Whether the condition is initialized.

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

The resources used by the condition.

ConditionComponentType condition_type_ = ConditionComponentType::kNative

The type of the component.

Operator *op_ = nullptr

The operator this condition is associated with.

gxf_uid_t wrapper_cid_ = 0

Component ID of underlying GXFSchedulingTermWrapper.

Friends

friend class holoscan::Operator

Previous Class ComponentSpec
Next Class ConditionCombiner
© Copyright 2022-2025, NVIDIA. Last updated on Apr 30, 2025.