Live Cells C++
Reactive Programming for C++
Loading...
Searching...
No Matches
live_cells::mutable_cell_state< T > Class Template Reference

Maintains the state of a mutable_cell. More...

#include <mutable_cell.hpp>

Inheritance diagram for live_cells::mutable_cell_state< T >:
Collaboration diagram for live_cells::mutable_cell_state< T >:

Public Member Functions

 mutable_cell_state (key_ref key, T value)
 Create a mutable cell state with the value initialized to value.
 
value ()
 Get the value of the cell.
 
void value (T value)
 Set the value of the cell and notify its observers.
 
 cell_state (key_ref k)
 Create a cell state with a given key.
 
- Public Member Functions inherited from live_cells::cell_state
 cell_state (key_ref k)
 Create a cell state with a given key.
 
cell_stateoperator= (const cell_state &other)=delete
 
virtual void init ()
 Called before the first observer is added.
 
virtual void pause ()
 Called after the last observer is removed.
 
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 Member Functions

void silent_set (T value)
 Set the cell's value without notifying observers.
 
void add_to_batch ()
 Add this state to the list of mutable cells that were updating during the current batch update.
 
- Protected Member Functions inherited from live_cells::cell_state
bool is_active () const
 Does the cell have at least one observer?
 

Static Protected Member Functions

static bool is_batch_update ()
 Is a batch update of mutable cells currently in effect?
 

Additional Inherited Members

- Public Types inherited from live_cells::cell_state
typedef std::shared_ptr< cell_stateref
 Shared pointer to a cell_state.
 
- Protected Attributes inherited from live_cells::cell_state
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.
 

Detailed Description

template<typename T>
class live_cells::mutable_cell_state< T >

Maintains the state of a mutable_cell.

Constructor & Destructor Documentation

◆ mutable_cell_state()

template<typename T >
live_cells::mutable_cell_state< T >::mutable_cell_state ( key_ref key,
T value )
inline

Create a mutable cell state with the value initialized to value.

Parameters
keyKey identifying the state
valueInitial value

Member Function Documentation

◆ cell_state()

template<typename T >
live_cells::cell_state::cell_state ( key_ref k)
inline

Create a cell state with a given key.

Parameters
kThe key

◆ is_batch_update()

template<typename T >
static bool live_cells::mutable_cell_state< T >::is_batch_update ( )
inlinestaticprotected

Is a batch update of mutable cells currently in effect?

Returns
true if a batch update is in effect

◆ silent_set()

template<typename T >
void live_cells::mutable_cell_state< T >::silent_set ( T value)
inlineprotected

Set the cell's value without notifying observers.

Parameters
valueThe new value

◆ value() [1/2]

template<typename T >
T live_cells::mutable_cell_state< T >::value ( )
inline

Get the value of the cell.

Returns
The value

◆ value() [2/2]

template<typename T >
void live_cells::mutable_cell_state< T >::value ( T value)
inline

Set the value of the cell and notify its observers.

Parameters
valueThe new value.

The documentation for this class was generated from the following file: