|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Runs a linked application in-process (--app): its models over a LocalBackend, its bundle answered by a UiService in the same process, and verified by the same client as a remote one. More...
#include <source.hpp>
Public Member Functions | |
| LocalSource (LocalApp app, LocalSetup setup) | |
A source for app. | |
| LocalSource (LocalSource const &)=delete | |
| LocalSource & | operator= (LocalSource const &)=delete |
| LocalSource (LocalSource &&)=delete | |
| LocalSource & | operator= (LocalSource &&)=delete |
| std::string | signedOutPrincipal () const override |
| The development user, from --user. | |
| Public Member Functions inherited from morph::client::Source | |
| ui::Dispatcher & | dispatcher () |
| Where the screens' model calls go. | |
| ui::Catalog | catalog () const |
| The catalog facts the screens load with. | |
| std::vector< std::string > | screens () const |
| The screens the principal may open, in catalog order: each catalog entry that is available or public and whose document the bundle holds. | |
| bool | isPublic (std::string_view screenId) const |
Whether the catalog marks screenId public: a screen served before sign-in, such as a login screen. | |
| void | open (ui::AppContext &context, std::function< void(std::expected< ui::Bundle, ui::ConnectError >)> ready) final |
| Opens the source: the transport, the bridge and the bundle, verified. | |
| void | switchBackend (ui::Backend backend, std::function< void(std::expected< void, std::string >)> done) final |
| Refused: a switch between backends is the hosting layer's (spec 6 §9). | |
| void | close () final |
| Drops a ready not yet delivered and releases the bridge, the transport and the bundle. | |
| void | signIn (std::string principal, std::string token, std::function< void(bool)> done) |
Installs a sign-in (spec 6 §5): a session built from the current one with principal and token replaced, carried by every later model call and UI-service request, then the catalog reloaded for it. | |
| void | signOut (std::function< void(bool)> done) |
| Ends the session: back to the principal before any sign-in, with no token, and the catalog reloaded for it. | |
| std::function< std::shared_ptr< ui::Document const >(std::string_view)> | documents (std::function< void(ui::Refusal const &)> onRefused={}) |
| The lookup a DocumentScreenHost takes (DocumentScreenHostOptions::documents), over the loaded bundle: each screen the source lists, loaded against the current catalog facts the first time it is asked for after a load, so a shell of an application's own mounts with the same source. | |
| ui::Bundle const * | bundle () const noexcept |
| The bundle the catalog currently lists. | |
| ui::CatalogReply const * | catalogReply () const noexcept |
| The catalog for the current principal: its entries, what the principal may run, and the facts. | |
| ui::SchemasByModel const & | schemasByModel () const noexcept |
| The schemas document of every model the catalog names, by model type, or why it did not arrive: what the explorer lists each model's actions from. | |
| std::string const & | principal () const noexcept |
| The principal the source's session carries now. | |
| std::optional< ui::FileTransfer > | files () const |
| The file side channel (files/1) over the source's exchange, carrying its session: what a screen's upload and download move bytes through. | |
| void | poll (std::function< void(std::vector< std::string > changed)> changed) |
| One step of development reload (spec 5 §12): sends ui-hello, and when the manifest digest changed, fetches the changed bundle and the catalog for it. Nothing is sent while a poll is still in flight. | |
| void | onConnected (std::function< void()> const &listener) final |
| Adds a listener called on the owner after each successful connect, the first included. On a reconnect the source first sends ui-hello again, so the new connection negotiates events, then calls the listeners. | |
| void | onEvent (std::function< void(wire::EventBody const &)> listener) |
| Adds a listener for the events the server sends: what a shell hands to Session::deliverEvent. | |
| ui::Watcher | watcher () |
| What the session's SessionOptions::watcher sends the cache's watch changes through: watcherOver the source's exchange, stamping the session current at each send. Empty for a source whose transport carries no server events, such as an in-process one. | |
| Public Member Functions inherited from morph::ui::AppSource | |
| AppSource (AppSource const &)=delete | |
| AppSource & | operator= (AppSource const &)=delete |
| AppSource (AppSource &&)=delete | |
| AppSource & | operator= (AppSource &&)=delete |
| virtual void | open (AppContext &context, std::function< void(std::expected< Bundle, ConnectError >)> ready)=0 |
| Connects (or, local, sets up the models), signs the user in natively if the application needs it, and delivers the bundle. | |
Protected Member Functions | |
| std::expected< Transport, ui::ConnectError > | connect (ui::AppContext &context) override |
Makes the transport on context. | |
| void | disconnect () override |
| Releases what connect made beside the backend; called by close, after the bridge is gone. | |
| void | fetchSchemas (std::string const &modelType, std::function< void(std::expected< std::string, std::string >)> done) override |
| Fetches the {actionType: schema} document of one model type, which a form, collection or wizard node is built from. The default sends a schemas envelope over the source's exchange. | |
| Protected Member Functions inherited from morph::client::Source | |
| virtual std::chrono::milliseconds | openTimeout () const |
| How long open waits for the bundle before it reports the source unreachable; zero waits forever. | |
| session::Context & | requestSession () noexcept |
| The session every request carries, for a source to fill before open sends anything. | |
Runs a linked application in-process (--app): its models over a LocalBackend, its bundle answered by a UiService in the same process, and verified by the same client as a remote one.
Definition at line 285 of file source.hpp.
| morph::client::LocalSource::LocalSource | ( | LocalApp | app, |
| LocalSetup | setup ) |
A source for app.
| app | The application. |
| setup | Its set-up options. |
|
inlinenodiscardoverridevirtual |
The development user, from --user.
Reimplemented from morph::client::Source.
Definition at line 299 of file source.hpp.
|
nodiscardoverrideprotectedvirtual |
Makes the transport on context.
| context | The running frontend's context. |
Implements morph::client::Source.
|
overrideprotectedvirtual |
Releases what connect made beside the backend; called by close, after the bridge is gone.
Reimplemented from morph::client::Source.
|
overrideprotectedvirtual |
Fetches the {actionType: schema} document of one model type, which a form, collection or wizard node is built from. The default sends a schemas envelope over the source's exchange.
| modelType | The model type id. |
| done | Called once with the document's JSON text, or why there is none. |
Reimplemented from morph::client::Source.