Live Cells C++
Reactive Programming for C++
Loading...
Searching...
No Matches
live_cells::make_cell< C > Struct Template Reference

Defines a cell class using C such that the constraints defined by the concept Cell are satisifed. More...

#include <make_cell.hpp>

Inheritance diagram for live_cells::make_cell< C >:
Collaboration diagram for live_cells::make_cell< C >:

Public Types

typedef cell_value_type< C > value_type
 Cell value type (return type of C::value()).
 

Public Member Functions

template<typename K , typename... Args>
requires (!Keyable<C> && std::constructible_from<C,Args...>)
 make_cell (K &&key, Args &&... args)
 Constructor that allows a key to be provided, with args forwarded to the constructor of C.
 
template<typename... Args>
requires (!Keyable<C> && std::constructible_from<C,Args...>)
 make_cell (Args &&... args)
 Constructor that forwards all its arguments args to the constructor of C.
 
template<typename... Args>
requires (Keyable<C> && std::constructible_from<C,Args...>)
 make_cell (Args &&... args)
 Constructor that forwards all its arguments args to the constructor of C.
 
void add_observer (observer::ref obs) const
 Add an observer to the cell.
 
void remove_observer (observer::ref obs) const
 Remove an observer from the 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.
 
value_type operator() () const
 Get the value of the cell and track it as a dependency.
 
key_ref key () const
 Get the key identifying the cell.
 
key_ref key () const
 Get the key identifying the cell.
 

Protected Attributes

cell
 
const std::enable_if<!Keyable< C >, key_ref >::type key_
 Key identifying the cell.
 

Detailed Description

template<typename C>
struct live_cells::make_cell< C >

Defines a cell class using C such that the constraints defined by the concept Cell are satisifed.

In-effect, this class generates a cell interface from a prototype that does not satisfy all the constraints of Cell.

Warning
This class may be inherited but may not be used polymorphically.

C::value(), C::add_observer(), C::remove_observer() are used to implement the value(), add_observer() and remove_observer() methods respectively.

The return type of C::value() is used to define the value_type.

If C::key() exists (that is C satisfies the Keyable concept), it is used to implement the key() method. Otherwise a default implementation is provided that returns the key given in the constructor.

If C::operator()() exists (that is C satisfies the Trackable concept), it is used to implement the operator()() method. Otherwise a default implementation is provided.

Constructor & Destructor Documentation

◆ make_cell() [1/3]

template<typename C >
template<typename K , typename... Args>
requires (!Keyable<C> && std::constructible_from<C,Args...>)
live_cells::make_cell< C >::make_cell ( K && key,
Args &&... args )
inline

Constructor that allows a key to be provided, with args forwarded to the constructor of C.

Note
This is only available if C::key() is not defined.
Parameters
keyThe key identifying the cell
argsArguments forwarded to constructor of C

◆ make_cell() [2/3]

template<typename C >
template<typename... Args>
requires (!Keyable<C> && std::constructible_from<C,Args...>)
live_cells::make_cell< C >::make_cell ( Args &&... args)
inline

Constructor that forwards all its arguments args to the constructor of C.

A unique_key is used as the key for this cell.

Note
This is only available if C::key() is not defined.
Parameters
argsArguments forwarded to constructor of C

◆ make_cell() [3/3]

template<typename C >
template<typename... Args>
requires (Keyable<C> && std::constructible_from<C,Args...>)
live_cells::make_cell< C >::make_cell ( Args &&... args)
inline

Constructor that forwards all its arguments args to the constructor of C.

This constructor does not generate or accept any key arguments. If any are provided, they are forwarded to the constructor of C.

Note
This is only available if C::key() is defined.
Parameters
argsArguments forwarded to constructor of C

Member Function Documentation

◆ add_observer()

template<typename C >
void live_cells::make_cell< C >::add_observer ( observer::ref obs) const
inline

Add an observer to the cell.

Cell methods

Note
Implemented using C::add_observer().
Parameters
obsObserver to add to cell

◆ key() [1/2]

template<typename C >
key_ref live_cells::make_cell< C >::key ( ) const
inline

Get the key identifying the cell.

Note
Implemented using C::key().
Returns
The key

◆ key() [2/2]

template<typename C >
key_ref live_cells::make_cell< C >::key ( ) const
inline

Get the key identifying the cell.

Note
This is only available if C::key() is not defined.
Returns
The key

◆ operator()() [1/2]

template<typename C >
value_type live_cells::make_cell< C >::operator() ( ) const
inline

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

Note
Implemented using C::value()
Returns
The cell's value

◆ operator()() [2/2]

template<typename C >
value_type live_cells::make_cell< C >::operator() ( ) const
inline

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

Note
This is only available if C::operator()() is defined.
Implemented using C::operator()()
Returns
The cell's value

◆ remove_observer()

template<typename C >
void live_cells::make_cell< C >::remove_observer ( observer::ref obs) const
inline

Remove an observer from the cell.

Note
Implemented using C::remove_observer().
Parameters
obsObserver to remove from cell

◆ value()

template<typename C >
value_type live_cells::make_cell< C >::value ( ) const
inline

Get the value of the cell.

Note
Implemented using C::value()
Returns
The cell's value

Member Data Documentation

◆ cell

template<typename C >
C live_cells::make_cell< C >::cell
protected

The partial cell implementation.

◆ key_

template<typename C >
const std::enable_if<!Keyable<C>,key_ref>::type live_cells::make_cell< C >::key_
protected

Key identifying the cell.

Note
This member exists only if C::key() is not defined.

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