Audacity 3.2.0
PluginDescriptor.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 PluginDescriptor.cpp
6
7 Split from PluginManager.cpp
8
9**********************************************************************/
10
11
13//
14// Plugindescriptor
15//
17
18#include "PluginDescriptor.h"
19
20#include "EffectInterface.h"
21#include "ModuleManager.h"
22#include "XMLWriter.h"
23
24namespace
25{
26 constexpr auto AttrID = "id";
27 constexpr auto AttrPath = "path";
28 constexpr auto AttrName = "name";
29 constexpr auto AttrVendor = "vendor";
30 constexpr auto AttrVersion = "version";
31 constexpr auto AttrEffectFamily = "effect_family";
32 constexpr auto AttrProviderID = "provider";
33
34 constexpr auto AttrType = "type";
35 constexpr auto AttrEnabled = "enabled";
36 constexpr auto AttrValid = "valid";
37
38 constexpr auto AttrEffectType = "effect_type";
39 constexpr auto AttrEffectDefault = "effect_default";
40 constexpr auto AttrEffectRealtime = "effect_realtime";
41 constexpr auto AttrEffectAutomatable = "effect_automatable";
42 constexpr auto AttrEffectInteractive = "effect_interactive";
43}
44
46{
47 return mPluginType;
48}
49
51{
52 return mID;
53}
54
56{
57 return mProviderID;
58}
59
61{
62 return mPath;
63}
64
66{
67 return mSymbol;
68}
69
71{
72 return mVersion;
73}
74
75const wxString& PluginDescriptor::GetVendor() const
76{
77 return mVendor;
78}
79
81{
82 return mEnabled;
83}
84
86{
87 return mValid;
88}
89
91{
92 mPluginType = type;
93}
94
96{
97 mID = ID;
98}
99
101{
102 mProviderID = providerID;
103}
104
106{
107 mPath = path;
108}
109
111{
112 mSymbol = symbol;
113}
114
115void PluginDescriptor::SetVersion(const wxString & version)
116{
117 mVersion = version;
118}
119
120void PluginDescriptor::SetVendor(const wxString & vendor)
121{
122 mVendor = vendor;
123}
124
126{
127 mEnabled = enable;
128}
129
131{
132 mValid = valid;
133}
134
135// Effects
136
138{
139 return mEffectFamily;
140}
141
143{
144 return mEffectType;
145}
146
148{
149 return mEffectInteractive;
150}
151
153{
154 return mEffectDefault;
155}
156
158{
159 return mEffectLegacy;
160}
161
163{
165}
166
168{
169 return mEffectAutomatable;
170}
171
172void PluginDescriptor::SetEffectFamily(const wxString & family)
173{
174 mEffectFamily = family;
175}
176
178{
179 mEffectType = type;
180}
181
183{
184 mEffectInteractive = interactive;
185}
186
188{
189 mEffectDefault = dflt;
190}
191
193{
194 mEffectLegacy = legacy;
195}
196
199{
200 mEffectRealtime = realtime;
201}
202
203static constexpr auto After_3_1_string = "00";
204
206{
207 // Write a string value that converts to 0 or 1, therefore to a boolean,
208 // when read as a boolean from a config file by Audacity 3.1 or earlier
209 switch (mEffectRealtime) {
211 default:
212 // A value that earlier Audacity interprets as false
213 return "0";
215 // A different value that earlier Audacity interprets as false
216 return After_3_1_string;
218 // A value that earlier Audacity interprets as true
219 return "1";
220 }
221}
222
224{
225 // Interpret the values stored by SerializeRealtimeSupport, or by previous
226 // versions of Audacity
227 if (value == After_3_1_string)
229 else {
230 // This leaves some open-endedness for future versions of Audacity to
231 // define other string values they interpret one way, but we interpret
232 // otherwise
233 long number;
234 value.ToLong(&number);
235 mEffectRealtime = number
238 }
239}
240
242{
243 mEffectAutomatable = automatable;
244}
245
246// Importer
247
249{
250 return mImporterIdentifier;
251}
252
253void PluginDescriptor::SetImporterIdentifier(const wxString & identifier)
254{
255 mImporterIdentifier = identifier;
256}
257
259 const
260{
261 return mImporterExtensions;
262}
263
265{
266 writer.StartTag(XMLNodeName);
267 writer.WriteAttr(AttrID, GetID());
268 writer.WriteAttr(AttrType, static_cast<int>(GetPluginType()));
270 writer.WriteAttr(AttrValid, IsValid());
272 writer.WriteAttr(AttrPath, GetPath());
274 writer.WriteAttr(AttrVendor, GetVendor());
277 {
284 }
285 writer.EndTag(XMLNodeName);
286}
287
288bool PluginDescriptor::HandleXMLTag(const std::string_view& tag, const AttributesList& attrs)
289{
290 if(tag == XMLNodeName)
291 {
292 for(auto& p : attrs)
293 {
294 auto key = wxString(p.first.data(), p.first.length());
295 auto& attr = p.second;
296 if(key == AttrType)
297 SetPluginType(static_cast<PluginType>(attr.Get<int>()));
298 else if(key == AttrEffectType)
299 SetEffectType(static_cast<EffectType>(attr.Get<int>()));
300 else if(key == AttrEffectDefault)
301 SetEffectDefault(attr.Get<bool>());
302 else if(key == AttrEffectRealtime)
303 DeserializeRealtimeSupport(attr.ToWString());
304 else if(key == AttrEffectAutomatable)
305 SetEffectAutomatable(attr.Get<bool>());
306 else if(key == AttrEffectInteractive)
307 SetEffectInteractive(attr.Get<bool>());
308 else if(key == AttrEnabled)
309 SetEnabled(attr.Get<bool>());
310 else if(key == AttrValid)
311 SetValid(attr.Get<bool>());
312 else if(key == AttrID)
313 SetID(attr.ToWString());
314 else if(key == AttrPath)
315 SetPath(attr.ToWString());
316 else if(key == AttrName)
317 SetSymbol(attr.ToWString());
318 else if(key == AttrVendor)
319 SetVendor(attr.ToWString());
320 else if(key == AttrVersion)
321 SetVersion(attr.ToWString());
322 else if(key == AttrEffectFamily)
323 SetEffectFamily(attr.ToWString());
324 else if(key == AttrProviderID)
325 SetProviderID(attr.ToWString());
326 }
327 return true;
328 }
329 return false;
330}
331
333{
334 return nullptr;
335}
336
337void PluginDescriptor::HandleXMLEndTag(const std::string_view& basic_string_view)
338{
339
340}
341
343{
344 mImporterExtensions = std::move( extensions );
345}
@ Internal
Indicates internal failure from Audacity.
wxString PluginID
EffectType
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
static const AudacityProject::AttachedObjects::RegisteredFactory key
static constexpr auto After_3_1_string
PluginType
@ PluginTypeEffect
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
RealtimeSince
In which versions of Audacity was an effect realtime capable?
bool IsEffectLegacy() const
void SetEnabled(bool enable)
EffectType mEffectType
void SetEffectLegacy(bool legacy)
void SetImporterExtensions(FileExtensions extensions)
const ComponentInterfaceSymbol & GetSymbol() const
bool IsEffectRealtime() const
const FileExtensions & GetImporterExtensions() const
bool IsEffectAutomatable() const
PluginType GetPluginType() const
void SetVendor(const wxString &vendor)
void SetImporterIdentifier(const wxString &identifier)
wxString GetEffectFamily() const
void SetPath(const PluginPath &path)
bool IsEffectDefault() const
wxString SerializeRealtimeSupport() const
for serialization
void WriteXML(XMLWriter &writer) const
void SetValid(bool valid)
PluginType mPluginType
static constexpr auto XMLNodeName
bool IsEffectInteractive() const
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
const wxString & GetID() const
wxString mImporterIdentifier
bool IsEnabled() const
const wxString & GetImporterIdentifier() const
EffectDefinitionInterface::RealtimeSince mEffectRealtime
bool IsValid() const
const wxString & GetVendor() const
void SetSymbol(const ComponentInterfaceSymbol &symbol)
void SetProviderID(const PluginID &providerID)
const PluginPath & GetPath() const
void SetID(const PluginID &ID)
void SetEffectType(EffectType type)
void SetEffectFamily(const wxString &family)
EffectType GetEffectType() const
void HandleXMLEndTag(const std::string_view &) override
void SetPluginType(PluginType type)
const wxString & GetProviderID() const
FileExtensions mImporterExtensions
void SetEffectAutomatable(bool automatable)
const wxString & GetUntranslatedVersion() const
ComponentInterfaceSymbol mSymbol
void SetEffectDefault(bool dflt)
void SetEffectInteractive(bool interactive)
void SetRealtimeSupport(EffectDefinitionInterface::RealtimeSince realtime)
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
void SetVersion(const wxString &version)
void DeserializeRealtimeSupport(const wxString &value)
for deserialization
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:25
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:102
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.