LuciadCPillar 2024.0.08
|
This class makes it possible to hold and observe a value that can change over time. More...
#include <luciad/utils/Observable.h>
Public Member Functions | |
Observable (T initialValue) | |
Constructs the observable with an initial value. More... | |
virtual | ~Observable () |
void | addCallback (std::shared_ptr< IInvalidationCallback > callback) |
Adds a callback that is notified when setValue is called. More... | |
const T & | getValue () const |
Returns the observable value. More... | |
void | removeCallback (const std::shared_ptr< IInvalidationCallback > &callback) |
Remove the given callback. More... | |
void | setValue (T value) |
Sets the observable value. More... | |
Static Public Member Functions | |
static std::shared_ptr< Observable< T > > | create (T initialValue) |
Creates a new Observable with the given initial value. More... | |
This class makes it possible to hold and observe a value that can change over time.
T | the type to hold |
|
inlineexplicit |
Constructs the observable with an initial value.
initialValue | the initial value. |
|
inlinevirtual |
|
inline |
Adds a callback that is notified when setValue
is called.
callback | a callback |
luciad::InvalidArgumentException | when the call back is already added. |
|
inlinestatic |
Creates a new Observable with the given initial value.
initialValue | the initial value. |
|
inline |
Returns the observable value.
|
inline |
Remove the given callback.
callback | a callback |
luciad::InvalidArgumentException | when the call back is not known. |
|
inline |
Sets the observable value.
This triggers a call to the configured
callbacks.
value | the new value |
luciad::LogicException | when calling setValue on derived instances for example. |