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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_AutomatableParameterTree.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
15{
16public:
17 AutomatableParameterTree() : rootNode (new TreeNode ("root"))
18 {
19 }
20
21 enum NodeType
22 {
23 Parameter,
24 Group
25 };
26
27 struct TreeNode
28 {
29 TreeNode (const juce::String& groupName)
30 : name (groupName), type (AutomatableParameterTree::Group)
31 {}
32
34 : parameter (param), type (AutomatableParameterTree::Parameter)
35 {}
36
37 juce::String name;
39 NodeType type;
41 TreeNode* parent = nullptr;
42
43 void addSubNode (TreeNode* node)
44 {
45 subNodes.add (node);
46 node->parent = this;
47 }
48
49 juce::String getGroupName() const { return name; }
50
52 };
53
54 //==============================================================================
55 TreeNode* getNodeForParameter (AutomatableParameter& param) const
56 {
57 return getNodeForParameter (rootNode.get(), param);
58 }
59
60 void clear()
61 {
62 rootNode = std::make_unique<TreeNode> ("root");
63 }
64
66
67private:
68 static TreeNode* getNodeForParameter (TreeNode* node, AutomatableParameter& param)
69 {
70 for (auto subNode : node->subNodes)
71 {
72 if (subNode->type == Parameter)
73 {
74 if (subNode->parameter.get() == &param)
75 return subNode;
76 }
77 else if (subNode->type == Group)
78 {
79 if (auto res = getNodeForParameter (subNode, param))
80 return res;
81 }
82 }
83
84 return {};
85 }
86
87 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AutomatableParameterTree)
88};
89
90}} // namespace tracktion { inline namespace engine
ObjectClass * add(ObjectClass *newObject)
T is_pointer_v
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)