AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AFieldObservable< T > Class Template Reference

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

Detailed Description

template<typename T>
class AFieldObservable< T >

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

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. More...
 
template<typename Observer_t >
ObserverHandle operator<< (Observer_t observer)
 Adds an observer, immediately feeding the observer with the current value. More...
 
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
 

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.

#include <AUI/Util/AFieldObservable.h>


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