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

Collects an application's screens and files and builds the bundle the UI service serves. More...

#include <service.hpp>

Public Member Functions

 UiRegistry (ApplicationInfo application, Catalog catalog={})
 An empty registry.
std::expected< void, Refusal > addScreen (CatalogEntry entry, std::string text)
 Registers a screen: its catalog entry and its document.
std::expected< void, Refusal > addEntry (CatalogEntry entry)
 Lists an entry that has no document: a host screen (host), or one the application has not built (available: false).
std::expected< void, Refusal > addFile (BundleFile file)
 Adds a file that is not a screen: the app document (app, whose id is app), a theme (theme), a message catalogue (messages), a delivered component (component) or an icon (icon).
void requireVocabulary (std::string vocabulary)
 Adds a vocabulary the bundle needs beyond ui/1 and expr/1, such as forms/1 or files/1. A client that does not speak it is refused at ui-hello.
std::expected< std::shared_ptr< ServedBundle const >, Refusal > build () const
 Builds the bundle.

Detailed Description

Collects an application's screens and files and builds the bundle the UI service serves.

Built once, before the service answers anything; build copies everything into an immutable ServedBundle. A screen authored with the C++ builders is added by its emitted text, so an authoring registry feeds this one through addScreen without either depending on the other.

Definition at line 285 of file service.hpp.

Constructor & Destructor Documentation

◆ UiRegistry()

morph::ui::UiRegistry::UiRegistry ( ApplicationInfo application,
Catalog catalog = {} )
inlineexplicit

An empty registry.

Parameters
applicationThe application ui-hello names.
catalogThe catalog facts: load-time validation reads them at registration, and the ui-catalog reply carries them to the client. A lookup left empty is neither checked nor served.

Definition at line 292 of file service.hpp.

Member Function Documentation

◆ addScreen()

std::expected< void, Refusal > morph::ui::UiRegistry::addScreen ( CatalogEntry entry,
std::string text )
inline

Registers a screen: its catalog entry and its document.

Refused when the entry's id is empty, longer than kMaxNameBytes, already registered, or not the document's id; when whenDenied is neither hide nor disable; when the entry names a host (a host screen has no document: addEntry); when the document is app (addFile); when the text is too large to serve; and when load-time validation refuses the document.

Parameters
entryThe catalog entry.
textThe document's JSON text, served byte for byte.
Returns
Nothing, or the refusal.

Definition at line 304 of file service.hpp.

◆ addEntry()

std::expected< void, Refusal > morph::ui::UiRegistry::addEntry ( CatalogEntry entry)
inline

Lists an entry that has no document: a host screen (host), or one the application has not built (available: false).

Refused on the same entry rules as addScreen, and when the entry is neither a host screen nor unavailable.

Parameters
entryThe catalog entry.
Returns
Nothing, or the refusal.

Definition at line 322 of file service.hpp.

◆ addFile()

std::expected< void, Refusal > morph::ui::UiRegistry::addFile ( BundleFile file)
inline

Adds a file that is not a screen: the app document (app, whose id is app), a theme (theme), a message catalogue (messages), a delivered component (component) or an icon (icon).

Refused for another kind, an empty or over-long id, a kind and id already added, a file too large to serve, an app document that load-time validation refuses or whose id is not app, a message catalogue whose id is not i18n/LOCALE.json, that parseCatalogue refuses, or that has a pattern outside the ui/1 subset, and a theme file that is neither a theme index parseThemeIndex takes nor a token file parseTokens takes, and an icon that is not SVG text or is larger than kMaxIconBytes.

Parameters
fileThe file.
Returns
Nothing, or the refusal.

Definition at line 343 of file service.hpp.

◆ requireVocabulary()

void morph::ui::UiRegistry::requireVocabulary ( std::string vocabulary)
inline

Adds a vocabulary the bundle needs beyond ui/1 and expr/1, such as forms/1 or files/1. A client that does not speak it is refused at ui-hello.

Parameters
vocabularyThe vocabulary.

Definition at line 359 of file service.hpp.

◆ build()

std::expected< std::shared_ptr< ServedBundle const >, Refusal > morph::ui::UiRegistry::build ( ) const
inlinenodiscard

Builds the bundle.

Refused when a screen names a delivered component (qml) whose hash no component file has, when the bundle holds more than kMaxBundleFiles files or entries, and when it needs more than kMaxListItems vocabularies or a vocabulary name longer than kMaxNameBytes.

Returns
The bundle, or the refusal.

Definition at line 367 of file service.hpp.


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