Live Cells C++
Reactive Programming for C++
Loading...
Searching...
No Matches
live_cells::store_cell< C, State > Class Template Reference

A Cell that caches the value of another Cell. More...

#include <store_cell.hpp>

Inheritance diagram for live_cells::store_cell< C, State >:
Collaboration diagram for live_cells::store_cell< C, State >:

Public Types

typedef C::value_type value_type
 The type of value held by this cell.
 

Public Member Functions

 store_cell (C cell)
 Create a store cell that caches the value of cell.
 
value_type value () const
 Get the value of the cell.
 
value_type operator() () const
 Get the value of the cell and track it as a dependency.
 
- Public Member Functions inherited from live_cells::stateful_cell< S >
template<typename... Args>
 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< S >
const key_ref key_
 Key identifying the cell.
 
std::shared_ptr< Sstate
 Reference to the cell's state.
 

Detailed Description

template<Cell C, typename State = store_cell_state<C>>
class live_cells::store_cell< C, State >

A Cell that caches the value of another Cell.

This cell reads the value of another cell and caches it until it changes.

This is useful to cache the computed value of a lightweight computed cell, which would otherwise be recomputed every time it is accessed.

Constructor & Destructor Documentation

◆ store_cell()

template<Cell C, typename State = store_cell_state<C>>
live_cells::store_cell< C, State >::store_cell ( C cell)
inline

Create a store cell that caches the value of cell.

Parameters
cellThe argument cell.

Member Function Documentation

◆ operator()()

template<Cell C, typename State = store_cell_state<C>>
value_type live_cells::store_cell< C, State >::operator() ( ) const
inline

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

Returns
The value of the cell.

◆ value()

template<Cell C, typename State = store_cell_state<C>>
value_type live_cells::store_cell< C, State >::value ( ) const
inline

Get the value of the cell.

Returns
The value of the cell.

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