58template <
typename Type>
119 template <
typename OtherType>
125 template <
typename OtherType>
158 void setDefault (
const Type& value) { defaultValue = value; }
197 Type getTypedValue()
const;
208template <
typename Type>
211template <
typename Type>
213 : targetTree (v), targetProperty (i), undoManager (
um),
214 defaultValue(), cachedValue (getTypedValue())
219template <
typename Type>
221 : targetTree (v), targetProperty (i), undoManager (
um),
222 defaultValue (
defaultToUse), cachedValue (getTypedValue())
227template <
typename Type>
230 return targetTree.getPropertyAsValue (targetProperty, undoManager);
233template <
typename Type>
236 return ! targetTree.hasProperty (targetProperty);
239template <
typename Type>
242 setValue (newValue, undoManager);
246template <
typename Type>
249 if (cachedValue != newValue || isUsingDefault())
251 cachedValue = newValue;
256template <
typename Type>
259 resetToDefault (undoManager);
262template <
typename Type>
266 forceUpdateOfCachedValue();
269template <
typename Type>
272 referToWithDefault (v, i,
um, Type());
275template <
typename Type>
281template <
typename Type>
284 cachedValue = getTypedValue();
287template <
typename Type>
290 targetTree.removeListener (
this);
295 cachedValue = getTypedValue();
296 targetTree.addListener (
this);
299template <
typename Type>
300inline Type CachedValue<Type>::getTypedValue()
const
302 if (
const var* property = targetTree.getPropertyPointer (targetProperty))
303 return VariantConverter<Type>::fromVar (*property);
308template <
typename Type>
309inline void CachedValue<Type>::valueTreePropertyChanged (ValueTree& changedTree,
const Identifier& changedProperty)
312 forceUpdateOfCachedValue();
bool isUsingDefault() const
Type * operator->() noexcept
ValueTree & getValueTree() noexcept
const Identifier & getPropertyID() const noexcept
CachedValue & operator=(const Type &newValue)
void forceUpdateOfCachedValue()
void setValue(const Type &newValue, UndoManager *undoManagerToUse)
UndoManager * getUndoManager() noexcept
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
Value getPropertyAsValue()
bool operator==(const OtherType &other) const
void setDefault(const Type &value)
bool operator!=(const OtherType &other) const
Type get() const noexcept
Type & operator*() noexcept
void addListener(Listener *listener)