Class OnChangeEvaluator

Inheritance Relationships

Base Type

Class Documentation

class OnChangeEvaluator : public ros2_medkit_gateway::ConditionEvaluator

Fires when the current value differs from the previous value. First evaluation (no previous) always fires.

Public Functions

inline virtual bool evaluate(const std::optional<nlohmann::json> &previous, const nlohmann::json &current, const nlohmann::json&) 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&) const override

Validate condition parameters before a trigger is created.

Parameters:

params – The parameters to validate

Returns:

void on success, error string on failure