AAX SDK 2.8.0
Avid Audio Extensions Development Kit
Loading...
Searching...
No Matches
AAX_PageTableUtilities.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 * Copyright 2016-2017, 2023-2024 Avid Technology, Inc.
4 * All rights reserved.
5 *
6 * This file is part of the Avid AAX SDK.
7 *
8 * The AAX SDK is subject to commercial or open-source licensing.
9 *
10 * By using the AAX SDK, you agree to the terms of both the Avid AAX SDK License
11 * Agreement and Avid Privacy Policy.
12 *
13 * AAX SDK License: https://developer.avid.com/aax
14 * Privacy Policy: https://www.avid.com/legal/privacy-policy-statement
15 *
16 * Or: You may also use this code under the terms of the GPL v3 (see
17 * www.gnu.org/licenses).
18 *
19 * THE AAX SDK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 * EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 * DISCLAIMED.
22 */
23
24#ifndef AAXLibrary_AAX_PageTableUtilities_h
25#define AAXLibrary_AAX_PageTableUtilities_h
26
27#include "AAX_CString.h"
28#include "AAX.h"
29
30namespace AAX
31{
36 template <class T1, class T2>
37 inline bool PageTableParameterMappingsAreEqual(const T1& inL, const T2& inR)
38 {
41
42 int32_t numPagesL = -1;
43 int32_t numPagesR = -1;
44 errL = inL.GetNumPages(numPagesL);
45 errR = inR.GetNumPages(numPagesR);
46
47 if (errL != errR || numPagesL != numPagesR) { return false; }
48 else if (AAX_SUCCESS != errL) { return true; } // can't get page data from either table
49
50 for (int32_t i = 0; i < numPagesL; ++i)
51 {
52 int32_t numParamsL = -1;
53 int32_t numParamsR = -1;
54 errL = inL.GetNumMappedParameterIDs(i, numParamsL);
55 errR = inR.GetNumMappedParameterIDs(i, numParamsR);
56
57 if (errL != errR || numParamsL != numParamsR) { return false; }
58 else if (AAX_SUCCESS != errL) { continue; } // skip this page if equal errors were returned
59
60 for (int32_t j = 0; j < numParamsL; ++j)
61 {
62 AAX_CString paramIdentifierL;
63 AAX_CString paramIdentifierR;
64 errL = inL.GetMappedParameterID(i, j, paramIdentifierL);
65 errR = inR.GetMappedParameterID(i, j, paramIdentifierR);
66
67 if (errL != errR || paramIdentifierL != paramIdentifierR) { return false; }
68 }
69 }
70
71 return true;
72 }
73
74 template <class T1, class T2>
75 inline bool PageTableParameterNameVariationsAreEqual(const T1& inL, const T2& inR)
76 {
79
80 int32_t numParamIdentifiersL = -1;
81 int32_t numParamIdentifiersR = -1;
82 errL = inL.GetNumParametersWithNameVariations(numParamIdentifiersL);
83 errR = inR.GetNumParametersWithNameVariations(numParamIdentifiersR);
84
85 if (errL != errR || numParamIdentifiersL != numParamIdentifiersR) { return false; }
86 else if (AAX_SUCCESS != errL) { return true; } // can't get parameter name variation data from either table
87
88 for (int32_t i = 0; i < numParamIdentifiersL; ++i)
89 {
90 AAX_CString paramIdentifierL;
91 AAX_CString paramIdentifierR;
92 errL = inL.GetNameVariationParameterIDAtIndex(i, paramIdentifierL);
93 errL = inR.GetNameVariationParameterIDAtIndex(i, paramIdentifierR);
94
95 if (errL != errR || paramIdentifierL != paramIdentifierR) { return false; }
96 else if (AAX_SUCCESS != errL) { continue; } // skip this index if equal errors were returned
97
98 int32_t numVariationsL = -1;
99 int32_t numVariationsR = -1;
100 errL = inL.GetNumNameVariationsForParameter(paramIdentifierL.Get(), numVariationsL);
101 errL = inR.GetNumNameVariationsForParameter(paramIdentifierR.Get(), numVariationsR);
102
103 if (errL != errR || numVariationsL != numVariationsR) { return false; }
104 else if (AAX_SUCCESS != errL) { continue; } // skip this index if equal errors were returned
105
106 for (int32_t j = 0; j < numVariationsL; ++j)
107 {
108 AAX_CString nameVariationL;
109 int32_t lengthL;
110 AAX_CString nameVariationR;
111 int32_t lengthR;
112 errL = inL.GetParameterNameVariationAtIndex(paramIdentifierL.Get(), j, nameVariationL, lengthL);
113 errR = inR.GetParameterNameVariationAtIndex(paramIdentifierR.Get(), j, nameVariationR, lengthR);
114
115 if (errL != errR || lengthL != lengthR || nameVariationL != nameVariationR) { return false; }
116 }
117 }
118
119 return true;
120 }
121
122 template <class T1, class T2>
123 inline bool PageTablesAreEqual(const T1& inL, const T2& inR)
124 {
126 }
127
132 template <class T>
133 inline void CopyPageTable(T& to, const T& from)
134 {
135 to.Clear();
136
137 // Copy page tables
138 int32_t curPageIndex;
139 from.GetNumPages(curPageIndex);
140 while (0 < curPageIndex--)
141 {
142 to.InsertPage(0);
143
144 int32_t numIDsRemaining = 0;
145 from.GetNumMappedParameterIDs(curPageIndex, numIDsRemaining);
146 for (int32_t curSlotIndex = 0; 0 < numIDsRemaining; ++curSlotIndex) // numIDsRemaining is decremented in the loop body
147 {
148 AAX_CString curParam;
149 const AAX_Result getParamResult = from.GetMappedParameterID(curPageIndex, curSlotIndex, curParam);
150 if (AAX_SUCCESS == getParamResult)
151 {
152 to.MapParameterID(curParam.CString(), 0, curSlotIndex);
153 --numIDsRemaining;
154 }
155 }
156 }
157
158 // Copy name variations
159 int32_t numParameterIdentifiers = 0;
160 to.ClearParameterNameVariations();
161 from.GetNumParametersWithNameVariations(numParameterIdentifiers);
162 for (int32_t curParamIndex = 0; curParamIndex < numParameterIdentifiers; ++curParamIndex)
163 {
164 AAX_CString curParamIdentifier;
165 from.GetNameVariationParameterIDAtIndex(curParamIndex, curParamIdentifier);
166
167 int32_t numNameVariations = 0;
168 from.GetNumNameVariationsForParameter(curParamIdentifier.Get(), numNameVariations);
169
170 for (int32_t curNameVariationIndex = 0; curNameVariationIndex < numNameVariations; ++curNameVariationIndex)
171 {
172 int32_t curNameVariationLength;
173 AAX_CString curNameVariation;
174 from.GetParameterNameVariationAtIndex(curParamIdentifier.Get(), curNameVariationIndex, curNameVariation, curNameVariationLength);
175 to.SetParameterNameVariation(curParamIdentifier.Get(), curNameVariation, curNameVariationLength);
176 }
177 }
178 }
179
186 template <class T>
187 inline std::vector<std::pair<int32_t, int32_t> > FindParameterMappingsInPageTable(const T& inTable, AAX_CParamID inParameterID)
188 {
189 const AAX_CString searchParamID(inParameterID);
190 std::vector<std::pair<int32_t, int32_t> > foundParamMappings;
191
192 int32_t numPages = 0;
193 inTable.GetNumPages(numPages);
194 for (int32_t i = 0; i < numPages; ++i)
195 {
196 int32_t numIDsRemaining = 0;
197 inTable.GetNumMappedParameterIDs(i, numIDsRemaining);
198 for (int32_t curSlotIndex = 0; 0 < numIDsRemaining; ++curSlotIndex) // numIDs is decremented in the loop body
199 {
200 AAX_CString curParam;
201 const AAX_Result getParamResult = inTable.GetMappedParameterID(i, curSlotIndex, curParam);
202 if (AAX_SUCCESS == getParamResult)
203 {
204 if (searchParamID == curParam)
205 {
206 foundParamMappings.push_back(std::make_pair(i, curSlotIndex));
207 }
208
209 --numIDsRemaining;
210 }
211 }
212 }
213
214 return foundParamMappings;
215 }
216
221 template <class T>
222 inline void ClearMappedParameterByID(T& ioTable, AAX_CParamID inParameterID)
223 {
224 const auto paramMappings(AAX::FindParameterMappingsInPageTable(ioTable, inParameterID));
225 for (const auto& locationPair : paramMappings)
226 {
227 ioTable.ClearMappedParameter(locationPair.first, locationPair.second);
228 }
229 }
230}
231
232#endif
A generic AAX string class with similar functionality to std::string.
@ AAX_SUCCESS
Definition: AAX_Errors.h:49
Various utility definitions for AAX.
const char * AAX_CParamID
Parameter identifier.
Definition: AAX.h:362
int32_t AAX_Result
Definition: AAX.h:347
Definition: AAX_EnvironmentUtilities.h:72
std::vector< std::pair< int32_t, int32_t > > FindParameterMappingsInPageTable(const T &inTable, AAX_CParamID inParameterID)
Definition: AAX_PageTableUtilities.h:187
bool PageTableParameterNameVariationsAreEqual(const T1 &inL, const T2 &inR)
Definition: AAX_PageTableUtilities.h:75
bool PageTablesAreEqual(const T1 &inL, const T2 &inR)
Definition: AAX_PageTableUtilities.h:123
bool PageTableParameterMappingsAreEqual(const T1 &inL, const T2 &inR)
Definition: AAX_PageTableUtilities.h:37
void CopyPageTable(T &to, const T &from)
Definition: AAX_PageTableUtilities.h:133
void ClearMappedParameterByID(T &ioTable, AAX_CParamID inParameterID)
Definition: AAX_PageTableUtilities.h:222
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:57
const char * CString() const
const char * Get() const AAX_OVERRIDE