|
LMMS
|
#include <juce_CachedValue.h>
Private Member Functions | |
| void | referToWithDefault (ValueTree &, const Identifier &, UndoManager *, const Type &) |
| Type | getTypedValue () const |
| void | valueTreePropertyChanged (ValueTree &changedTree, const Identifier &changedProperty) override |
| Private Member Functions inherited from juce::ValueTree::Listener | |
| virtual | ~Listener ()=default |
| virtual void | valueTreeChildAdded (ValueTree &parentTree, ValueTree &childWhichHasBeenAdded) |
| virtual void | valueTreeChildRemoved (ValueTree &parentTree, ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved) |
| virtual void | valueTreeChildOrderChanged (ValueTree &parentTreeWhoseChildrenHaveMoved, int oldIndex, int newIndex) |
| virtual void | valueTreeParentChanged (ValueTree &treeWhoseParentHasChanged) |
| virtual void | valueTreeRedirected (ValueTree &treeWhichHasBeenChanged) |
Private Attributes | |
| ValueTree | targetTree |
| Identifier | targetProperty |
| UndoManager * | undoManager = nullptr |
| Type | defaultValue |
| Type | cachedValue |
This class acts as a typed wrapper around a property inside a ValueTree.
A CachedValue provides an easy way to read and write a ValueTree property with a chosen type. So for example a CachedValue<int> allows you to read or write the property as an int, and a CachedValue<String> lets you work with it as a String.
It also allows efficient access to the value, by caching a copy of it in the type that is being used.
You can give the CachedValue an optional UndoManager which it will use when writing to the underlying ValueTree.
If the property inside the ValueTree is missing, the CachedValue will automatically return an optional default value, which can be specified when initialising the CachedValue.
To create one, you can either use the constructor to attach the CachedValue to a ValueTree, or can create an uninitialised CachedValue with its default constructor and then attach it later with the referTo() methods.
Common types like String, int, double which can be easily converted to a var should work out-of-the-box, but if you want to use more complex custom types, you may need to implement some template specialisations of VariantConverter which this class uses to convert between the type and the ValueTree's internal var.
@tags{DataStructures}
|
inlinedefault |
Default constructor. Creates a default CachedValue not referring to any property. To initialise the object, call one of the referTo() methods.
|
inline |
Constructor.
Creates a CachedValue referring to a Value property inside a ValueTree. If you use this constructor, the fallback value will be a default-constructed instance of Type.
| tree | The ValueTree containing the property |
| propertyID | The identifier of the property |
| undoManager | The UndoManager to use when writing to the property |
|
inline |
Constructor.
Creates a default Cached Value referring to a Value property inside a ValueTree, and specifies a fallback value to use if the property does not exist.
| tree | The ValueTree containing the property |
| propertyID | The identifier of the property |
| undoManager | The UndoManager to use when writing to the property |
| defaultToUse | The fallback default value to use. |
|
inline |
Force an update in case the referenced property has been changed from elsewhere.
Note: The CachedValue is a ValueTree::Listener and therefore will be informed of changes of the referenced property anyway (and update itself). But this may happen asynchronously. forceUpdateOfCachedValue() forces an update immediately.
|
inlinenoexcept |
Returns the current value of the property. If the property does not exist, returns the fallback default value.
|
inline |
Returns the current fallback default value.
|
inline |
Returns the current property as a Value object.
|
inlinenoexcept |
Returns the property ID of the referenced property.
|
inlineprivate |
|
inlinenoexcept |
Returns the UndoManager that is being used.
|
inlinenoexcept |
Returns a reference to the ValueTree containing the referenced property.
|
inline |
Returns true if the current property does not exist and the CachedValue is using the fallback default value instead.
|
inlinenoexcept |
Returns the current value of the property. If the property does not exist, returns the fallback default value.
This is the same as calling get().
|
inline |
Returns true if the current value of the property (or the fallback value) is not equal to other.
|
inlinenoexcept |
Dereference operator. Provides direct access to the property.
|
inlinenoexcept |
Dereference operator. Provides direct access to members of the property if it is of object type.
|
inline |
Sets the property. This will actually modify the property in the referenced ValueTree.
|
inline |
Returns true if the current value of the property (or the fallback value) is equal to other.
|
inline |
Makes the CachedValue refer to the specified property inside the given ValueTree.
|
inline |
Makes the CachedValue refer to the specified property inside the given ValueTree, and specifies a fallback value to use if the property does not exist.
|
inlineprivate |
|
inline |
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback default value instead.
|
inline |
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback default value instead.
|
inline |
Resets the fallback default value.
|
inline |
Sets the property. This will actually modify the property in the referenced ValueTree.
|
inlineoverrideprivatevirtual |
This method is called when a property of this tree (or of one of its sub-trees) is changed. Note that when you register a listener to a tree, it will receive this callback for property changes in that tree, and also for any of its children, (recursively, at any depth). If your tree has sub-trees but you only want to know about changes to the top level tree, simply check the tree parameter in this callback to make sure it's the tree you're interested in.
Reimplemented from juce::ValueTree::Listener.
|
private |
|
private |
|
private |
|
private |
|
private |