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

A computed cell which determines its argument cells at runtime. More...

#include <dynamic_compute_cell.hpp>

Inheritance diagram for live_cells::dynamic_compute_cell< F, State >:
Collaboration diagram for live_cells::dynamic_compute_cell< F, State >:

Public Types

typedef std::invoke_result_t< F > value_type
 Shorthand for the type of value held by this cell.
 

Public Member Functions

 dynamic_compute_cell (F compute)
 Create a dynamic computed cell with a given value computation function.
 
 dynamic_compute_cell (key_ref key, F compute)
 Create a dynamic computed cell with a given value computation function.
 
value_type value () const
 
value_type operator() () const
 
- 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<std::invocable F, typename State = dynamic_compute_cell_state<F>>
class live_cells::dynamic_compute_cell< F, State >

A computed cell which determines its argument cells at runtime.

This is a stateful cell that caches its value when computed and maintains its own observer set.

Constructor & Destructor Documentation

◆ dynamic_compute_cell() [1/2]

template<std::invocable F, typename State = dynamic_compute_cell_state<F>>
live_cells::dynamic_compute_cell< F, State >::dynamic_compute_cell ( F compute)
inline

Create a dynamic computed cell with a given value computation function.

The function compute is called with no arguments to compute the value of the cell when necessary. It should reference its argument cells using the function call operator so that they are registered as dependencies of this cell.

Parameters
computeValue computation function.

◆ dynamic_compute_cell() [2/2]

template<std::invocable F, typename State = dynamic_compute_cell_state<F>>
live_cells::dynamic_compute_cell< F, State >::dynamic_compute_cell ( key_ref key,
F compute )
inline

Create a dynamic computed cell with a given value computation function.

The function compute is called with no arguments to compute the value of the cell when necessary. It should reference its argument cells using the function call operator so that they are registered as dependencies of this cell.

Parameters
keyKey identifying cell.
computeValue computation function.

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