Live Cells C++
Reactive Programming for C++
|
Maintains the state of a store_cell
.
More...
#include <store_cell.hpp>
Public Member Functions | |
store_cell_state (key_ref k, C arg) | |
Create a store_cell state. | |
![]() | |
compute_cell_state (key_ref k, Args &&... args) | |
Create a computed cell state. | |
value_type | value () |
Retrieve the latest cached value. | |
![]() | |
cell_state (key_ref k) | |
Create a cell state with a given key. | |
cell_state & | operator= (const cell_state &other)=delete |
virtual void | add_observer (observer::ref o) |
Add an observer to the cell's set of observers. | |
virtual void | remove_observer (observer::ref o) |
Remove an observer from the cell's set of observers. | |
virtual void | notify_will_update () |
Notify the observers that the cell's value will change. | |
virtual void | notify_update (bool did_change=true) |
Notify the observers that the cell's value has changed. | |
Protected Types | |
typedef C::value_type | value_type |
Protected Member Functions | |
void | init () override |
Called before the first observer is added. | |
void | pause () override |
Called after the last observer is removed. | |
![]() | |
std::shared_ptr< observer > | observer_ptr () |
Get an observer::ref for this, that can be passed to add_observer and remove_observer of Cell . | |
void | will_update (const key_ref &k) override |
Notifies this observer that the value of the Cell identified by k is going to change. | |
void | update (const key_ref &k, bool changed) override |
Notifies this observer that the value of the Cell identified by k has changed. | |
![]() | |
bool | is_active () const |
Does the cell have at least one observer? | |
![]() | |
void | init_observer_state () |
Initialize the cell observation state. | |
void | pause_observer_state () |
Pause the cell observation state. | |
void | handle_will_update (const std::invocable auto ¬ify_will_update) |
Handle a observer::will_update call. | |
void | handle_will_update (const std::invocable auto &pre_update, const std::invocable auto ¬ify_will_update) |
Handle a observer::will_update call. | |
void | handle_update (bool changed, const std::invocable< bool > auto ¬ify_update) |
Handle an observer::update call. | |
void | handle_update (bool changed, const std::invocable auto &did_change, const std::invocable< bool > auto ¬ify_update, const std::invocable auto &post_update) |
Handle an observer::update call. | |
Additional Inherited Members | |
![]() | |
typedef std::invoke_result_t< C, observer::ref > | value_type |
Shorthand for computed value type. | |
![]() | |
typedef std::shared_ptr< cell_state > | ref |
Shared pointer to a cell_state . | |
![]() | |
typedef std::shared_ptr< observer > | ref |
Shared pointer to an observer . | |
![]() | |
C | compute |
Compute value function. | |
![]() | |
key_ref | key_ |
Key identifying the cell corresponding to this state. | |
std::unordered_map< observer::ref, std::size_t > | observers |
The set of observers observing changes to the values in the cell corresponding to this state. | |
![]() | |
bool | stale = true |
Does the value have to be recomputed? | |
bool | updating = false |
Are the argument cells in the process of updating their values? | |
Maintains the state of a store_cell
.
|
protected |
Shorthand for the value type of C
|
inline |
Create a store_cell
state.
k | Key identifying the cell |
cell | The argument cell |
|
inlineoverrideprotectedvirtual |
Called before the first observer is added.
Subclasses should override this method to include initialization logic specific to this cell state.
Reimplemented from live_cells::compute_cell_state< store_cell_compute_state< C > >.
|
inlineoverrideprotectedvirtual |
Called after the last observer is removed.
Subclasses should override this method to include cleanup logic specific to this cell state.
init()
should be removed in this method. Reimplemented from live_cells::compute_cell_state< store_cell_compute_state< C > >.