18#ifndef LIVE_CELLS_DYNAMIC_MUTABLE_COMPUTE_CELL_HPP
19#define LIVE_CELLS_DYNAMIC_MUTABLE_COMPUTE_CELL_HPP
27#include "mutable_compute_cell_state.hpp"
28#include "changes_only_state.hpp"
36 template<std::invocable F,
typename R,
typename ValueType = std::invoke_result_t<F>>
53 template <
typename T,
typename U>
56 compute_fn(std::forward<T>(
compute)),
57 reverse_fn(std::forward<U>(
reverse)) {}
63 this->arguments.emplace(cell);
65 cell.add_observer(this->observer_ptr());
90 template <std::invocable F,
typename R>
104 template <std::invocable F,
typename R,
typename State = dynamic_mutable_compute_cell_state<F,R>>
132 template <
typename T,
typename U>
149 template <
typename T,
typename U>
154 return this->
state->value();
166 void value(value_type value)
const {
167 this->
state->value(value);
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
Maintains the state of a dynamic_mutable_compute_cell.
Definition dynamic_mutable_compute_cell.hpp:37
dynamic_mutable_compute_cell_state(key_ref key, T &&compute, U &&reverse)
Create the state for a dynamic mutable computed cell.
Definition dynamic_mutable_compute_cell.hpp:54
mutable_compute_cell_state< ValueType > parent
Shorthand for parent class.
Definition dynamic_mutable_compute_cell.hpp:42
ValueType compute() override
Compute the value of the cell as a function of its argument cells.
Definition dynamic_mutable_compute_cell.hpp:60
A mutable computed cell with the argument cells determined dynamically.
Definition dynamic_mutable_compute_cell.hpp:105
value_type operator=(const value_type &value) const
Set the value of the cell.
Definition dynamic_mutable_compute_cell.hpp:204
dynamic_mutable_compute_cell(T &&compute, U &&reverse)
Create a dynamic mutable computed cell.
Definition dynamic_mutable_compute_cell.hpp:150
std::invoke_result_t< F > value_type
Shorthand for the type of value held by this cell.
Definition dynamic_mutable_compute_cell.hpp:115
value_type operator=(const value_type &value)
Set the value of the cell to value.
Definition dynamic_mutable_compute_cell.hpp:182
dynamic_mutable_compute_cell(key_ref k, T &&compute, U &&reverse)
Create a dynamic mutable computed cell.
Definition dynamic_mutable_compute_cell.hpp:133
void value(value_type value) const
Set the value of the cell.
Definition dynamic_mutable_compute_cell.hpp:166
A dynamic_mutable_compute_cell_state that only notifies the observers of the cell if its value has ac...
Definition dynamic_mutable_compute_cell.hpp:92
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
T 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
A key of uniquely identified by a single instance.
Definition keys.hpp:128
Definition boolean.hpp:26
constant_cell< T > value(const T &value)
Definition constant_cell.hpp:132