tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tracktion::engine::ConstrainedCachedValue< Type > Class Template Reference

A CachedValue that can take a std::function to constrain its value. More...

#include "tracktion_ConstrainedCachedValue.h"

Inheritance diagram for tracktion::engine::ConstrainedCachedValue< Type >:
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.
 
ConstrainedCachedValueoperator= (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::ValueTreegetValueTree () noexcept
 Returns a reference to the ValueTree containing the referenced property.
 
const juce::IdentifiergetPropertyID () const noexcept
 Returns the property ID of the referenced property.
 

Detailed Description

template<typename Type>
class tracktion::engine::ConstrainedCachedValue< Type >

A CachedValue that can take a std::function to constrain its value.

Definition at line 19 of file tracktion_ConstrainedCachedValue.h.

Constructor & Destructor Documentation

◆ ConstrainedCachedValue() [1/3]

template<typename Type >
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.

Definition at line 174 of file tracktion_ConstrainedCachedValue.h.

◆ ConstrainedCachedValue() [2/3]

template<typename Type >
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.

Parameters
treeThe ValueTree containing the property
propertyIDThe identifier of the property
undoManagerThe UndoManager to use when writing to the property

Definition at line 177 of file tracktion_ConstrainedCachedValue.h.

◆ ConstrainedCachedValue() [3/3]

template<typename Type >
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.

Parameters
treeThe ValueTree containing the property
propertyIDThe identifier of the property
undoManagerThe UndoManager to use when writing to the property
defaultToUseThe fallback default value to use.

Definition at line 185 of file tracktion_ConstrainedCachedValue.h.

Member Function Documentation

◆ forceUpdateOfCachedValue()

template<typename Type >
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.

Definition at line 263 of file tracktion_ConstrainedCachedValue.h.

◆ get()

template<typename Type >
Type tracktion::engine::ConstrainedCachedValue< Type >::get ( ) const
noexcept

Returns the current value of the property.

If the property does not exist, returns the fallback default value.

Definition at line 71 of file tracktion_ConstrainedCachedValue.h.

◆ getDefault()

template<typename Type >
Type tracktion::engine::ConstrainedCachedValue< Type >::getDefault ( ) const

Returns the current fallback default value.

Definition at line 103 of file tracktion_ConstrainedCachedValue.h.

◆ getPropertyAsValue()

template<typename Type >
juce::Value tracktion::engine::ConstrainedCachedValue< Type >::getPropertyAsValue ( )

Returns the current property as a Value object.

Definition at line 206 of file tracktion_ConstrainedCachedValue.h.

◆ getPropertyID()

template<typename Type >
const juce::Identifier & tracktion::engine::ConstrainedCachedValue< Type >::getPropertyID ( ) const
noexcept

Returns the property ID of the referenced property.

Definition at line 147 of file tracktion_ConstrainedCachedValue.h.

◆ getValueTree()

template<typename Type >
juce::ValueTree & tracktion::engine::ConstrainedCachedValue< Type >::getValueTree ( )
noexcept

Returns a reference to the ValueTree containing the referenced property.

Definition at line 144 of file tracktion_ConstrainedCachedValue.h.

◆ isUsingDefault()

template<typename Type >
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.

Definition at line 212 of file tracktion_ConstrainedCachedValue.h.

◆ operator Type()

template<typename Type >
tracktion::engine::ConstrainedCachedValue< Type >::operator Type ( ) const
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().

Definition at line 66 of file tracktion_ConstrainedCachedValue.h.

◆ operator!=()

template<typename Type >
template<typename OtherType >
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.

Definition at line 91 of file tracktion_ConstrainedCachedValue.h.

◆ operator*()

template<typename Type >
Type & tracktion::engine::ConstrainedCachedValue< Type >::operator* ( )
noexcept

Dereference operator.

Provides direct access to the property.

Definition at line 74 of file tracktion_ConstrainedCachedValue.h.

◆ operator->()

template<typename Type >
Type * tracktion::engine::ConstrainedCachedValue< Type >::operator-> ( )
noexcept

Dereference operator.

Provides direct access to members of the property if it is of object type.

Definition at line 79 of file tracktion_ConstrainedCachedValue.h.

◆ operator=()

template<typename Type >
ConstrainedCachedValue< Type > & tracktion::engine::ConstrainedCachedValue< Type >::operator= ( const Type &  newValue)

Sets the property.

This will actually modify the property in the referenced ValueTree.

Definition at line 218 of file tracktion_ConstrainedCachedValue.h.

◆ operator==()

template<typename Type >
template<typename OtherType >
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.

Definition at line 85 of file tracktion_ConstrainedCachedValue.h.

◆ referTo() [1/2]

template<typename Type >
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.

Definition at line 251 of file tracktion_ConstrainedCachedValue.h.

◆ referTo() [2/2]

template<typename Type >
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.

Definition at line 257 of file tracktion_ConstrainedCachedValue.h.

◆ resetToDefault() [1/2]

template<typename Type >
void tracktion::engine::ConstrainedCachedValue< Type >::resetToDefault ( )

Removes the property from the referenced ValueTree and makes the CachedValue return the fallback default value instead.

Definition at line 238 of file tracktion_ConstrainedCachedValue.h.

◆ resetToDefault() [2/2]

template<typename Type >
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.

Definition at line 244 of file tracktion_ConstrainedCachedValue.h.

◆ setConstrainer()

template<typename Type >
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.

Definition at line 193 of file tracktion_ConstrainedCachedValue.h.

◆ setDefault()

template<typename Type >
void tracktion::engine::ConstrainedCachedValue< Type >::setDefault ( const Type &  value)

Resets the fallback default value.

Definition at line 123 of file tracktion_ConstrainedCachedValue.h.

◆ setValue()

template<typename Type >
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.

Definition at line 225 of file tracktion_ConstrainedCachedValue.h.


The documentation for this class was generated from the following file: