AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AFieldObservable< T > Class Template Reference

Stores a value and observes it's changes, notifying observers. More...

#include <AUI/Util/AFieldObservable.h>

Public Types

using Observer = std::function<void()>
 
using ObserverHandle = Observer*
 

Public Member Functions

 AFieldObservable (T initial=T())
 
void setValue (T t, ObserverHandle exceptObserver=nullptr)
 
void notifyObservers (ObserverHandle exceptObserver=nullptr)
 
AFieldObservableoperator= (T t)
 
T & operator+= (T t)
 
T & operator-= (T t)
 
T & operator*= (T t)
 
T & operator/= (T t)
 
 operator const T & () const noexcept
 
const T & value () const noexcept
 
T * operator-> () noexcept
 
T const * operator-> () const noexcept
 
template<typename Observer_t>
ObserverHandle addObserver (Observer_t &&observer)
 Adds an observer, immediately feeding the observer with the current value.
 
template<typename Observer_t>
ObserverHandle operator<< (Observer_t observer)
 Adds an observer, immediately feeding the observer with the current value.
 
void operator>> (ObserverHandle h)
 Removes an observer.
 
void removeObserver (ObserverHandle h)
 Removes an observer.
 
template<aui::invocable< const T & > AdapterCallable>
AFieldObservableAdapter< T, std::decay_t< AdapterCallable > > operator() (AdapterCallable &&callable) noexcept
 

Detailed Description

template<typename T>
class AFieldObservable< T >

Stores a value and observes it's changes, notifying observers.

Member Function Documentation

◆ addObserver()

template<typename T>
template<typename Observer_t>
ObserverHandle AFieldObservable< T >::addObserver ( Observer_t && observer)
inline

Adds an observer, immediately feeding the observer with the current value.

Parameters
observerobserver. Optionally can accept the AFieldObservable's stored type as the first argument.

◆ operator<<()

template<typename T>
template<typename Observer_t>
ObserverHandle AFieldObservable< T >::operator<< ( Observer_t observer)
inline

Adds an observer, immediately feeding the observer with the current value.

Parameters
observerobserver. Optionally can accept the AFieldObservable's stored type as the first argument.

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