|
Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
|
#include <property.hpp>
Public Types | |
| using | value_type = T |
Public Member Functions | |
| Property (T initial=T{}) | |
| ~Property () noexcept override | |
| Property (const Property &)=delete | |
| Property & | operator= (const Property &)=delete |
| Property (Property &&)=delete | |
| Property & | operator= (Property &&)=delete |
| T | get () const |
| Auto-tracked read. | |
| const T & | get_ref () const |
| Auto-tracked read by const reference. | |
| T | peek () const noexcept(std::is_nothrow_copy_constructible_v< T >) |
| Snapshot read that does NOT register a dependency. | |
| const T & | peek_ref () const noexcept |
| Snapshot read by const reference (never tracks, never copies). | |
| operator T () const | |
| Convenience: implicit conversion behaves like .get() so expressions read naturally (int total = price + tax;). | |
| void | set (const T &new_val) |
| Commit a new value. | |
| void | set (T &&new_val) |
| Property & | operator= (const T &v) |
| Property & | operator= (T &&v) |
| template<std::invocable< T & > Fn> | |
| void | mutate (Fn &&fn) |
| Mutate-in-place: always fires a change (cannot detect no-op because the mutation is opaque). | |
| ::aria::Subscription | on_changed (std::function< void(const T &)> fn) |
| Run fn(new_value) every time the value changes. | |
| ::aria::Subscription | bind (std::function< void(const T &)> fn) |
| Fire once with the current value, then on every subsequent change. | |
| ::aria::Subscription | observe (std::function< void(const T &, const T &)> fn) |
| Two-argument form: receive (old, new). | |
| std::any | get_any () const override |
| Read the current value as a std::any. | |
| bool | set_any (const std::any &value) override |
| Try to set the property's value from a std::any. | |
| ::aria::Subscription | subscribe_any (std::function< void(const std::any &)> on_changed_any) override |
| Subscribe to value changes. | |
| const std::type_info & | type () const noexcept override |
| The runtime type of the wrapped value. | |
| Public Member Functions inherited from aria::reactive::Node | |
| Node (NodeKind kind) noexcept | |
| virtual | ~Node () noexcept |
| Node (const Node &)=delete | |
| Node & | operator= (const Node &)=delete |
| Node (Node &&)=delete | |
| Node & | operator= (Node &&)=delete |
| NodeKind | kind () const noexcept |
| NodeState | state () const noexcept |
| std::uint64_t | version () const noexcept |
| const std::string & | debug_name () const noexcept |
| void | set_debug_name (std::string name) |
| const std::string & | effective_debug_name () const |
| A non-empty debug label for diagnostic output. | |
| void | notify_changed () |
| Called by a Source after its value has actually changed: bumps the version and colors all downstream nodes MaybeDirty. | |
| void | mark_downstream_maybe_dirty () |
| Mark self and all reachable descendants as MaybeDirty. | |
| void | mark_dirty () noexcept |
| Escalate state to Dirty (used by Graph::pull after confirming an upstream has truly moved). | |
| std::uint32_t | depth () const noexcept |
| Topological depth used by flush ordering. | |
| void | set_depth (std::uint32_t d) noexcept |
| virtual bool | recompute () |
| Recompute hook for Derivation / Reaction nodes. | |
| virtual std::shared_ptr< Node > | retain_for_recompute () noexcept |
| Reactions are shared-owned and may cancel themselves while running. | |
| void | attach_as_observer_of (Node &source, Edge &edge) noexcept |
| void | detach_edge (Edge &edge) noexcept |
| void | clear_sources () noexcept |
| Drop every upstream edge. | |
| template<class F> | |
| void | for_each_observer (F &&f) |
| Iterate the observer list (used by Graph to color downstream nodes). | |
| template<class F> | |
| void | for_each_source (F &&f) const |
| Iterate the source list (used by a Derivation in pull() to compare each upstream's current version against observed_version). | |
| bool | has_observers () const noexcept |
| bool | has_sources () const noexcept |
| Public Member Functions inherited from aria::IProperty | |
| virtual | ~IProperty () noexcept=default |
Additional Inherited Members | |
| Static Public Member Functions inherited from aria::reactive::Node | |
| static Graph & | graph () noexcept |
| Returns the process-wide singleton Graph this node belongs to. | |
| Protected Member Functions inherited from aria::reactive::Node | |
| void | retire_ () noexcept |
| Retire before derived members (including user captures) are destroyed. | |
| void | bump_version_ () noexcept |
| void | set_state_ (NodeState s) noexcept |
| Protected Member Functions inherited from aria::IProperty | |
| IProperty () noexcept=default | |
| IProperty (const IProperty &)=delete | |
| IProperty & | operator= (const IProperty &)=delete |
| IProperty (IProperty &&)=delete | |
| IProperty & | operator= (IProperty &&)=delete |
| using aria::reactive::Property< T >::value_type = T |
|
inlineexplicit |
|
inlineoverridenoexcept |
|
delete |
|
delete |
|
delete |
|
delete |
|
inlinenodiscard |
Auto-tracked read.
If a TrackingContext is active (inside a Derivation's compute or a Reaction's body), this read becomes an upstream edge of that context.
|
inlinenodiscard |
|
inlinenodiscardnoexcept |
Snapshot read that does NOT register a dependency.
Equivalent to untracked([&]{ return p.get(); }) but cheaper.
noexcept is conditional on T's copy ctor — for trivially copyable types this is a free promise; for T that may throw on copy (e.g. std::string under low-memory conditions) we degrade gracefully rather than terminate.
|
inlinenodiscardnoexcept |
Snapshot read by const reference (never tracks, never copies).
|
inline |
Convenience: implicit conversion behaves like .get() so expressions read naturally (int total = price + tax;).
|
inline |
Commit a new value.
No-op if equal to the current one. Emits a graph-wide invalidation pulse otherwise.
|
inline |
|
inline |
|
inline |
|
inline |
Mutate-in-place: always fires a change (cannot detect no-op because the mutation is opaque).
Useful for container-valued Properties where a full equality check would be expensive.
|
inlinenodiscard |
Run fn(new_value) every time the value changes.
Returns a Subscription RAII handle; drop it to stop receiving callbacks. The argument borrows this property's value; copy it before mutating or destroying the property if it is needed afterwards.
|
inlinenodiscard |
Fire once with the current value, then on every subsequent change.
This is the idiomatic "bind a UI widget to this property" path.
|
inlinenodiscard |
Two-argument form: receive (old, new).
Implemented on top of on_changed by stashing the last-seen value in a shared cell.
|
inlinenodiscardoverridevirtual |
Read the current value as a std::any.
The runtime type is guaranteed to equal type().
Implements aria::IProperty.
|
inlinenodiscardoverridevirtual |
Try to set the property's value from a std::any.
Returns true on success, false when the runtime types don't match (in which case the property is left unchanged).
Implements aria::IProperty.
|
inlinenodiscardoverridevirtual |
Subscribe to value changes.
The callback receives the new value as std::any of the same runtime type as type().
Implements aria::IProperty.
|
inlinenodiscardoverridevirtualnoexcept |
The runtime type of the wrapped value.
Useful for callers that want to gate their std::any_cast on a name comparison before paying the cost of the cast.
Implements aria::IProperty.