18#ifndef LIVE_CELLS_MUTABLE_CELL_HPP
19#define LIVE_CELLS_MUTABLE_CELL_HPP
23#include "cell_state.hpp"
24#include "stateful_cell.hpp"
59 static bool is_batch_update();
68 static void add_to_batch(std::shared_ptr<cell_state> state);
109 if (value_ !=
value) {
111 value_ = std::move(
value);
113 if (!batch_update::is_batch_update()) {
129 value_ = std::move(
value);
138 return batch_update::is_batch_update();
241 return this->
state->value();
253 this->
state->value(value);
322 template <
typename T>
337 template <
typename T>
352 template <
typename T>
367 template <
typename T>
383 template <
typename T>
398 template <
typename T>
413 template <
typename T>
429 template <
typename T>
445 template <
typename T>
461 template <
typename T>
494 auto old =
c.value();
528 auto old =
c.value();
static argument_tracker & global()
Definition tracker.hpp:99
Defer changes to the values of mutable cells.
Definition mutable_cell.hpp:44
Maintains the state of a stateful cell.
Definition cell_state.hpp:43
virtual void notify_will_update()
Notify the observers that the cell's value will change.
Definition live_cells.cpp:76
virtual void notify_update(bool did_change=true)
Notify the observers that the cell's value has changed.
Definition live_cells.cpp:92
cell_state(key_ref k)
Create a cell state with a given key.
Definition cell_state.hpp:53
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_cell.
Definition mutable_cell.hpp:78
void add_to_batch()
Add this state to the list of mutable cells that were updating during the current batch update.
Definition mutable_cell.hpp:145
T value()
Get the value of the cell.
Definition mutable_cell.hpp:99
void value(T value)
Set the value of the cell and notify its observers.
Definition mutable_cell.hpp:108
mutable_cell_state(key_ref key, T value)
Create a mutable cell state with the value initialized to value.
Definition mutable_cell.hpp:89
void silent_set(T value)
Set the cell's value without notifying observers.
Definition mutable_cell.hpp:128
static bool is_batch_update()
Is a batch update of mutable cells currently in effect?
Definition mutable_cell.hpp:137
A stateful cell which can have its value set directly.
Definition mutable_cell.hpp:158
void value(T value) const
Set the value of the cell.
Definition mutable_cell.hpp:252
T value() const
Get the value of the cell.
Definition mutable_cell.hpp:240
mutable_cell(key_ref key, T value)
Create a mutable cell with an initial value.
Definition mutable_cell.hpp:197
T operator=(const T &value)
Set the value of the cell.
Definition mutable_cell.hpp:211
mutable_cell()
Create a mutable cell with a default initialized value.
Definition mutable_cell.hpp:174
T value_type
The type of value held by this cell.
Definition mutable_cell.hpp:168
T operator()() const
Get the value of the cell and track it as a dependency.
Definition mutable_cell.hpp:262
mutable_cell(T value)
Create a mutable cell with an initial value.
Definition mutable_cell.hpp:181
T operator=(const T &value) const
Set the value of the cell.
Definition mutable_cell.hpp:230
Base class for a cell with a state.
Definition stateful_cell.hpp:42
std::shared_ptr< mutable_cell_state< T > > 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
Concept defining a Cell that can have its value set.
Definition types.hpp:155
Definition boolean.hpp:26
constant_cell< T > value(const T &value)
Definition constant_cell.hpp:132
T operator&=(const MutableCell auto &c, const T &value)
Compute the bitwise and of the value of Cell c and value, and assign it to c.
Definition mutable_cell.hpp:430
T operator>>=(const MutableCell auto &c, const T &value)
Right shift the value of Cell c by value.
Definition mutable_cell.hpp:414
T operator<<=(const MutableCell auto &c, const T &value)
Left shift the value of Cell c by value.
Definition mutable_cell.hpp:399
T operator|=(const MutableCell auto &c, const T &value)
Compute the bitwise or of the value of Cell c and value, and assign it to c.
Definition mutable_cell.hpp:462
T operator+=(const MutableCell auto &c, const T &value)
Add value to the value of Cell c.
Definition mutable_cell.hpp:323
T operator%=(const MutableCell auto &c, const T &value)
Compute the remainder of the value of Cell c divided by value, and assign it to c.
Definition mutable_cell.hpp:384
void batch(F fn)
Batch changes to the values of mutable cells.
Definition mutable_cell.hpp:307
T operator/=(const MutableCell auto &c, const T &value)
Divide the value of Cell c by value.
Definition mutable_cell.hpp:368
mutable_cell< T > variable(T value)
Create a new mutable cell with an initial value.
Definition mutable_cell.hpp:276
T operator-=(const MutableCell auto &c, const T &value)
Subtract value from the value of Cell c.
Definition mutable_cell.hpp:338
T operator^=(const MutableCell auto &c, const T &value)
Compute the bitwise exclusive or of the value of Cell c and value, and assign it to c.
Definition mutable_cell.hpp:446
auto operator++(const MutableCell auto &c)
Increment the value of Cell c.
Definition mutable_cell.hpp:476
T operator*=(const MutableCell auto &c, const T &value)
Multiply the value of Cell c by value.
Definition mutable_cell.hpp:353
auto operator--(const MutableCell auto &c)
Decrement the value of Cell c.
Definition mutable_cell.hpp:510