Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::reactive::Node Class Reference

Common base for every node participating in the reactive graph. More...

#include <node.hpp>

Inheritance diagram for aria::reactive::Node:
[legend]

Public Member Functions

 Node (NodeKind kind) noexcept
virtual ~Node () noexcept
 Node (const Node &)=delete
Nodeoperator= (const Node &)=delete
 Node (Node &&)=delete
Nodeoperator= (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< Noderetain_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

Static Public Member Functions

static Graphgraph () noexcept
 Returns the process-wide singleton Graph this node belongs to.

Protected Member Functions

void retire_ () noexcept
 Retire before derived members (including user captures) are destroyed.
void bump_version_ () noexcept
void set_state_ (NodeState s) noexcept

Friends

class Graph
class detail::NodeHandle

Detailed Description

Common base for every node participating in the reactive graph.

Concrete nodes implement recompute() (Derivation / Reaction) or drive notify_changed() externally after mutating their value (Source).

Constructor & Destructor Documentation

◆ Node() [1/3]

aria::reactive::Node::Node ( NodeKind kind)
inlineexplicitnoexcept

◆ ~Node()

aria::reactive::Node::~Node ( )
inlinevirtualnoexcept

◆ Node() [2/3]

aria::reactive::Node::Node ( const Node & )
delete

◆ Node() [3/3]

aria::reactive::Node::Node ( Node && )
delete

Member Function Documentation

◆ operator=() [1/2]

Node & aria::reactive::Node::operator= ( const Node & )
delete

◆ operator=() [2/2]

Node & aria::reactive::Node::operator= ( Node && )
delete

◆ kind()

NodeKind aria::reactive::Node::kind ( ) const
inlinenodiscardnoexcept

◆ state()

NodeState aria::reactive::Node::state ( ) const
inlinenodiscardnoexcept

◆ version()

std::uint64_t aria::reactive::Node::version ( ) const
inlinenodiscardnoexcept

◆ debug_name()

const std::string & aria::reactive::Node::debug_name ( ) const
inlinenodiscardnoexcept

◆ set_debug_name()

void aria::reactive::Node::set_debug_name ( std::string name)
inline

◆ effective_debug_name()

const std::string & aria::reactive::Node::effective_debug_name ( ) const
inlinenodiscard

A non-empty debug label for diagnostic output.

If the user explicitly set a debug_name(), that is returned verbatim. Otherwise a deterministic per-node fallback of the form "<Kind>#<id>" (e.g. "Derivation#42") is lazily cached and returned — so stderr dumps and GraphInspector labels are always meaningful even when the host type forgot to name its nodes.

The fallback id is a process-wide monotonic counter, not the node's address, so diagnostic output stays stable across runs and ASLR shuffles.

◆ graph()

Graph & aria::reactive::Node::graph ( )
inlinestaticnoexcept

Returns the process-wide singleton Graph this node belongs to.

◆ notify_changed()

void aria::reactive::Node::notify_changed ( )
inline

Called by a Source after its value has actually changed: bumps the version and colors all downstream nodes MaybeDirty.

If no batch is active, the Graph will immediately flush afterwards.

◆ mark_downstream_maybe_dirty()

void aria::reactive::Node::mark_downstream_maybe_dirty ( )
inline

Mark self and all reachable descendants as MaybeDirty.

Nodes already in a non-Clean state are skipped, bounding the walk to O(|affected|).

◆ mark_dirty()

void aria::reactive::Node::mark_dirty ( )
inlinenoexcept

Escalate state to Dirty (used by Graph::pull after confirming an upstream has truly moved).

◆ depth()

std::uint32_t aria::reactive::Node::depth ( ) const
inlinenodiscardnoexcept

Topological depth used by flush ordering.

Source nodes are depth 0; Derivations are (max upstream depth + 1). Updated on edge insertion.

◆ set_depth()

void aria::reactive::Node::set_depth ( std::uint32_t d)
inlinenoexcept

◆ recompute()

virtual bool aria::reactive::Node::recompute ( )
inlinevirtual

Recompute hook for Derivation / Reaction nodes.

Source nodes keep the default empty implementation (never invoked). Return true iff the cached value actually changed (version already bumped inside the override); this tells the Graph to propagate to downstream nodes.

Reimplemented in aria::Computed< T >, and aria::reactive::Computed< T >.

◆ retain_for_recompute()

virtual std::shared_ptr< Node > aria::reactive::Node::retain_for_recompute ( )
inlinenodiscardvirtualnoexcept

Reactions are shared-owned and may cancel themselves while running.

Value nodes keep caller-owned lifetimes and return an empty handle.

◆ attach_as_observer_of()

void aria::reactive::Node::attach_as_observer_of ( Node & source,
Edge & edge )
inlinenoexcept

◆ detach_edge()

void aria::reactive::Node::detach_edge ( Edge & edge)
inlinenoexcept

◆ clear_sources()

void aria::reactive::Node::clear_sources ( )
inlinenoexcept

Drop every upstream edge.

Typical use: a Derivation calls this just before recomputing so it can gather a fresh dependency set.

◆ for_each_observer()

template<class F>
void aria::reactive::Node::for_each_observer ( F && f)
inline

Iterate the observer list (used by Graph to color downstream nodes).

◆ for_each_source()

template<class F>
void aria::reactive::Node::for_each_source ( F && f) const
inline

Iterate the source list (used by a Derivation in pull() to compare each upstream's current version against observed_version).

◆ has_observers()

bool aria::reactive::Node::has_observers ( ) const
inlinenodiscardnoexcept

◆ has_sources()

bool aria::reactive::Node::has_sources ( ) const
inlinenodiscardnoexcept

◆ retire_()

void aria::reactive::Node::retire_ ( )
inlineprotectednoexcept

Retire before derived members (including user captures) are destroyed.

The base destructor repeats this safely for custom Node subclasses.

◆ bump_version_()

void aria::reactive::Node::bump_version_ ( )
inlineprotectednoexcept

◆ set_state_()

void aria::reactive::Node::set_state_ ( NodeState s)
inlineprotectednoexcept

◆ Graph

friend class Graph
friend

◆ detail::NodeHandle

friend class detail::NodeHandle
friend

The documentation for this class was generated from the following files:
  • modules/core/include/aria/reactive/node.hpp
  • modules/core/include/aria/reactive/graph.inl