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

Dynamically typed Cell container with a static value type. More...

#include <observable.hpp>

Public Member Functions

template<TypedCell< T > C>
 typed_cell (C cell)
 Create a container holding the Cell cell.
 
 typed_cell (cell c)
 Create a container holding the Cell held in c.
 
void add_observer (observer::ref obs)
 Add an observer to the underlying Cell.
 
void remove_observer (observer::ref obs)
 Remove an observer from the underlying Cell.
 
key_ref key () const
 Get the key that uniquely identifies the underlying Cell.
 
T value () const
 Get the value held by the underlying Cell.
 
void value (T value)
 Set the value of the underlying Cell.
 
T operator() () const
 Get the value held by the underlying Cell and track it as a dependency.
 

Friends

class cell
 

Related Symbols

(Note that these are not member symbols.)

template<typename T1 , typename T2 >
bool operator== (const typed_cell< T1 > &a, const typed_cell< T2 > &b)
 Compare two typed_cell's by their keys.
 
template<typename T1 , typename T2 >
bool operator!= (const typed_cell< T1 > &a, const typed_cell< T2 > &b)
 Compare two typed_cell's by their keys.
 

Detailed Description

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

Dynamically typed Cell container with a static value type.

Like cell, this class erases the types of Cell's, so that a cell can be used and stored in containers when its exact type is not known at compile-time. However, this class enforces that the value type of the underlying Cell is convertible to T.

Constructor & Destructor Documentation

◆ typed_cell() [1/2]

template<typename T >
template<TypedCell< T > C>
live_cells::typed_cell< T >::typed_cell ( C cell)
inline

Create a container holding the Cell cell.

Parameters
cellThe cell to hold in the container

◆ typed_cell() [2/2]

template<typename T >
live_cells::typed_cell< T >::typed_cell ( cell c)
inline

Create a container holding the Cell held in c.

Parameters
cA typeless cell container.
Exceptions
bad_typed_cell_castWhen the value type of the Cell held in c is not compatible with the value type T of this container.

Member Function Documentation

◆ add_observer()

template<typename T >
void live_cells::typed_cell< T >::add_observer ( observer::ref obs)
inline

Add an observer to the underlying Cell.

Parameters
obsThe observer to add to the cell.

◆ key()

template<typename T >
key_ref live_cells::typed_cell< T >::key ( ) const
inline

Get the key that uniquely identifies the underlying Cell.

Returns
The key identifying the underlying cell.

◆ operator()()

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

Get the value held by the underlying Cell and track it as a dependency.

Returns
The value of the underlying cell.

◆ remove_observer()

template<typename T >
void live_cells::typed_cell< T >::remove_observer ( observer::ref obs)
inline

Remove an observer from the underlying Cell.

Note
The observer is only removed when this method is called the same number of times add_observer was called for the same observer obs.
Parameters
obsThe observer to remove from the cell.

◆ value() [1/2]

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

Get the value held by the underlying Cell.

Returns
The value of the underlying cell.

◆ value() [2/2]

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

Set the value of the underlying Cell.

If the underlying cell does is not a MutableCell, an std::bad_cast exception is thrown.

Parameters
valueThe value to set the underlying cell to.

Friends And Related Symbol Documentation

◆ operator!=()

template<typename T1 , typename T2 >
bool operator!= ( const typed_cell< T1 > & a,
const typed_cell< T2 > & b )
related

Compare two typed_cell's by their keys.

Parameters
aA dynamically typed cell
bA dynamically typed cell
Returns
true if the key of a is not equal to the key of b.

◆ operator==()

template<typename T1 , typename T2 >
bool operator== ( const typed_cell< T1 > & a,
const typed_cell< T2 > & b )
related

Compare two typed_cell's by their keys.

Parameters
aA dynamically typed cell
bA dynamically typed cell
Returns
true if the key of a is equal to the key of b.

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