|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Drives N independently editable action drafts on one screen. More...
#include <sections.hpp>
Public Member Functions | |
| SectionSet (::morph::bridge::BridgeHandler< Model > &handler, std::function< void(std::exception_ptr)> onError=nullptr) | |
Constructs a section set dispatching through handler. | |
| SectionSet (const SectionSet &)=delete | |
| SectionSet & | operator= (const SectionSet &)=delete |
| SectionSet (SectionSet &&)=delete | |
| SectionSet & | operator= (SectionSet &&)=delete |
| ~SectionSet () | |
| Stops every callback this set installed from being delivered. | |
| template<auto FieldPtr> | |
| void | set (::morph::bridge::detail::MemberPointerTraits< decltype(FieldPtr)>::ValueType value) |
| Sets one field of its section's draft, dispatching that section if the draft is now ready. | |
| template<typename A> | |
| void | reset () |
| Clears one section's draft back to a default-constructed action. | |
| template<typename A> | |
| A | draft () const |
| Snapshots one section's current draft. | |
| std::optional< std::string > | resolved (std::string_view path) const |
| Looks up a value captured from a section's submitted draft or result. | |
Drives N independently editable action drafts on one screen.
Each section accumulates its own draft through set<> and dispatches through the handler as soon as ActionValidator<A>::ready accepts it. There is no active section and no sequence: a field belonging to any declared section may be set at any time, in any order. This is the whole difference from morph::flows::FlowSession, which throws on a field outside its current step.
A ready section re-fires on every subsequent set<>. There is no latch and no coalescing, matching FlowSession; a caller that wants one request per pause debounces on its own side, where it knows what a pause means.
| Model | The model the handler is bound to. |
| Sections | One or more Section<Action, Title, Binds...> types. |
Definition at line 133 of file sections.hpp.
|
inlineexplicit |
Constructs a section set dispatching through handler.
| handler | Handler every section dispatches through. Must outlive this SectionSet, which belongs to the handler's owner: it is built, used and destroyed there, and the handler's guiExec delivers its continuations there. |
| onError | Optional callback invoked when a section's dispatch fails. When absent, the error is logged via morph::log::logError. Stored and invoked for this object's whole lifetime, so anything the callable refers to must outlive it. |
Definition at line 149 of file sections.hpp.
|
inline |
Stops every callback this set installed from being delivered.
There is nothing to detach: a section's continuations are owned by the in-flight dispatch, not held in a map this object could remove itself from. _callbacks gates each one on a token it checks before touching this, so a completion resolving after this object is gone finds the token stopped and returns without dereferencing anything.
requestStop() is called explicitly rather than left to the member's own destruction, even though _callbacks is declared last: members are destroyed only after the destructor body runs, so a body that later grew a call pumping an event loop would otherwise deliver into a half-dead object. The body does not do that today; stopping first keeps it correct if one is ever added.
Destroyed on the handler's owner, where its continuations run, so the check a continuation makes and this destructor cannot interleave.
Definition at line 175 of file sections.hpp.
|
inline |
Sets one field of its section's draft, dispatching that section if the draft is now ready.
Unlike FlowSession::set<> this imposes no ordering: the field's action need only be one of the declared sections. On the handler's owner.
| FieldPtr | Pointer-to-data-member of a declared section's action struct. |
| value | New value for the field. |
Definition at line 188 of file sections.hpp.
|
inline |
Clears one section's draft back to a default-constructed action.
Touches no other section and dispatches nothing. Values already captured from a previous successful dispatch stay in resolved(): they describe what the model was told, which resetting an editor does not undo.
| A | The section's action type. |
Definition at line 206 of file sections.hpp.
|
inlinenodiscard |
Snapshots one section's current draft.
A copy, not a reference into live state. On the handler's owner.
| A | The section's action type. |
Definition at line 219 of file sections.hpp.
|
inlinenodiscard |
Looks up a value captured from a section's submitted draft or result.
| path | "<ActionTypeId>.<field>", matching a section's declared Bind::path(). |
path was never captured — the section never fired successfully, or has no such field. Definition at line 231 of file sections.hpp.