HikoGUI
Select Version: ⚠️ This documents the main development branch of HikoGUI. It might differ from release versions.
A low latency retained GUI
|
#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_state & | operator= (shared_state const &) noexcept=default |
constexpr shared_state & | operator= (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. | |
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:
observer
will extend the lifetime of shared_state
.observer::proxy
must be within the lifetime of observer
.observer::const_proxy
must be within the lifetime of observer
.observer
are created from another observer
they internally do not refer to each other so their lifetime are not connected.T | type used as the shared state. |
|
inlineconstexprnoexcept |
Construct the shared state and initialize the value.
args | The arguments passed to the constructor of the value. |
|
inlinenoexcept |
Get a observer to a member variable of the value.
hi::selector<value_type>
. Name | the name of the member variable of the value. |
|
inlinenoexcept |
Get a observer to a sub-object of value accessed by the index operator.
index | The index used with the index operator of the value. |