mitteLib
Loading...
Searching...
No Matches
mlab::observable< T > Class Template Reference

#include <observable.hpp>

Public Types

using read_value_type = std::conditional_t<std::is_trivially_copyable_v<T>, T, T const &>
 
using read_observer_fn = std::function<void(read_value_type)>
 
using write_observer_fn = std::function<void(read_value_type, read_value_type)>
 

Public Member Functions

 observable ()
 
 observable (T t)
 
 operator read_value_type () const
 
observableoperator= (T t)
 
observe< T > do_observe (read_observer_fn read_fn, write_observer_fn write_fn)
 
observable_ref< T > ref ()
 
observable_cref< T > cref () const
 

Private Member Functions

std::size_t append_observer (std::pair< read_observer_fn, write_observer_fn > observers)
 
void delete_observer (std::size_t idx)
 

Private Attributes

_value
 
std::recursive_mutex _lock
 
std::vector< std::pair< read_observer_fn, write_observer_fn > > _observers
 

Friends

class observe< T >
 

Member Typedef Documentation

◆ read_observer_fn

template<class T >
using mlab::observable< T >::read_observer_fn = std::function<void(read_value_type)>

◆ read_value_type

template<class T >
using mlab::observable< T >::read_value_type = std::conditional_t<std::is_trivially_copyable_v<T>, T, T const &>

◆ write_observer_fn

template<class T >
using mlab::observable< T >::write_observer_fn = std::function<void(read_value_type, read_value_type)>

Constructor & Destructor Documentation

◆ observable() [1/2]

template<class T >
mlab::observable< T >::observable ( )
inline

◆ observable() [2/2]

template<class T >
mlab::observable< T >::observable ( T t)
inlineexplicit

Member Function Documentation

◆ append_observer()

template<class T >
std::size_t mlab::observable< T >::append_observer ( std::pair< read_observer_fn, write_observer_fn > observers)
nodiscardprivate

◆ cref()

template<class T >
observable_cref< T > mlab::observable< T >::cref ( ) const
nodiscard

◆ delete_observer()

template<class T >
void mlab::observable< T >::delete_observer ( std::size_t idx)
private

◆ do_observe()

template<class T >
observe< T > mlab::observable< T >::do_observe ( read_observer_fn read_fn,
write_observer_fn write_fn )
nodiscard

◆ operator read_value_type()

template<class T >
mlab::observable< T >::operator read_value_type ( ) const
inline

◆ operator=()

template<class T >
observable< T > & mlab::observable< T >::operator= ( T t)
inline

◆ ref()

template<class T >
observable_ref< T > mlab::observable< T >::ref ( )
nodiscard

Friends And Related Symbol Documentation

◆ observe< T >

template<class T >
friend class observe< T >
friend

Member Data Documentation

◆ _lock

template<class T >
std::recursive_mutex mlab::observable< T >::_lock
mutableprivate

◆ _observers

template<class T >
std::vector<std::pair<read_observer_fn, write_observer_fn> > mlab::observable< T >::_observers
private

◆ _value

template<class T >
T mlab::observable< T >::_value
private

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