Maintains an object hierarchy that mirrors a ValueTree structure.
More...
#include <gin_valuetreeobject.h>
Inherits juce::ValueTree::Listener.
Maintains an object hierarchy that mirrors a ValueTree structure.
This base class allows you to create an object-oriented wrapper around a ValueTree, where each ValueTree node is represented by a corresponding object. The object hierarchy automatically stays in sync with the ValueTree structure.
To use this class:
- Derive your own classes from ValueTreeObject
- Implement a factory function to create appropriate objects for each ValueTree type
- Changes to the ValueTree will automatically create/destroy matching objects
- See also
- getState, getChildren, findParentOfType, findChildrenOfClass
◆ ValueTreeObject()
| ValueTreeObject::ValueTreeObject |
( |
const juce::ValueTree & |
state | ) |
|
Creates a ValueTreeObject wrapping the given ValueTree.
- Parameters
-
| state | The ValueTree this object represents |
◆ getState()
| juce::ValueTree & ValueTreeObject::getState |
( |
| ) |
|
Returns the ValueTree that this object represents.
- Returns
- Reference to the wrapped ValueTree
◆ getChildren()
◆ findParentOfType()
| TargetClass * ValueTreeObject::findParentOfType |
( |
| ) |
const |
Searches up the parent chain for an object of the specified type.
- Template Parameters
-
| TargetClass | The class type to search for |
- Returns
- Pointer to the first parent of the specified type, or nullptr if not found
◆ findChildrenOfClass()
| juce::Array< TargetClass * > ValueTreeObject::findChildrenOfClass |
( |
| ) |
const |
Finds all direct children of a specific class type.
- Template Parameters
-
| TargetClass | The class type to search for |
- Returns
- Array of pointers to children of the specified type
◆ countChildrenOfClass()
| int ValueTreeObject::countChildrenOfClass |
( |
| ) |
const |
Counts the number of direct children of a specific class type.
- Template Parameters
-
| TargetClass | The class type to count |
- Returns
- The number of children of the specified type
◆ findChildOfClass()
Finds a specific child of a class type by index.
Returns the nth child of the specified type (where n is the idx parameter).
- Template Parameters
-
| TargetClass | The class type to search for |
- Parameters
-
| idx | The index of the child to return (0-based, among children of this type) |
- Returns
- Pointer to the child at the specified index, or nullptr if not found
◆ factory
Factory function for creating ValueTreeObject instances.
Set this to a function that creates the appropriate ValueTreeObject-derived class based on the ValueTree's type identifier.
The documentation for this class was generated from the following file: