| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

Loading...
Searching...
No Matches
AAX_PageTableUtilities.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 * Copyright 2016-2017, 2023 Avid Technology, Inc.
4 * All rights reserved.
5 *
6 * CONFIDENTIAL: this document contains confidential information of Avid. Do
7 * not disclose to any third party. Use of the information contained in this
8 * document is subject to an Avid SDK license.
9 */
10
11#ifndef AAXLibrary_AAX_PageTableUtilities_h
12#define AAXLibrary_AAX_PageTableUtilities_h
13
14#include "AAX_CString.h"
15#include "AAX.h"
16
17 namespace AAX
18{
23 template <class T1, class T2>
24 inline bool PageTableParameterMappingsAreEqual(const T1& inL, const T2& inR)
25 {
26 AAX_Result errL = AAX_SUCCESS;
27 AAX_Result errR = AAX_SUCCESS;
28
29 int32_t numPagesL = -1;
30 int32_t numPagesR = -1;
31 errL = inL.GetNumPages(numPagesL);
32 errR = inR.GetNumPages(numPagesR);
33
34 if (errL != errR || numPagesL != numPagesR) { return false; }
35 else if (AAX_SUCCESS != errL) { return true; } // can't get page data from either table
36
37 for (int32_t i = 0; i < numPagesL; ++i)
38 {
39 int32_t numParamsL = -1;
40 int32_t numParamsR = -1;
41 errL = inL.GetNumMappedParameterIDs(i, numParamsL);
42 errR = inR.GetNumMappedParameterIDs(i, numParamsR);
43
44 if (errL != errR || numParamsL != numParamsR) { return false; }
45 else if (AAX_SUCCESS != errL) { continue; } // skip this page if equal errors were returned
46
47 for (int32_t j = 0; j < numParamsL; ++j)
48 {
49 AAX_CString paramIdentifierL;
50 AAX_CString paramIdentifierR;
51 errL = inL.GetMappedParameterID(i, j, paramIdentifierL);
52 errR = inR.GetMappedParameterID(i, j, paramIdentifierR);
53
54 if (errL != errR || paramIdentifierL != paramIdentifierR) { return false; }
55 }
56 }
57
58 return true;
59 }
60
61 template <class T1, class T2>
62 inline bool PageTableParameterNameVariationsAreEqual(const T1& inL, const T2& inR)
63 {
64 AAX_Result errL = AAX_SUCCESS;
65 AAX_Result errR = AAX_SUCCESS;
66
67 int32_t numParamIdentifiersL = -1;
68 int32_t numParamIdentifiersR = -1;
69 errL = inL.GetNumParametersWithNameVariations(numParamIdentifiersL);
70 errR = inR.GetNumParametersWithNameVariations(numParamIdentifiersR);
71
72 if (errL != errR || numParamIdentifiersL != numParamIdentifiersR) { return false; }
73 else if (AAX_SUCCESS != errL) { return true; } // can't get parameter name variation data from either table
74
75 for (int32_t i = 0; i < numParamIdentifiersL; ++i)
76 {
77 AAX_CString paramIdentifierL;
78 AAX_CString paramIdentifierR;
79 errL = inL.GetNameVariationParameterIDAtIndex(i, paramIdentifierL);
80 errL = inR.GetNameVariationParameterIDAtIndex(i, paramIdentifierR);
81
82 if (errL != errR || paramIdentifierL != paramIdentifierR) { return false; }
83 else if (AAX_SUCCESS != errL) { continue; } // skip this index if equal errors were returned
84
85 int32_t numVariationsL = -1;
86 int32_t numVariationsR = -1;
87 errL = inL.GetNumNameVariationsForParameter(paramIdentifierL.Get(), numVariationsL);
88 errL = inR.GetNumNameVariationsForParameter(paramIdentifierR.Get(), numVariationsR);
89
90 if (errL != errR || numVariationsL != numVariationsR) { return false; }
91 else if (AAX_SUCCESS != errL) { continue; } // skip this index if equal errors were returned
92
93 for (int32_t j = 0; j < numVariationsL; ++j)
94 {
95 AAX_CString nameVariationL;
96 int32_t lengthL;
97 AAX_CString nameVariationR;
98 int32_t lengthR;
99 errL = inL.GetParameterNameVariationAtIndex(paramIdentifierL.Get(), j, nameVariationL, lengthL);
100 errR = inR.GetParameterNameVariationAtIndex(paramIdentifierR.Get(), j, nameVariationR, lengthR);
101
102 if (errL != errR || lengthL != lengthR || nameVariationL != nameVariationR) { return false; }
103 }
104 }
105
106 return true;
107 }
108
109 template <class T1, class T2>
110 inline bool PageTablesAreEqual(const T1& inL, const T2& inR)
111 {
112 return (PageTableParameterMappingsAreEqual(inL, inR) && PageTableParameterNameVariationsAreEqual(inL, inR));
113 }
114
119 template <class T>
120 inline void CopyPageTable(T& to, const T& from)
121 {
122 to.Clear();
123
124 // Copy page tables
125 int32_t curPageIndex;
126 from.GetNumPages(curPageIndex);
127 while (0 < curPageIndex--)
128 {
129 to.InsertPage(0);
130
131 int32_t numIDsRemaining = 0;
132 from.GetNumMappedParameterIDs(curPageIndex, numIDsRemaining);
133 for (int32_t curSlotIndex = 0; 0 < numIDsRemaining; ++curSlotIndex) // numIDsRemaining is decremented in the loop body
134 {
135 AAX_CString curParam;
136 const AAX_Result getParamResult = from.GetMappedParameterID(curPageIndex, curSlotIndex, curParam);
137 if (AAX_SUCCESS == getParamResult)
138 {
139 to.MapParameterID(curParam.CString(), 0, curSlotIndex);
140 --numIDsRemaining;
141 }
142 }
143 }
144
145 // Copy name variations
146 int32_t numParameterIdentifiers = 0;
147 to.ClearParameterNameVariations();
148 from.GetNumParametersWithNameVariations(numParameterIdentifiers);
149 for (int32_t curParamIndex = 0; curParamIndex < numParameterIdentifiers; ++curParamIndex)
150 {
151 AAX_CString curParamIdentifier;
152 from.GetNameVariationParameterIDAtIndex(curParamIndex, curParamIdentifier);
153
154 int32_t numNameVariations = 0;
155 from.GetNumNameVariationsForParameter(curParamIdentifier.Get(), numNameVariations);
156
157 for (int32_t curNameVariationIndex = 0; curNameVariationIndex < numNameVariations; ++curNameVariationIndex)
158 {
159 int32_t curNameVariationLength;
160 AAX_CString curNameVariation;
161 from.GetParameterNameVariationAtIndex(curParamIdentifier.Get(), curNameVariationIndex, curNameVariation, curNameVariationLength);
162 to.SetParameterNameVariation(curParamIdentifier.Get(), curNameVariation, curNameVariationLength);
163 }
164 }
165 }
166
173 template <class T>
174 inline std::vector<std::pair<int32_t, int32_t> > FindParameterMappingsInPageTable(const T& inTable, AAX_CParamID inParameterID)
175 {
176 const AAX_CString searchParamID(inParameterID);
177 std::vector<std::pair<int32_t, int32_t> > foundParamMappings;
178
179 int32_t numPages = 0;
180 inTable.GetNumPages(numPages);
181 for (int32_t i = 0; i < numPages; ++i)
182 {
183 int32_t numIDsRemaining = 0;
184 inTable.GetNumMappedParameterIDs(i, numIDsRemaining);
185 for (int32_t curSlotIndex = 0; 0 < numIDsRemaining; ++curSlotIndex) // numIDs is decremented in the loop body
186 {
187 AAX_CString curParam;
188 const AAX_Result getParamResult = inTable.GetMappedParameterID(i, curSlotIndex, curParam);
189 if (AAX_SUCCESS == getParamResult)
190 {
191 if (searchParamID == curParam)
192 {
193 foundParamMappings.push_back(std::make_pair(i, curSlotIndex));
194 }
195
196 --numIDsRemaining;
197 }
198 }
199 }
200
201 return foundParamMappings;
202 }
203
208 template <class T>
209 inline void ClearMappedParameterByID(T& ioTable, AAX_CParamID inParameterID)
210 {
211 const auto paramMappings(AAX::FindParameterMappingsInPageTable(ioTable, inParameterID));
212 for (const auto& locationPair : paramMappings)
213 {
214 ioTable.ClearMappedParameter(locationPair.first, locationPair.second);
215 }
216 }
217}
218
219#endif
AAX_CString.h
A generic AAX string class with similar functionality to std::string.
AAX_SUCCESS
@ AAX_SUCCESS
Definition: AAX_Errors.h:36
AAX.h
Various utility definitions for AAX.
AAX_CParamID
const char * AAX_CParamID
Parameter identifier.
Definition: AAX.h:349
AAX_Result
int32_t AAX_Result
Definition: AAX.h:334
AAX
Definition: AAX_EnvironmentUtilities.h:59
AAX::FindParameterMappingsInPageTable
std::vector< std::pair< int32_t, int32_t > > FindParameterMappingsInPageTable(const T &inTable, AAX_CParamID inParameterID)
Definition: AAX_PageTableUtilities.h:174
AAX::PageTableParameterNameVariationsAreEqual
bool PageTableParameterNameVariationsAreEqual(const T1 &inL, const T2 &inR)
Definition: AAX_PageTableUtilities.h:62
AAX::PageTablesAreEqual
bool PageTablesAreEqual(const T1 &inL, const T2 &inR)
Definition: AAX_PageTableUtilities.h:110
AAX::PageTableParameterMappingsAreEqual
bool PageTableParameterMappingsAreEqual(const T1 &inL, const T2 &inR)
Definition: AAX_PageTableUtilities.h:24
AAX::CopyPageTable
void CopyPageTable(T &to, const T &from)
Definition: AAX_PageTableUtilities.h:120
AAX::ClearMappedParameterByID
void ClearMappedParameterByID(T &ioTable, AAX_CParamID inParameterID)
Definition: AAX_PageTableUtilities.h:209
AAX_CString
A generic AAX string class with similar functionality to std::string
Definition: AAX_CString.h:44
AAX_CString::CString
const char * CString() const
AAX_CString::Get
const char * Get() const AAX_OVERRIDE