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

Where the screens and the models are: a server (remote) or the application linked in-process (local). More...

#include <frontend.hpp>

Inheritance diagram for morph::ui::AppSource:
morph::client::Source morph::client::LocalSource morph::client::RemoteSource

Public Member Functions

 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.
virtual void switchBackend (Backend backend, std::function< void(std::expected< void, std::string >)> done)=0
 Replaces the dispatch target under the mounted screens: Bridge::switchBackend, posted to the owner.
virtual void close ()=0
 Releases everything open made (connections, bridges, handlers) and drops a ready not yet delivered. Called by runApp once the screens are gone and before the frontend's runtime is; the source may be opened again afterwards.
virtual void onConnected (std::function< void()> const &listener)
 Adds a listener called on the owner after each successful connect to the server, the first included (spec 8 §7, "Reconnect"). A shell registers Session::reconnected here, so the session re-sends its watch set and re-reads what it shows after an outage. The source owns the backend's single connect hook, so anything else that wants connects subscribes here too.

Detailed Description

Where the screens and the models are: a server (remote) or the application linked in-process (local).

main builds one from its arguments and hands it to Frontend::run. Every call is made on the context's owner executor, and every callback it is given must be called there too.

Definition at line 137 of file frontend.hpp.

Member Function Documentation

◆ open()

virtual void morph::ui::AppSource::open ( AppContext & context,
std::function< void(std::expected< Bundle, ConnectError >)> ready )
pure virtual

Connects (or, local, sets up the models), signs the user in natively if the application needs it, and delivers the bundle.

Parameters
contextThe running frontend's context; its executor is every bridge's callback executor.
readyCalled once, on the owner, now or later, with the bundle or why there is none. A source that is closed first never calls it.

◆ switchBackend()

virtual void morph::ui::AppSource::switchBackend ( Backend backend,
std::function< void(std::expected< void, std::string >)> done )
pure virtual

Replaces the dispatch target under the mounted screens: Bridge::switchBackend, posted to the owner.

Parameters
backendOne of the application's backends.
doneCalled once, on the owner, when the switch committed, or with why it did not; a switch that fails leaves the old backend in place.

Implemented in morph::client::Source.

◆ close()

virtual void morph::ui::AppSource::close ( )
pure virtual

Releases everything open made (connections, bridges, handlers) and drops a ready not yet delivered. Called by runApp once the screens are gone and before the frontend's runtime is; the source may be opened again afterwards.

Implemented in morph::client::Source.

◆ onConnected()

virtual void morph::ui::AppSource::onConnected ( std::function< void()> const & listener)
inlinevirtual

Adds a listener called on the owner after each successful connect to the server, the first included (spec 8 §7, "Reconnect"). A shell registers Session::reconnected here, so the session re-sends its watch set and re-reads what it shows after an outage. The source owns the backend's single connect hook, so anything else that wants connects subscribes here too.

The default does nothing: a local source has no connection to lose.

Parameters
listenerCalled on the owner after each connect; it must stay callable while the source is open.

Reimplemented in morph::client::Source.

Definition at line 171 of file frontend.hpp.


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