morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
dev_reload.hpp File Reference

Development reload (spec 5 §12): which documents a changed bundle changed, and remounting the mounted screens that show them, keeping their state. More...

#include <algorithm>
#include <functional>
#include <map>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "bundle.hpp"
#include "document.hpp"
#include "frontend.hpp"
#include "host.hpp"
#include "value.hpp"

Go to the source code of this file.

Classes

struct  morph::ui::MountedScreen
 A mounted screen a reload may remount. More...
struct  morph::ui::ReloadOutcome
 What reloadDocuments did. More...

Typedefs

using morph::ui::DocumentMap = std::map<std::string, std::shared_ptr<Document const>, std::less<>>
 The loaded documents a host mounts from, by screen id.

Functions

std::vector< std::string > morph::ui::changedDocuments (Manifest const &before, Manifest const &after)
 The ids of the documents (screens and the app document) whose files differ between two manifests: changed, added or removed. Themes, message catalogues and components are not documents; a document that names a changed component names it by its new hash, so it changes too.
ReloadOutcome morph::ui::reloadDocuments (std::span< std::string const > changed, Bundle const &bundle, LoadOptions const &options, DocumentMap &documents, DocumentScreenHost &host, std::span< MountedScreen const > mounted)
 Loads the changed documents of a new bundle and remounts the mounted screens that show them.

Detailed Description

Development reload (spec 5 §12): which documents a changed bundle changed, and remounting the mounted screens that show them, keeping their state.

A development client polls with UiClient::poll and hands each changed bundle to reloadDocuments. Specified in docs/spec/ui/service.md.

Definition in file dev_reload.hpp.

Typedef Documentation

◆ DocumentMap

using morph::ui::DocumentMap = std::map<std::string, std::shared_ptr<Document const>, std::less<>>

The loaded documents a host mounts from, by screen id.

Definition at line 30 of file dev_reload.hpp.

Function Documentation

◆ changedDocuments()

std::vector< std::string > morph::ui::changedDocuments ( Manifest const & before,
Manifest const & after )
inlinenodiscard

The ids of the documents (screens and the app document) whose files differ between two manifests: changed, added or removed. Themes, message catalogues and components are not documents; a document that names a changed component names it by its new hash, so it changes too.

Parameters
beforeThe manifest the client had.
afterThe manifest it has now.
Returns
The ids, sorted and each once.

Definition at line 38 of file dev_reload.hpp.

◆ reloadDocuments()

ReloadOutcome morph::ui::reloadDocuments ( std::span< std::string const > changed,
Bundle const & bundle,
LoadOptions const & options,
DocumentMap & documents,
DocumentScreenHost & host,
std::span< MountedScreen const > mounted )
inlinenodiscard

Loads the changed documents of a new bundle and remounts the mounted screens that show them.

Each changed screen document is loaded with options. A document that does not load is refused and keeps the old document, in documents and on every screen showing it. A document that loads is mounted, through DocumentScreenHost::remount, on every screen of mounted showing it, which keeps each state of the screen's own scope declared under the same name and type. A remount the interpreter refuses keeps that screen on the old document, and keeps the old document in documents. A changed id the bundle no longer holds, and the app document, which no DocumentScreenHost mounts, change nothing here.

Parameters
changedThe ids of the changed documents (changedDocuments).
bundleThe new bundle's documents.
optionsHow the documents load: the catalog facts.
documentsThe host's documents, updated in place.
hostThe host that mounted every screen of mounted.
mountedThe mounted screens.
Returns
The screens remounted, and the refusals.

Definition at line 99 of file dev_reload.hpp.