57template <
typename Type>
118 template <
typename OtherType>
121 return cachedValue == other;
127 template <
typename OtherType>
160 void setDefault (
const Type& value) { defaultValue = value; }
199 Type getTypedValue()
const;
210template <
typename Type>
213template <
typename Type>
215 : targetTree (v), targetProperty (i), undoManager (
um),
216 defaultValue(), cachedValue (getTypedValue())
221template <
typename Type>
223 : targetTree (v), targetProperty (i), undoManager (
um),
224 defaultValue (
defaultToUse), cachedValue (getTypedValue())
229template <
typename Type>
232 return targetTree.getPropertyAsValue (targetProperty, undoManager);
235template <
typename Type>
238 return ! targetTree.hasProperty (targetProperty);
241template <
typename Type>
244 setValue (newValue, undoManager);
248template <
typename Type>
251 if (! exactlyEqual (cachedValue, newValue) || isUsingDefault())
253 cachedValue = newValue;
258template <
typename Type>
261 resetToDefault (undoManager);
264template <
typename Type>
268 forceUpdateOfCachedValue();
271template <
typename Type>
274 referToWithDefault (v, i,
um, Type());
277template <
typename Type>
283template <
typename Type>
286 cachedValue = getTypedValue();
289template <
typename Type>
292 targetTree.removeListener (
this);
297 cachedValue = getTypedValue();
298 targetTree.addListener (
this);
301template <
typename Type>
302inline Type CachedValue<Type>::getTypedValue()
const
304 if (
const var* property = targetTree.getPropertyPointer (targetProperty))
305 return VariantConverter<Type>::fromVar (*property);
310template <
typename Type>
311inline void CachedValue<Type>::valueTreePropertyChanged (ValueTree& changedTree,
const Identifier& changedProperty)
313 if (changedProperty == targetProperty && targetTree == changedTree)
314 forceUpdateOfCachedValue();
bool isUsingDefault() const
ValueTree & getValueTree() noexcept
const Identifier & getPropertyID() const noexcept
CachedValue & operator=(const Type &newValue)
void forceUpdateOfCachedValue()
const Type & operator*() const noexcept
const Type * operator->() const noexcept
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
void addListener(Listener *listener)