morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::model::WrappedModelKey Concept Reference

Key types that wrap a RawModelKey — the ladder's strong ids. More...

#include <model_key.hpp>

Concept definition

template<typename K>
concept WrappedModelKey = !RawModelKey<K> && requires(const K& key) {
{ key.hasValue() } -> std::convertible_to<bool>;
{ *key };
requires RawModelKey<std::remove_cvref_t<decltype(*key)>>;
requires requires(std::remove_cvref_t<decltype(*key)> raw) { K{std::move(raw)}; };
}
Key types that are themselves a wire-encodable scalar.
Definition model_key.hpp:41
Key types that wrap a RawModelKey — the ladder's strong ids.
Definition model_key.hpp:62

Detailed Description

Key types that wrap a RawModelKey — the ladder's strong ids.

examples/IMPLEMENTATION.md rule 3 requires entity identity to be a per-entity strong id type (struct PasteId, struct OptionId) exposing hasValue(), so that it joins the forms palette as an empty-capable field. Such a type is not integral and is not std::string, so before this it satisfied no arm of ModelKey at all — and a rung obeying rule 3 could not use BRIDGE_MODEL_KEY/BRIDGE_KEY_FROM, the very macros the framework provides for keying. Three rungs hand-wrote the traits instead, each re-stating the *id unwrapping convention the macro exists to hide.

The shape is deduced structurally rather than declared, matching how a keyed model is detected: any type with hasValue() and an operator* yielding a RawModelKey, and constructible back from that raw value so the key round-trips from the wire. Both ladder spellings qualify — an std::optional-backed id whose operator* returns a reference, and a sentinel-backed one (0 means empty) whose operator* returns by value.

Definition at line 62 of file model_key.hpp.