|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
View-schema generation: composes a registered query action's result rows with an optional row-opener action and row/collection action buttons into a list/table or master-detail screen descriptor. More...
#include <algorithm>#include <cstddef>#include <cstdint>#include <functional>#include <glaze/glaze.hpp>#include <span>#include <stdexcept>#include <string>#include <string_view>#include <type_traits>#include <unordered_map>#include <utility>#include <vector>#include "../core/registry.hpp"#include "forms.hpp"Go to the source code of this file.
Classes | |
| struct | morph::views::BindEntry |
| Maps one target-action wire field to a row wire field, so a row's current value prefills the action's draft before it fires. More... | |
| struct | morph::views::ActionDescriptor |
| One action a view screen can fire — the row opener (v-rowAction) or an entry of v-actions. More... | |
| struct | morph::views::ColumnOverride |
| Declare-to-override entry for one derived column of a collection view. More... | |
| struct | morph::views::CollectionView |
| Tag type: V::kind selects a plain list/table screen. More... | |
| struct | morph::views::MasterDetailView |
| Tag type: V::kind selects a list + inline/side editor screen. Introduces no JSON keys beyond CollectionView — purely a rendering choice a conformant renderer may act on. More... | |
| class | morph::views::ViewRegistry |
| Process-level registry mapping a view's string type-id to its viewSchemaJson<V>() provider, so a controller can enumerate every registered view by name — parallels ActionExecuteRegistry for actions (docs/spec/core/bridge.md), but a view registers no executor, only a schema provider. More... | |
Macros | |
| #define | BRIDGE_REGISTER_VIEW(V, NAME) |
Registers view descriptor V with the string id NAME. | |
Enumerations | |
| enum class | morph::views::ActionScope : std::uint8_t { Row , Collection } |
| Where a view action button appears: opened per row, or once for the whole collection. More... | |
Functions | |
| template<typename Action> | |
| consteval ActionDescriptor | morph::views::describeAction (std::string_view label={}, ActionScope scope=ActionScope::Row, std::span< const BindEntry > bind={}, bool confirm=false) |
Builds an ActionDescriptor for Action, resolving its wire type id from the real, registered ActionTraits<Action> rather than a hand-typed string. | |
| template<typename V> | |
| const std::string & | morph::views::viewSchemaJson () |
Generates the view-schema JSON document for view descriptor V. | |
View-schema generation: composes a registered query action's result rows with an optional row-opener action and row/collection action buttons into a list/table or master-detail screen descriptor.
Where morph::forms::schemaJson<A>() describes one action, this header describes a set of related actions — a query, an edit, a delete — as a single, additional JSON document, morph::views::viewSchemaJson<V>(), emitted alongside (never merged into) the action schemas. See docs/spec/forms/views.md.
Definition in file views.hpp.
| #define BRIDGE_REGISTER_VIEW | ( | V, | |
| NAME ) |
Registers view descriptor V with the string id NAME.
Specialises morph::views::ViewTraits<V> and registers V's viewSchemaJson<V>() provider with the process-level ViewRegistry at static-init time — parallels BRIDGE_REGISTER_ACTION (registry.hpp), but a view has no dispatch path: it is metadata only, so this macro needs only <morph/core/registry.hpp>, never <morph/core/bridge.hpp>.
| V | Concrete, unqualified view descriptor type in scope at the call site (bring a namespaced type into scope with using ns::V; first — this macro pastes V into an identifier, so it cannot be namespace-qualified). |
| NAME | String literal used as the view's type-id. |
|
strong |
|
nodiscardconsteval |
Builds an ActionDescriptor for Action, resolving its wire type id from the real, registered ActionTraits<Action> rather than a hand-typed string.
| Action | Registered action type — BRIDGE_REGISTER_ACTION for Action must already have run earlier in this translation unit, or ActionTraits<Action> is incomplete and this fails to compile. |
| label | Button label. Defaults to empty ("use the action type id"). |
| scope | Row button vs. collection-wide button. Defaults to Row. |
| bind | Field-name mapping prefilling the action's draft from the activating row. Defaults to empty (no prefill). |
| confirm | Whether a renderer must confirm before firing. Defaults to false. |
|
nodiscard |
Generates the view-schema JSON document for view descriptor V.
A new, separate top-level document from morph::forms::schemaJson<A>() — never merged into any action schema. Computed once per type and cached, exactly like schemaJson<A>() — and, like it, returned by reference: the cache is created once per type per process, never mutated afterwards, and lives until the process exits, so the reference stays valid for as long as any caller could hold it. A caller that needs its own mutable copy asks for one (std::string mine = viewSchemaJson<V>();).
| V | View descriptor: using kind = CollectionView (or MasterDetailView); using query = <registered query action>; optional static constexpr std::string_view title, rowKey, std::array<ColumnOverride, N> columns, ActionDescriptor rowAction, and std::array<ActionDescriptor, N> actions. |