22#include "cello_object.h"
23#include "cello_value.h"
56template <
typename T>
class ComputedValue :
public ValueBase
63 using GetImplFn = std::function<T ()>;
65 ComputedValue (
Object&
object,
const juce::Identifier&
id, GetImplFn getImpl =
nullptr,
SetImplFn setImpl =
nullptr)
97 void set (
const T& val)
99 if (setImpl !=
nullptr)
110 operator T ()
const {
return get (); }
120 if (getImpl !=
nullptr)
146#define MAKE_COMPUTED_VALUE_MEMBER(type, name, ...) \
147 static const inline juce::Identifier name##Id { #name }; \
148 cello::ComputedValue<type> name { *this, name##Id, __VA_ARGS__ };
T get() const
Get the current computed value.
Definition cello_computed_value.h:118
void set(const T &val)
Set the value of the computed value.
Definition cello_computed_value.h:97
std::function< void(const T &)> SetImplFn
The type of the function that will be called to set the value of the computed value.
Definition cello_computed_value.h:62
ComputedValue & operator=(const T &val)
Assignment operator for the computed value.
Definition cello_computed_value.h:82
Definition cello_object.h:34
const juce::Identifier id
identifier of this value/property.
Definition cello_value.h:54
ValueBase(const juce::Identifier &id_)
ctor is protected – you can't create an object of type ValueBase directly, this only exists so we hav...
Definition cello_value.h:47