|
HikoGUI
A low latency retained GUI
|
#include <ttauri/observable.hpp>
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_base & | operator= (observable_base const &)=delete |
| observable_base & | operator= (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) |
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.
|
inlinenoexcept |
Constructor.
|
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 >.
|
inlinevirtualnoexcept |
Replace the operands.
Reimplemented in tt::detail::observable_chain< T >.
|
inlinenoexcept |
Let other take over the listeners and owner.
|
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.
| new_value | The new value |
Implemented in tt::detail::observable_value< T >, and tt::detail::observable_chain< T >.