HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
tt::detail::observable_base< T > Class Template Referenceabstract

#include <ttauri/observable.hpp>

Inheritance diagram for tt::detail::observable_base< T >:
tt::detail::observable_chain< T > tt::detail::observable_value< T >

Public Types

using value_type = T
 
using notifier_type = notifier<void()>
 
using callback_type = typename notifier_type::callback_type
 
using callback_ptr_type = typename notifier_type::callback_ptr_type
 

Public Member Functions

 observable_base (observable_base const &)=delete
 
 observable_base (observable_base &&)=delete
 
observable_baseoperator= (observable_base const &)=delete
 
observable_baseoperator= (observable_base &&)=delete
 
 observable_base (observable< value_type > *owner) noexcept
 Constructor.
 
virtual value_type load () const noexcept=0
 Get the current value.
 
virtual bool store (value_type const &new_value) noexcept=0
 Set the value.
 
void notify () noexcept
 
virtual void replace_operand (observable_base *from, observable_base *to) noexcept
 Replace the operands.
 
void replace_with (observable_base *other) noexcept
 Let other take over the listeners and owner.
 
void add_listener (observable_base *listener)
 
void remove_listener (observable_base *listener)
 

Detailed Description

template<typename T>
class tt::detail::observable_base< T >

Observable abstract base class.

Objects of the observable_base class will notify listeners through callbacks of changes of its value.

This class does not hold the value itself, concrete subclasses will either hold the value or calculate the value on demand. In many cases concrete subclasses may be sub-expressions of other observable objects.

This object will also track the time when the value was last modified so that the value can be animated. Usefull when displaying the value as an animated graphic element. For calculating inbetween values it will keep track of the previous value.

Constructor & Destructor Documentation

◆ observable_base()

template<typename T >
tt::detail::observable_base< T >::observable_base ( observable< value_type > * owner)
inlinenoexcept

Constructor.

Member Function Documentation

◆ load()

template<typename T >
virtual value_type tt::detail::observable_base< T >::load ( ) const
pure virtualnoexcept

Get the current value.

The value is often calculated directly from the cached values retrieved from notifications down the chain.

Implemented in tt::detail::observable_value< T >, and tt::detail::observable_chain< T >.

◆ replace_operand()

template<typename T >
virtual void tt::detail::observable_base< T >::replace_operand ( observable_base< T > * from,
observable_base< T > * to )
inlinevirtualnoexcept

Replace the operands.

Reimplemented in tt::detail::observable_chain< T >.

◆ replace_with()

template<typename T >
void tt::detail::observable_base< T >::replace_with ( observable_base< T > * other)
inlinenoexcept

Let other take over the listeners and owner.

◆ store()

template<typename T >
virtual bool tt::detail::observable_base< T >::store ( value_type const & new_value)
pure virtualnoexcept

Set the value.

The value is often not directly stored, but instead forwarded up the chain of observables. And then let the notifications flowing backward updated the cached values so that loads() will be quick.

Parameters
new_valueThe new value
Returns
true if the value was different from before.

Implemented in tt::detail::observable_value< T >, and tt::detail::observable_chain< T >.


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