Audacity 3.2.0
LoadCommands.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 LoadCommands.h
6
7 Dominic Mazzoni
8 James Crook
9
10**********************************************************************/
11
12#ifndef __AUDACITY_LOAD_COMMANDS__
13#define __AUDACITY_LOAD_COMMANDS__
14
15#include "PluginProvider.h"
16
17#include <functional>
18#include <memory>
19#include <unordered_map>
20#include <memory>
21
22class AudacityCommand;
23
25//
26// BuiltinCommandsModule
27//
29
30class AUDACITY_DLL_API BuiltinCommandsModule final : public PluginProvider
31{
32public:
34 virtual ~BuiltinCommandsModule();
35
36 using Factory = std::function< std::unique_ptr<AudacityCommand> () >;
37
38 // Typically you make a static object of this type in the .cpp file that
39 // also implements the Command subclass.
40 template< typename Subclass >
41 struct Registration final { Registration() {
42 DoRegistration(
43 Subclass::Symbol, []{ return std::make_unique< Subclass >(); } );
44 } };
45
46 // ComponentInterface implementation
47
48 PluginPath GetPath() const override;
49 ComponentInterfaceSymbol GetSymbol() const override;
50 VendorSymbol GetVendor() const override;
51 wxString GetVersion() const override;
52 TranslatableString GetDescription() const override;
53
54 // PluginProvider implementation
55
56 bool Initialize() override;
57 void Terminate() override;
59
60 const FileExtensions &GetFileExtensions() override;
61 FilePath InstallPath() override { return {}; }
62
65 unsigned DiscoverPluginsAtPath(
66 const PluginPath & path, TranslatableString &errMsg,
67 const RegistrationCallback &callback)
68 override;
69
70 bool CheckPluginExist(const PluginPath& path) const override;
71
72 std::unique_ptr<ComponentInterface>
73 LoadPlugin(const PluginPath & path) override;
74
75private:
76 // BuiltinEffectModule implementation
77
78 std::unique_ptr<AudacityCommand> Instantiate(const PluginPath & path);
79
80private:
81 struct Entry;
82
83 static void DoRegistration(
84 const ComponentInterfaceSymbol &name, const Factory &factory );
85
86 using CommandHash = std::unordered_map< wxString, const Entry* > ;
88};
89
90#endif
static RegisteredToolbarFactory factory
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
Generalized interface for discovery of plug-ins for one protocol.
wxString FilePath
Definition: Project.h:21
wxString name
Definition: TagsEditor.cpp:166
Base class for command in Audacity.
Internal module to auto register all built in commands. It is closely modelled on BuiltinEffectsModul...
Definition: LoadCommands.h:31
std::function< std::unique_ptr< AudacityCommand >() > Factory
Definition: LoadCommands.h:36
CommandHash mCommands
Definition: LoadCommands.h:87
std::unordered_map< wxString, const Entry * > CommandHash
Definition: LoadCommands.h:86
FilePath InstallPath() override
Where plug-in files should be copied to install them.
Definition: LoadCommands.h:61
virtual wxString GetVersion() const =0
virtual PluginPath GetPath() const =0
virtual VendorSymbol GetVendor() const =0
virtual ComponentInterfaceSymbol GetSymbol() const =0
virtual TranslatableString GetDescription() const =0
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual EffectFamilySymbol GetOptionalFamilySymbol()=0
A symbol identifying the family of plug-ins provided by this.
virtual unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback)=0
virtual void Terminate()=0
Called just prior to deletion to allow releasing any resources.
virtual PluginPaths FindModulePaths(PluginManagerInterface &pluginManager)=0
virtual std::unique_ptr< ComponentInterface > LoadPlugin(const PluginPath &path)=0
Load the plug-in at a path reported by DiscoverPluginsAtPath.
virtual void AutoRegisterPlugins(PluginManagerInterface &pluginManager)=0
Called so that a provider of a static set of plug-ins can register them.
virtual const FileExtensions & GetFileExtensions()=0
File types associated with this protocol.
virtual bool Initialize()=0
Called immediately after creation. Let provider initialize.
virtual bool CheckPluginExist(const PluginPath &path) const =0
Performs plugin/module existence check, still plugin may fail to load. Implementation should avoid lo...
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.