|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
#include <algorithm>#include <glaze/glaze.hpp>#include <optional>#include <string>#include <string_view>#include <typeindex>#include <utility>#include <vector>#include "change_types.hpp"#include "effects.hpp"Go to the source code of this file.
Typedefs | |
| using | morph::effects::detail::ResultJson = glz::generic_u64 |
| The JSON tree a result is parsed into. It keeps integers exact, so a 64-bit key is copied as written. | |
Functions | |
| void | morph::effects::detail::collectKey (ResultJson const &value, std::string_view keyField, std::vector< glz::raw_json > &out) |
Appends the key of one record value to out. | |
| void | morph::effects::detail::collectKeysAtLeaf (ResultJson const &value, std::string_view keyField, std::vector< glz::raw_json > &out) |
| Appends the keys of the records held at a value that the path has reached. | |
| void | morph::effects::detail::collectKeysAtPath (ResultJson const &value, std::string_view path, std::string_view keyField, std::vector< glz::raw_json > &out) |
Walks the remaining path segments from value, then collects the keys found there. | |
| void | morph::effects::detail::addRecordChange (Changes &changes, std::string const &record, std::optional< std::vector< glz::raw_json > > keys) |
| Adds a change for a record, merging with one already there. | |
| void | morph::effects::detail::addDerivedChanges (Resolved const &resolved, std::string const &source, Changes &changes) |
Adds a whole-type change for every record derived, directly or through others, from source. | |
| void | morph::effects::detail::addInstanceChange (Changes &changes, InstanceChange const &ranOn) |
| Adds the change an execute's instance makes, unless it is already there. | |
| void | morph::effects::detail::addUpdatesChange (Resolved const &resolved, std::string_view actionId, std::string const &record, ResultJson const *parsed, Changes &changes) |
| Adds the change an updates<R> effect makes: the keys of the R rows found in the result. | |
| Changes | morph::effects::detail::deriveChangesFrom (Resolved const &resolved, std::string_view actionId, std::string_view resultJson, InstanceChange const &ranOn) |
| See morph::effects::deriveChanges, over given registries. | |
| Changes | morph::effects::deriveChanges (std::string_view actionId, std::string_view resultJson, InstanceChange const &ranOn) |
| The changes a successful execute made, from the action's declared effects and its result. | |
Deriving an execute's changes from the action's declared effects and its result.
Definition in file changes.hpp.
| using morph::effects::detail::ResultJson = glz::generic_u64 |
The JSON tree a result is parsed into. It keeps integers exact, so a 64-bit key is copied as written.
Definition at line 24 of file changes.hpp.
|
inline |
Appends the key of one record value to out.
| value | A JSON value expected to be one record. |
| keyField | The record's key member. |
| out | Where to append the key's raw JSON. |
Definition at line 30 of file changes.hpp.
|
inline |
Appends the keys of the records held at a value that the path has reached.
An object is one record when it has the key member, and otherwise a map whose values are records.
| value | The value at the end of a path. |
| keyField | The record's key member. |
| out | Where to append. |
Definition at line 51 of file changes.hpp.
|
inline |
Walks the remaining path segments from value, then collects the keys found there.
A vector or optional adds no segment, so an array is entered without consuming one. A map adds none either, so an object that lacks the next segment is searched through its values.
| value | The current value. |
| path | The dot-joined member names; "" is the value itself. |
| keyField | The record's key member. |
| out | Where to append. |
Definition at line 77 of file changes.hpp.
|
inline |
Adds a change for a record, merging with one already there.
A whole-type change absorbs keys, and keys are not repeated.
| changes | The changes so far. |
| record | The record's wire name. |
| keys | The changed keys, or nullopt for the whole type. |
Definition at line 111 of file changes.hpp.
|
inline |
Adds a whole-type change for every record derived, directly or through others, from source.
| resolved | The resolved registries. |
| source | A changed record's wire name. |
| changes | Where to add. |
Definition at line 137 of file changes.hpp.
|
inline |
Adds the change an execute's instance makes, unless it is already there.
| changes | Where to add. |
| ranOn | The instance the action ran on. |
Definition at line 161 of file changes.hpp.
|
inline |
Adds the change an updates<R> effect makes: the keys of the R rows found in the result.
A result that does not parse, or a record without a key, cannot name rows: the whole type is reported, which over-notifies but never misses.
| resolved | The resolved registries. |
| actionId | The action's id. |
| record | The updated record's wire name. |
| parsed | The parsed result, or nullptr when it did not parse. |
| changes | Where to add. |
Definition at line 179 of file changes.hpp.
|
inlinenodiscard |
See morph::effects::deriveChanges, over given registries.
| resolved | The resolved registries. |
| actionId | The action's id. |
| resultJson | The action's result as JSON. |
| ranOn | The instance the action ran on. |
Definition at line 205 of file changes.hpp.
|
inlinenodiscard |
The changes a successful execute made, from the action's declared effects and its result.
updates<R> gives the keys of the R rows found in the result, changes<R> the whole type, and both also every record derived from R, directly or through others, as a whole-type change. changesInstance gives ranOn. An action that declared nothing, or only none, gives no changes.
| actionId | The action's id. |
| resultJson | The action's result as JSON. |
| ranOn | The instance the action ran on. |
| morph::model::EffectsRegistrationError | when the registered configuration is invalid. |
Definition at line 265 of file changes.hpp.