Audacity 3.2.0
PluginInterface.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 PluginInterface.h
6
7 Leland Lucius
8
9 Copyright (c) 2014, Audacity Team
10 All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
15
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of the copyright holder nor the names of its
24 contributors may be used to endorse or promote products derived from
25 this software without specific prior written permission.
26
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 POSSIBILITY OF SUCH DAMAGE.
39
40**********************************************************************/
41
42#ifndef __AUDACITY_PLUGININTERFACE_H__
43#define __AUDACITY_PLUGININTERFACE_H__
44
45#include "EffectInterface.h"
46#include "ComponentInterface.h"
47#include "Identifier.h"
48#include "PluginProvider.h"
49#include <variant>
50
51class PluginProvider;
52
53namespace PluginSettings {
54
55enum ConfigurationType : unsigned {
57};
58
60using ConfigValueTypes = std::tuple<
61 wxString
62 , int
63 , bool
64 , float
65 , double
66>;
67
69
70template<bool is_const, typename> struct ConfigReferenceGenerator;
71template<bool is_const, typename... Types>
72struct ConfigReferenceGenerator<is_const, std::tuple<Types...>> {
73 using type = std::variant< std::reference_wrapper<
74 std::conditional_t<is_const, const Types, Types> >... >;
75};
80
81}
82
84using PluginRegistryVersion = wxString;
85
86MODULE_MANAGER_API
87bool Regver_eq(
88 const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2);
89
90// Compare registry versions
91MODULE_MANAGER_API
92bool Regver_lt(
93 const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2);
94
95// Compare registry versions
96inline bool Regver_le(
97 const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2)
98{
99 return !Regver_lt(regver2, regver1);
100}
101
102class MODULE_MANAGER_API PluginManagerInterface /* not final */
103{
104public:
108
110
111 static const PluginID &DefaultRegistrationCallback(
113 static const PluginID &AudacityCommandRegistrationCallback(
115
117
122 virtual bool IsPluginRegistered(
123 const PluginPath & path,
124 const TranslatableString *pName = nullptr) = 0;
125
126 virtual const PluginID & RegisterPlugin(PluginProvider *provider) = 0;
127 virtual const PluginID & RegisterPlugin(PluginProvider *provider, EffectDefinitionInterface *effect, int type) = 0;
128
129 virtual void FindFilesInPathList(const wxString & pattern,
130 const FilePaths & pathList,
131 FilePaths & files,
132 bool directories = false) = 0;
133
134 // Many functions corresponding to those in ConfigClientInterface, but
135 // with an extra ID argument
136 virtual bool GetConfigSubgroups(ConfigurationType type, const PluginID & ID,
137 const RegistryPath & group, RegistryPaths & subgroups) = 0;
138
139 virtual bool HasConfigValue(ConfigurationType type, const PluginID & ID,
140 const RegistryPath & group, const RegistryPath & key) = 0;
141
143 virtual bool GetConfigValue(ConfigurationType type, const PluginID & ID,
144 const RegistryPath & group, const RegistryPath & key,
145 ConfigReference var, ConfigConstReference defval) = 0;
146
147 virtual bool SetConfigValue(ConfigurationType type, const PluginID & ID,
148 const RegistryPath & group, const RegistryPath & key,
149 ConfigConstReference value) = 0;
150
152 const PluginID & ID, const RegistryPath & group) = 0;
153 virtual bool RemoveConfig(ConfigurationType type, const PluginID & ID,
154 const RegistryPath & group, const RegistryPath & key) = 0;
155
157 virtual const PluginRegistryVersion &GetRegistryVersion() const = 0;
158};
159
160#endif // __AUDACITY_PLUGININTERFACE_H__
static const AudacityProject::AttachedObjects::RegisteredFactory key
wxString PluginID
Definition: EffectManager.h:30
wxString RegistryPath
Definition: Identifier.h:218
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
static CommandHandlerObject & ident(AudacityProject &project)
bool Regver_le(const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2)
MODULE_MANAGER_API bool Regver_lt(const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2)
MODULE_MANAGER_API bool Regver_eq(const PluginRegistryVersion &regver1, const PluginRegistryVersion &regver2)
wxString PluginRegistryVersion
Type of plugin registry version information.
Generalized interface for discovery of plug-ins for one protocol.
ComponentInterface provides name / vendor / version functions to identify plugins....
EffectDefinitionInterface is a ComponentInterface that adds some basic read-only information about ef...
virtual bool RemoveConfigSubgroup(ConfigurationType type, const PluginID &ID, const RegistryPath &group)=0
virtual bool GetConfigValue(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigReference var, ConfigConstReference defval)=0
virtual bool RemoveConfig(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key)=0
virtual const PluginID & RegisterPlugin(PluginProvider *provider, EffectDefinitionInterface *effect, int type)=0
virtual bool GetConfigSubgroups(ConfigurationType type, const PluginID &ID, const RegistryPath &group, RegistryPaths &subgroups)=0
PluginSettings::ConfigReference ConfigReference
virtual bool SetConfigValue(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key, ConfigConstReference value)=0
virtual void FindFilesInPathList(const wxString &pattern, const FilePaths &pathList, FilePaths &files, bool directories=false)=0
virtual const PluginID & RegisterPlugin(PluginProvider *provider)=0
virtual bool IsPluginRegistered(const PluginPath &path, const TranslatableString *pName=nullptr)=0
Was the plugin registry already populated for a path (maybe from loading the config file)?
PluginSettings::ConfigConstReference ConfigConstReference
virtual bool HasConfigValue(ConfigurationType type, const PluginID &ID, const RegistryPath &group, const RegistryPath &key)=0
virtual ~PluginManagerInterface()
virtual const PluginRegistryVersion & GetRegistryVersion() const =0
What is the plugin registry version number now in the file?
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
std::tuple< wxString, int, bool, float, double > ConfigValueTypes
Supported types for settings.
ConfigReferenceGenerator< false, ConfigValueTypes >::type ConfigReference
ConfigReferenceGenerator< true, ConfigValueTypes >::type ConfigConstReference
STL namespace.
std::variant< std::reference_wrapper< std::conditional_t< is_const, const Types, Types > >... > type
Define a reference to a variable of one of the types in ConfigValueTypes.