morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::author::DeclScope Class Reference

A scope's declarations (spec 5 §3): model aliases, state, let, queries, mutations, watches and checks. A row, a dialog, a drawer and a switch case declare theirs on the scope their builder hands over. More...

#include <author.hpp>

Inheritance diagram for morph::ui::author::DeclScope:
morph::ui::author::Scope

Public Member Functions

 DeclScope ()=default
 An empty scope.
template<typename Model>
ModelHandle< Model > model (std::string const &alias, ModelOptions const &options={})
 A model alias.
template<typename T>
Handle< T > state (std::string const &name)
 State with a declared type and no initial value; it starts null.
template<typename T>
Handle< T > state (std::string const &name, Handle< T > const &init)
 State initialised from an expression; its type is T's.
template<typename L>
requires detail::Literal<L>
Handle< detail::LiteralT< L > > state (std::string const &name, L const &init)
 State initialised from a constant; its type is the constant's.
template<typename T>
Handle< T > let (std::string const &name, Handle< T > const &value)
 A derived value (let).
template<typename Action, typename Model>
requires Runs<Model, Action>
QueryHandle< Action > query (std::string const &name, ModelHandle< Model > const &model, Body< Action > const &body={}, QueryOptions const &options={})
 A query (spec 5 §5).
template<typename Action, typename Model>
requires Runs<Model, Action>
QueryHandle< Action, Action > evaluate (std::string const &name, ModelHandle< Model > const &model, Body< Action > const &body={}, QueryOptions const &options={})
 A query that evaluates an action without running it: the server returns its calculated fields and field errors (spec 5 §7).
template<typename Action, typename Model>
requires Runs<Model, Action>
MutationHandle< Action > mutation (std::string const &name, ModelHandle< Model > const &model, MutationOptions< Action > const &options={})
 A mutation (spec 5 §5).
void watch (AnyHandle const &watched, Commands const &commands, Source source=Source::Any)
 A cascade: commands that run when a value changes (spec 5 §6).
void check (CheckOptions const &options)
 A validation across elements (spec 5 §6).
bool empty () const
 Whether the scope declares nothing.
void writeTo (Json &out) const
 Writes the declarations into a document or a "scope" object, in the document's order.
CatalogFacts const & facts () const noexcept
 The catalog facts of the models and actions the scope names.

Protected Member Functions

CatalogFacts & recordedFacts () noexcept
 The catalog facts, for a scope that records more.

Detailed Description

A scope's declarations (spec 5 §3): model aliases, state, let, queries, mutations, watches and checks. A row, a dialog, a drawer and a switch case declare theirs on the scope their builder hands over.

Definition at line 2045 of file author.hpp.

Member Function Documentation

◆ model()

template<typename Model>
ModelHandle< Model > morph::ui::author::DeclScope::model ( std::string const & alias,
ModelOptions const & options = {} )
inline

A model alias.

Template Parameters
ModelThe model type; morph::model::ModelTraits<Model> names it.
Parameters
aliasThe alias.
optionsHow it binds.
Returns
The alias's handle.

Definition at line 2056 of file author.hpp.

◆ state() [1/3]

template<typename T>
Handle< T > morph::ui::author::DeclScope::state ( std::string const & name)
inline

State with a declared type and no initial value; it starts null.

Template Parameters
TThe state's type.
Parameters
nameThe state's name.
Returns
The read of the state.

Definition at line 2072 of file author.hpp.

◆ state() [2/3]

template<typename T>
Handle< T > morph::ui::author::DeclScope::state ( std::string const & name,
Handle< T > const & init )
inline

State initialised from an expression; its type is T's.

Template Parameters
TThe state's type.
Parameters
nameThe state's name.
initThe initial value.
Returns
The read of the state.

Definition at line 2082 of file author.hpp.

◆ state() [3/3]

template<typename L>
requires detail::Literal<L>
Handle< detail::LiteralT< L > > morph::ui::author::DeclScope::state ( std::string const & name,
L const & init )
inline

State initialised from a constant; its type is the constant's.

