18#ifndef LIVE_CELLS_STATIC_MUTABLE_COMPUTE_CELL_HPP
19#define LIVE_CELLS_STATIC_MUTABLE_COMPUTE_CELL_HPP
27#include "mutable_compute_cell_state.hpp"
28#include "changes_only_state.hpp"
36 template <std::invocable F,
typename R>
39 typedef std::invoke_result_t<F> value_type;
54 template <
typename T,
typename U>
95 template <std::invocable F,
typename R>
109 template <std::invocable F,
typename R,
typename State = static_mutable_compute_cell_state<F,R>>
138 template <
typename T,
typename U,
typename...
Args>
157 template <
typename T,
typename U,
typename... Args>
167 return this->
state->value();
182 this->
state->value(value);
247 template <std::invocable C,
typename R, Cell... As>
269 template <std::invocable C,
typename R, Cell... As>
static argument_tracker & global()
Definition tracker.hpp:99
Dynamically typed Cell container.
Definition observable.hpp:133
Mixin that modifies a compute_cell_state subclass to only notify its observers if the new value of th...
Definition changes_only_state.hpp:24
A computed cell which determines its argument cells at runtime.
Definition dynamic_compute_cell.hpp:153
Dynamically type key container.
Definition keys.hpp:76
Defines the interface for a key which uniquely identifies a cell.
Definition keys.hpp:33
Maintains the state of a mutable computed cell.
Definition mutable_compute_cell_state.hpp:39
std::unordered_set< cell > arguments
Set of argument cells referenced by the value computation function.
Definition mutable_compute_cell_state.hpp:166
bool reverse
Is the value of the cell being set, and hence a reverse computation being performed?
Definition mutable_compute_cell_state.hpp:172
std::invoke_result_t< F > value()
Get the value of the cell.
Definition mutable_compute_cell_state.hpp:63
Base class for a cell with a state.
Definition stateful_cell.hpp:42
std::shared_ptr< S > state
Reference to the cell's state.
Definition stateful_cell.hpp:105
Maintains the state for a static_mutable_compute_cell.
Definition static_mutable_compute_cell.hpp:37
void reverse_compute(value_type value) override
Call the reverse computation function of the cell.
Definition static_mutable_compute_cell.hpp:76
mutable_compute_cell_state< value_type > parent
Definition static_mutable_compute_cell.hpp:42
static_mutable_compute_cell_state(key_ref key, T &&compute, U &&reverse, const std::unordered_set< cell > &arguments)
Create the state for a static_mutable_compute cell.
Definition static_mutable_compute_cell.hpp:55
value_type compute() override
Compute the value of the cell as a function of the arguments.
Definition static_mutable_compute_cell.hpp:67
A mutable computed cell with arguments determined at compile-time.
Definition static_mutable_compute_cell.hpp:110
value_type operator=(const value_type &value)
Set the value of the cell to value.
Definition static_mutable_compute_cell.hpp:197
std::invoke_result_t< F > value_type
The type of value held by this cell.
Definition static_mutable_compute_cell.hpp:119
static_mutable_compute_cell(key_ref k, T &&compute, U &&reverse, Args &&... args)
Create a static mutable computed cell.
Definition static_mutable_compute_cell.hpp:139
value_type value() const
Get the value of the cell.
Definition static_mutable_compute_cell.hpp:166
void value(value_type value) const
Set the value of the cell.
Definition static_mutable_compute_cell.hpp:181
value_type operator()() const
Get the value of the cell and track it as a dependency.
Definition static_mutable_compute_cell.hpp:230
value_type operator=(const value_type &value) const
Set the value of the cell.
Definition static_mutable_compute_cell.hpp:219
static_mutable_compute_cell(T &&compute, U &&reverse, Args &&... args)
Create a static mutable computed cell.
Definition static_mutable_compute_cell.hpp:158
A static_mutable_compute_cell_state that only notifies the observers of the cell when the cell's valu...
Definition static_mutable_compute_cell.hpp:97
A key of uniquely identified by a single instance.
Definition keys.hpp:128
Definition boolean.hpp:26
auto make_mutable_compute_cell(C compute, R reverse, As... args)
Create a static_mutable_compute_cell with compute function compute, reverse compute function reverse ...
Definition static_mutable_compute_cell.hpp:248
Cell option specifying that the cell, to which it is applied, should only notify its observers when i...
Definition changes_only_state.hpp:94