TracktionEngine
|
A CachedValue that can take a std::function to constrain its value. More...
#include <tracktion_ConstrainedCachedValue.h>
Inherits juce::ValueTree::Listener.
Public Member Functions | |
ConstrainedCachedValue () | |
Default constructor. | |
ConstrainedCachedValue (juce::ValueTree &tree, const juce::Identifier &propertyID, juce::UndoManager *undoManager) | |
Constructor. | |
ConstrainedCachedValue (juce::ValueTree &tree, const juce::Identifier &propertyID, juce::UndoManager *undoManager, const Type &defaultToUse) | |
Constructor. | |
void | setConstrainer (std::function< Type(Type)> constrainerToUse) |
Sets a std::function to use to constain the value. | |
operator Type () const noexcept | |
Returns the current value of the property. | |
Type | get () const noexcept |
Returns the current value of the property. | |
Type & | operator* () noexcept |
Dereference operator. | |
Type * | operator-> () noexcept |
Dereference operator. | |
template<typename OtherType > | |
bool | operator== (const OtherType &other) const |
Returns true if the current value of the property (or the fallback value) is equal to other. | |
template<typename OtherType > | |
bool | operator!= (const OtherType &other) const |
Returns true if the current value of the property (or the fallback value) is not equal to other. | |
juce::Value | getPropertyAsValue () |
Returns the current property as a Value object. | |
bool | isUsingDefault () const |
Returns true if the current property does not exist and the CachedValue is using the fallback default value instead. | |
Type | getDefault () const |
Returns the current fallback default value. | |
ConstrainedCachedValue & | operator= (const Type &newValue) |
Sets the property. | |
void | setValue (const Type &newValue, juce::UndoManager *undoManagerToUse) |
Sets the property. | |
void | resetToDefault () |
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback default value instead. | |
void | resetToDefault (juce::UndoManager *undoManagerToUse) |
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback default value instead. | |
void | setDefault (const Type &value) |
Resets the fallback default value. | |
void | referTo (juce::ValueTree &tree, const juce::Identifier &property, juce::UndoManager *) |
Makes the CachedValue refer to the specified property inside the given ValueTree. | |
void | referTo (juce::ValueTree &tree, const juce::Identifier &property, juce::UndoManager *, const Type &defaultVal) |
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. | |
void | forceUpdateOfCachedValue () |
Force an update in case the referenced property has been changed from elsewhere. | |
juce::ValueTree & | getValueTree () noexcept |
Returns a reference to the ValueTree containing the referenced property. | |
const juce::Identifier & | getPropertyID () const noexcept |
Returns the property ID of the referenced property. | |
A CachedValue that can take a std::function to constrain its value.
tracktion::engine::ConstrainedCachedValue< Type >::ConstrainedCachedValue | ( | ) |
Default constructor.
Creates a default CachedValue not referring to any property. To initialise the object, call one of the referTo() methods.
tracktion::engine::ConstrainedCachedValue< Type >::ConstrainedCachedValue | ( | juce::ValueTree & | tree, |
const juce::Identifier & | propertyID, | ||
juce::UndoManager * | undoManager | ||
) |
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 |
tracktion::engine::ConstrainedCachedValue< Type >::ConstrainedCachedValue | ( | juce::ValueTree & | tree, |
const juce::Identifier & | propertyID, | ||
juce::UndoManager * | undoManager, | ||
const Type & | defaultToUse | ||
) |
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. |
void tracktion::engine::ConstrainedCachedValue< Type >::setConstrainer | ( | std::function< Type(Type)> | constrainerToUse | ) |
Sets a std::function to use to constain the value.
You must call this before setting any of the values.
|
noexcept |
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().
|
noexcept |
Returns the current value of the property.
If the property does not exist, returns the fallback default value.
Referenced by tracktion::engine::LatencyPlugin::getLatencySeconds().
|
noexcept |
Dereference operator.
Provides direct access to the property.
|
noexcept |
Dereference operator.
Provides direct access to members of the property if it is of object type.
bool tracktion::engine::ConstrainedCachedValue< Type >::operator== | ( | const OtherType & | other | ) | const |
Returns true if the current value of the property (or the fallback value) is equal to other.
bool tracktion::engine::ConstrainedCachedValue< Type >::operator!= | ( | const OtherType & | other | ) | const |
Returns true if the current value of the property (or the fallback value) is not equal to other.
juce::Value tracktion::engine::ConstrainedCachedValue< Type >::getPropertyAsValue | ( | ) |
Returns the current property as a Value object.
bool tracktion::engine::ConstrainedCachedValue< Type >::isUsingDefault | ( | ) | const |
Returns true if the current property does not exist and the CachedValue is using the fallback default value instead.
Type tracktion::engine::ConstrainedCachedValue< Type >::getDefault | ( | ) | const |
Returns the current fallback default value.
ConstrainedCachedValue< Type > & tracktion::engine::ConstrainedCachedValue< Type >::operator= | ( | const Type & | newValue | ) |
Sets the property.
This will actually modify the property in the referenced ValueTree.
void tracktion::engine::ConstrainedCachedValue< Type >::setValue | ( | const Type & | newValue, |
juce::UndoManager * | undoManagerToUse | ||
) |
Sets the property.
This will actually modify the property in the referenced ValueTree.
void tracktion::engine::ConstrainedCachedValue< Type >::resetToDefault | ( | ) |
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback default value instead.
void tracktion::engine::ConstrainedCachedValue< Type >::resetToDefault | ( | juce::UndoManager * | undoManagerToUse | ) |
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback default value instead.
void tracktion::engine::ConstrainedCachedValue< Type >::setDefault | ( | const Type & | value | ) |
Resets the fallback default value.
void tracktion::engine::ConstrainedCachedValue< Type >::referTo | ( | juce::ValueTree & | tree, |
const juce::Identifier & | property, | ||
juce::UndoManager * | um | ||
) |
Makes the CachedValue refer to the specified property inside the given ValueTree.
void tracktion::engine::ConstrainedCachedValue< Type >::referTo | ( | juce::ValueTree & | tree, |
const juce::Identifier & | property, | ||
juce::UndoManager * | um, | ||
const Type & | defaultVal | ||
) |
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.
void tracktion::engine::ConstrainedCachedValue< Type >::forceUpdateOfCachedValue | ( | ) |
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.
|
noexcept |
Returns a reference to the ValueTree containing the referenced property.
|
noexcept |
Returns the property ID of the referenced property.