morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::model::ActionValidator< Action > Struct Template Reference

Per-action readiness predicate deciding whether an action may execute. More...

#include <registry.hpp>

Static Public Member Functions

static constexpr bool ready (const Action &action)
 Returns true if the action is in a state that should be executed.

Detailed Description

template<typename Action>
struct morph::model::ActionValidator< Action >

Per-action readiness predicate deciding whether an action may execute.

Enforced on every dispatch path that reaches Model::execute (see ValidationError below for the sites), and consulted by morph::flows::FlowSession::set<> (forms/flows.hpp) to decide whether an in-progress draft is complete enough to fire.

Resolution order (highest-priority first):

  1. Explicit specialisation of ActionValidator<Action> — typically via BRIDGE_REGISTER_VALIDATOR(Action, fn). Wins over everything.
  2. bool validate() const member on Action — picked up automatically. Co-locates the predicate with the data it inspects; preferred when you own the action type.
  3. Default — returns true, matching one-shot semantics (the first set<> lands and the action fires).

Validation is intentionally a property of the action, not the model: different actions on the same model have different readiness requirements, and keeping the predicate next to the action keeps the GUI side oblivious to model internals.

struct FormAction {
double a;
double b;
double c;
bool validate() const { return a != 0.0 && b != 0.0 && c != 0.0; }
};
// No macro needed; ActionValidator<FormAction>::ready calls .validate() automatically.
Template Parameters
ActionConcrete action type.

Definition at line 261 of file registry.hpp.

Member Function Documentation

◆ ready()

template<typename Action>
constexpr bool morph::model::ActionValidator< Action >::ready ( const Action & action)
inlinestaticconstexpr

Returns true if the action is in a state that should be executed.

Auto-detects a bool validate() const member on action via the morph::model::detail::HasValidate concept. Falls back to true.

Parameters
actionDraft action whose readiness is being checked.
Returns
true if the action should fire, false to keep collecting fields.

Definition at line 269 of file registry.hpp.


The documentation for this struct was generated from the following file: