|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
A handler for a model known only by its registered type id. More...
#include <bridge.hpp>
Public Member Functions | |
| RawHandler (Bridge &bridge, ::morph::exec::IExecutor *cbExec, std::string typeId, BindSharing sharing=BindSharing::Private, std::string instanceKey={}) | |
Binds the model registered as typeId. | |
| ~RawHandler () | |
| Deregisters the binding, on the owner. | |
| RawHandler (const RawHandler &)=delete | |
| RawHandler & | operator= (const RawHandler &)=delete |
| RawHandler (RawHandler &&)=delete | |
| RawHandler & | operator= (RawHandler &&)=delete |
| ::morph::async::Completion< std::string > | execute (std::string actionId, std::string bodyJson) |
Dispatches the action registered as actionId with bodyJson. | |
| ::morph::async::Completion< std::string > | execute (std::string actionId, std::string bodyJson, ::core::async::StopToken stop) |
execute, cancellable through stop. | |
| ::morph::async::Completion< std::string > | executeOn (std::string instanceKey, std::string actionId, std::string bodyJson) |
execute on the instance for instanceKey, attaching this shared handler to it first; see Bridge::executeRawOn. | |
| void | attach (std::string instanceKey) |
Attaches (or re-points) this shared handler to the instance for instanceKey, as BridgeHandler::attach does for a typed one. | |
| std::string | primary () const |
| This handler's current instance key. | |
| bool | isBound () const noexcept |
| Whether the handler holds a live instance now. | |
| const std::string & | typeId () const noexcept |
| The model's registered type id. | |
A handler for a model known only by its registered type id.
What a client compiled without the model's C++ type holds: binds through Bridge::bindByType on construction, dispatches through Bridge::executeRaw, and deregisters on destruction — on the owner, with every guarantee a BridgeHandler has. Non-copyable and non-movable.
Definition at line 2950 of file bridge.hpp.
|
inline |
Binds the model registered as typeId.
| bridge | The bridge to bind on. Borrowed: it must outlive every call made on this handler. |
| cbExec | Executor the Completion callbacks are posted on. Borrowed: it must outlive this handler. |
| typeId | The model's registered type id. |
| sharing | Private or shared. |
| instanceKey | For a shared handler, the key to attach to now, or empty. |
| std::invalid_argument | for a private handler with a key. |
| std::logic_error | for a key given off the owner, inside a running action: attaching is the owner's. |
Definition at line 2963 of file bridge.hpp.
|
inline |
Deregisters the binding, on the owner.
Every call still held for a bind in flight is rejected with HandlerDestroyedError. Destroyed after its bridge — still on the owner — it finds the bridge's token expired and deregisters nothing.
Definition at line 2976 of file bridge.hpp.
|
inlinenodiscard |
Dispatches the action registered as actionId with bodyJson.
| actionId | The action's registered type id. |
| bodyJson | The action's JSON body. |
Definition at line 2992 of file bridge.hpp.
|
inlinenodiscard |
execute, cancellable through stop.
| actionId | The action's registered type id. |
| bodyJson | The action's JSON body. |
| stop | The caller's cancel. |
Definition at line 3002 of file bridge.hpp.
|
inlinenodiscard |
execute on the instance for instanceKey, attaching this shared handler to it first; see Bridge::executeRawOn.
The way to send a keyed action: a refused attach rejects the call rather than running it on the instance the handler held before.
| instanceKey | Canonical string encoding of the primary key. |
| actionId | The action's registered type id. |
| bodyJson | The action's JSON body. |
| std::invalid_argument | for an empty instanceKey. |
| std::logic_error | on a private handler. |
Definition at line 3018 of file bridge.hpp.
|
inline |
Attaches (or re-points) this shared handler to the instance for instanceKey, as BridgeHandler::attach does for a typed one.
Issued, not awaited, and a refusal is logged rather than reported: a call that must run on instanceKey goes through executeOn.
| instanceKey | Canonical string encoding of the primary key. |
| std::invalid_argument | for an empty instanceKey. |
| std::logic_error | on a private handler. |
Definition at line 3032 of file bridge.hpp.
|
inlinenodiscard |
This handler's current instance key.
Definition at line 3036 of file bridge.hpp.
|
inlinenodiscardnoexcept |
Whether the handler holds a live instance now.
Definition at line 3040 of file bridge.hpp.
|
inlinenodiscardnoexcept |
The model's registered type id.
Definition at line 3044 of file bridge.hpp.