Class OnChangeToEvaluator

Inheritance Relationships

Base Type

Class Documentation

class OnChangeToEvaluator : public ros2_medkit_gateway::ConditionEvaluator

Fires when the current value equals a target AND differs from the previous. First evaluation (no previous) checks target only. Requires params: {“target_value”: <any JSON value>}

Public Functions

inline virtual bool evaluate(const std::optional<nlohmann::json> &previous, const nlohmann::json &current, const nlohmann::json &params) const override

Evaluate whether the condition is met.

Parameters:
  • previous – The previous value (nullopt on first evaluation)

  • current – The current value

  • params – Condition-specific parameters (e.g., target_value, bounds)

Pre:

validate_params(params) must have returned success before calling evaluate.

Returns:

true if the condition is met and the trigger should fire

inline virtual tl::expected<void, std::string> validate_params(const nlohmann::json &params) const override

Validate condition parameters before a trigger is created.

Parameters:

params – The parameters to validate

Returns:

void on success, error string on failure