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

A stateful cell which can have its value set directly. More...

#include <mutable_cell.hpp>

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

Public Types

typedefvalue_type
 The type of value held by this cell.
 

Public Member Functions

 mutable_cell ()
 Create a mutable cell with a default initialized value.
 
 mutable_cell (T value)
 Create a mutable cell with an initial value.
 
 mutable_cell (key_ref key, T value)
 Create a mutable cell with an initial value.
 
operator= (const T &value)
 Set the value of the cell.
 
operator= (const T &value) const
 Set the value of the cell.
 
value () const
 Get the value of the cell.
 
void value (T value) const
 Set the value of the cell.
 
operator() () const
 Get the value of the cell and track it as a dependency.
 
- Public Member Functions inherited from live_cells::stateful_cell< mutable_cell_state< T > >
 stateful_cell (key_ref k, Args... args)
 Create a stateful cell and associate it with a state.
 
key_ref key () const
 Get the key identifying the cell.
 
void add_observer (observer::ref o) const
 Add an observer to the cell.
 
void remove_observer (observer::ref o) const
 Remove an observer from the cell.
 

Additional Inherited Members

- Protected Attributes inherited from live_cells::stateful_cell< mutable_cell_state< T > >
const key_ref key_
 Key identifying the cell.
 
std::shared_ptr< mutable_cell_state< T > > state
 Reference to the cell's state.
 

Detailed Description

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

A stateful cell which can have its value set directly.

Constructor & Destructor Documentation

◆ mutable_cell() [1/2]

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

Create a mutable cell with an initial value.

Parameters
valueThe initial value of the cell

◆ mutable_cell() [2/2]

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

Create a mutable cell with an initial value.

If there is no state associated with key key, a new state is created and the value of the cell is initialized to value.

If there is a state associated with key, value is ignored.

Parameters
keyKey identifying cell
valueInitial value

Member Function Documentation

◆ operator()()

template<typename T >
T live_cells::mutable_cell< T >::operator() ( ) const
inline

Get the value of the cell and track it as a dependency.

Returns
The value of the cell.

◆ operator=() [1/2]

template<typename T >
T live_cells::mutable_cell< T >::operator= ( const T & value)
inline

Set the value of the cell.

This is equivalent to \prop value(value).

Parameters
valueThe new value
Returns
value

◆ operator=() [2/2]

template<typename T >
T live_cells::mutable_cell< T >::operator= ( const T & value) const
inline

Set the value of the cell.

This is equivalent to \prop value(value).

Note
This const version is provided to allow setting the value of a mutable cell within a lambda provided for the reverse computation function of a mutable computed cell.
Parameters
valueThe new value
Returns
value

◆ value() [1/2]

template<typename T >
T live_cells::mutable_cell< T >::value ( ) const
inline

Get the value of the cell.

Returns
The value of the cell.

◆ value() [2/2]

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

Set the value of the cell.

Note
This method is marked const to allow the value of the cell to be set when it is copy-captured by a lambda.
Parameters
valueThe new value

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