HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
v1::shared_state< T > Class Template Reference

#include <hikogui/observer/shared_state.hpp>

Public Types

using value_type = T
 

Public Member Functions

constexpr shared_state (shared_state const &) noexcept=default
 
constexpr shared_state (shared_state &&) noexcept=default
 
constexpr shared_stateoperator= (shared_state const &) noexcept=default
 
constexpr shared_stateoperator= (shared_state &&) noexcept=default
 
template<typename... Args>
constexpr shared_state (Args &&...args) noexcept
 Construct the shared state and initialize the value.
 
observer< value_type > observer () const &noexcept
 
auto sub (auto const &index) const &noexcept
 Get a observer to a sub-object of value accessed by the index operator.
 
template<fixed_string Name>
auto sub () const &noexcept
 Get a observer to a member variable of the value.
 

Detailed Description

template<typename T>
class v1::shared_state< T >

Shared state of an application.

The shared state of an application that can be manipulated by the GUI, preference and other systems.

A observer selects a member or indexed element from the shared state, or from another observer. You can .read() or .copy() the value pointed to by the observer to read and manipulate the shared-data.

Both .read() and .copy() take the full shared-state as a whole not allowing other threads to have write access to this reference or copy. A copy will be automatically committed, or may be aborted as well.

lifetime:

Template Parameters
Ttype used as the shared state.

Constructor & Destructor Documentation

◆ shared_state()

template<typename T >
template<typename... Args>
constexpr v1::shared_state< T >::shared_state ( Args &&... args)
inlineconstexprnoexcept

Construct the shared state and initialize the value.

Parameters
argsThe arguments passed to the constructor of the value.

Member Function Documentation

◆ sub() [1/2]

template<typename T >
template<fixed_string Name>
auto v1::shared_state< T >::sub ( ) const &
inlinenoexcept

Get a observer to a member variable of the value.

Note
This requires the specialization of hi::selector<value_type>.
Template Parameters
Namethe name of the member variable of the value.
Returns
The new observer pointing to the member variable of the value

◆ sub() [2/2]

template<typename T >
auto v1::shared_state< T >::sub ( auto const & index) const &
inlinenoexcept

Get a observer to a sub-object of value accessed by the index operator.

Parameters
indexThe index used with the index operator of the value.
Returns
The new observer pointing to a sub-object of the value.

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