Template Parameters
LThe constant's C++ type.
Parameters
nameThe state's name.
initThe initial value.
Returns
The read of the state.

Definition at line 2093 of file author.hpp.

◆ let()

template<typename T>
Handle< T > morph::ui::author::DeclScope::let ( std::string const & name,
Handle< T > const & value )
inline

A derived value (let).

Template Parameters
TThe value type.
Parameters
nameThe name.
valueThe expression.
Returns
The read of the name.

Definition at line 2103 of file author.hpp.

◆ query()

template<typename Action, typename Model>
requires Runs<Model, Action>
QueryHandle< Action > morph::ui::author::DeclScope::query ( std::string const & name,
ModelHandle< Model > const & model,
Body< Action > const & body = {},
QueryOptions const & options = {} )
inline

A query (spec 5 §5).

Template Parameters
ActionThe action it runs.
ModelThe model type of the alias; it must run the action.
Parameters
nameThe query's name.
modelThe alias it goes through.
bodyThe body, which is the query's key.
optionsThe gate and timing.
Returns
The query's handle.

Definition at line 2118 of file author.hpp.

◆ evaluate()

template<typename Action, typename Model>
requires Runs<Model, Action>
QueryHandle< Action, Action > morph::ui::author::DeclScope::evaluate ( std::string const & name,
ModelHandle< Model > const & model,
Body< Action > const & body = {},
QueryOptions const & options = {} )
inline

A query that evaluates an action without running it: the server returns its calculated fields and field errors (spec 5 §7).

Template Parameters
ActionThe action it evaluates.
ModelThe model type of the alias; it must run the action.
Parameters
nameThe query's name.
modelThe alias it goes through.
bodyThe body, which is the query's key.
optionsThe gate and timing.
Returns
The query's handle. Its value is the action body as the server reconciled it, computed fields filled, with errors and ready beside the fields.

Definition at line 2136 of file author.hpp.

◆ mutation()

template<typename Action, typename Model>
requires Runs<Model, Action>
MutationHandle< Action > morph::ui::author::DeclScope::mutation ( std::string const & name,
ModelHandle< Model > const & model,
MutationOptions< Action > const & options = {} )
inline

A mutation (spec 5 §5).

Template Parameters
ActionThe action it runs.
ModelThe model type of the alias; it must run the action.
Parameters
nameThe mutation's name.
modelThe alias it goes through.
optionsIts body, concurrency, optimistic write and command lists.
Returns
The mutation's handle.

Definition at line 2151 of file author.hpp.

◆ watch()

void morph::ui::author::DeclScope::watch ( AnyHandle const & watched,
Commands const & commands,
Source source = Source::Any )
inline

A cascade: commands that run when a value changes (spec 5 §6).

Parameters
watchedThe value watched.
commandsThe commands.
sourceWhich changes run it.

Definition at line 2170 of file author.hpp.

◆ check()

void morph::ui::author::DeclScope::check ( CheckOptions const & options)
inline

A validation across elements (spec 5 §6).

Parameters
optionsThe check.

Definition at line 2182 of file author.hpp.

◆ empty()

bool morph::ui::author::DeclScope::empty ( ) const
inlinenodiscard

Whether the scope declares nothing.

Returns
True when it declares nothing.

Definition at line 2205 of file author.hpp.

◆ writeTo()

void morph::ui::author::DeclScope::writeTo ( Json & out) const
inline

Writes the declarations into a document or a "scope" object, in the document's order.

Parameters
outThe object to write into.

Definition at line 2214 of file author.hpp.

◆ facts()

CatalogFacts const & morph::ui::author::DeclScope::facts ( ) const
inlinenodiscardnoexcept

The catalog facts of the models and actions the scope names.

Returns
The facts.

Definition at line 2230 of file author.hpp.

◆ recordedFacts()

CatalogFacts & morph::ui::author::DeclScope::recordedFacts ( )
inlinenodiscardprotectednoexcept

The catalog facts, for a scope that records more.

Returns
The facts.

Definition at line 2235 of file author.hpp.


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