Audacity  3.0.3
LoadEffects.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  LoadEffects.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_LOAD_EFFECTS__
12 #define __AUDACITY_LOAD_EFFECTS__
13 
14 #include "ModuleInterface.h"
15 
16 #include <functional>
17 #include <memory>
18 #include <unordered_map>
19 #include <memory>
20 
21 class Effect;
22 
24 //
25 // BuiltinEffectsModule
26 //
28 
29 class AUDACITY_DLL_API BuiltinEffectsModule final : public ModuleInterface
30 {
31 public:
33  virtual ~BuiltinEffectsModule();
34 
35  using Factory = std::function< std::unique_ptr<Effect> () >;
36 
37  // Typically you make a static object of this type in the .cpp file that
38  // also implements the Effect subclass.
39  template< typename Subclass >
40  struct Registration final { Registration( bool excluded = false ) {
41  DoRegistration(
42  Subclass::Symbol, []{ return std::make_unique< Subclass >(); },
43  excluded );
44  } };
45 
46  // ComponentInterface implementation
47 
48  PluginPath GetPath() override;
50  VendorSymbol GetVendor() override;
51  wxString GetVersion() override;
53 
54  // ModuleInterface implementation
55 
56  bool Initialize() override;
57  void Terminate() override;
59 
60  const FileExtensions &GetFileExtensions() override;
61  FilePath InstallPath() override { return {}; }
62 
63  bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
65  unsigned DiscoverPluginsAtPath(
66  const PluginPath & path, TranslatableString &errMsg,
67  const RegistrationCallback &callback)
68  override;
69 
70  bool IsPluginValid(const PluginPath & path, bool bFast) override;
71 
72  std::unique_ptr<ComponentInterface>
73  CreateInstance(const PluginPath & path) override;
74 
75 private:
76  // BuiltinEffectModule implementation
77 
78  std::unique_ptr<Effect> Instantiate(const PluginPath & path);
79 
80 private:
81  static void DoRegistration(
82  const ComponentInterfaceSymbol &name, const Factory &factory,
83  bool excluded );
84 
85  struct Entry;
86  using EffectHash = std::unordered_map< wxString, const Entry* > ;
88 };
89 
90 #endif
ModuleInterface::AutoRegisterPlugins
virtual bool AutoRegisterPlugins(PluginManagerInterface &pluginManager)=0
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ComponentInterface::GetSymbol
virtual ComponentInterfaceSymbol GetSymbol()=0
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:72
PluginPath
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
ModuleInterface.h
BuiltinEffectsModule
Internal module to auto register all built in effects.
Definition: LoadEffects.h:30
BuiltinEffectsModule::InstallPath
FilePath InstallPath() override
Definition: LoadEffects.h:61
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
Entry
Definition: EditToolBar.cpp:225
ComponentInterface::GetVendor
virtual VendorSymbol GetVendor()=0
ModuleInterface
Definition: ModuleInterface.h:70
ModuleInterface::FindPluginPaths
virtual PluginPaths FindPluginPaths(PluginManagerInterface &pluginManager)=0
ModuleInterface::CreateInstance
virtual std::unique_ptr< ComponentInterface > CreateInstance(const PluginPath &path)=0
FilePath
wxString FilePath
Definition: Project.h:20
PluginManagerInterface
Definition: PluginInterface.h:55
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:817
ModuleInterface::Initialize
virtual bool Initialize()=0
ComponentInterface::GetPath
virtual PluginPath GetPath()=0
name
const TranslatableString name
Definition: Distortion.cpp:98
ComponentInterface::GetDescription
virtual TranslatableString GetDescription()=0
PluginPaths
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
BuiltinEffectsModule::Registration::Registration
Registration(bool excluded=false)
Definition: LoadEffects.h:40
BuiltinEffectsModule::Registration
Definition: LoadEffects.h:40
BuiltinEffectsModule::Factory
std::function< std::unique_ptr< Effect >() > Factory
Definition: LoadEffects.h:35
ModuleInterface::GetOptionalFamilySymbol
virtual EffectFamilySymbol GetOptionalFamilySymbol()=0
BuiltinEffectsModule::EffectHash
std::unordered_map< wxString, const Entry * > EffectHash
Definition: LoadEffects.h:86
ModuleInterface::DiscoverPluginsAtPath
virtual unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback)=0
ComponentInterface::GetVersion
virtual wxString GetVersion()=0
BuiltinEffectsModule::mEffects
EffectHash mEffects
Definition: LoadEffects.h:87
ModuleInterface::Terminate
virtual void Terminate()=0
ModuleInterface::GetFileExtensions
virtual const FileExtensions & GetFileExtensions()=0
ModuleInterface::IsPluginValid
virtual bool IsPluginValid(const PluginPath &path, bool bFast)=0