From 9daaa174958ae637e9c7d6a2cf297dfeb13fd346 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 2 Mar 2021 10:53:11 -0500 Subject: [PATCH] New library for module and plugin managers (cherry picked from commit 30e75e372e8a041fc97449858c1bbefedbde09b9; modified for Tenacity) Signed-off-by: Avery King --- libraries/CMakeLists.txt | 1 + libraries/lib-module-manager/CMakeLists.txt | 27 +++++++++++++++++++ .../lib-module-manager}/ConfigInterface.cpp | 0 .../lib-module-manager}/ConfigInterface.h | 12 ++++----- .../lib-module-manager}/ModuleManager.cpp | 13 ++++----- .../lib-module-manager}/ModuleManager.h | 19 +++++++------ .../lib-module-manager}/ModuleSettings.cpp | 3 +-- .../lib-module-manager}/ModuleSettings.h | 7 +++-- .../lib-module-manager}/PluginInterface.cpp | 0 .../lib-module-manager}/PluginInterface.h | 2 +- .../lib-module-manager}/PluginManager.cpp | 8 +++--- .../lib-module-manager}/PluginManager.h | 12 ++++----- src/CMakeLists.txt | 10 ------- src/commands/GetInfoCommand.cpp | 4 ++- src/effects/Effect.cpp | 2 +- src/effects/EffectManager.cpp | 2 +- src/effects/EffectUI.cpp | 4 +-- src/effects/VST/VSTEffect.cpp | 2 +- src/effects/audiounits/AudioUnitEffect.cpp | 4 +-- src/effects/ladspa/LadspaEffect.cpp | 5 ++-- src/effects/lv2/LV2Effect.cpp | 2 +- src/effects/lv2/LoadLV2.cpp | 2 +- src/effects/nyquist/LoadNyquist.cpp | 4 +-- src/effects/nyquist/Nyquist.cpp | 2 +- src/effects/vamp/LoadVamp.cpp | 2 +- src/menus/PluginMenus.cpp | 2 +- src/menus/TrackMenus.cpp | 2 +- src/prefs/EffectsPrefs.cpp | 2 +- src/prefs/ModulePrefs.cpp | 2 +- 29 files changed, 85 insertions(+), 72 deletions(-) create mode 100644 libraries/lib-module-manager/CMakeLists.txt rename {src => libraries/lib-module-manager}/ConfigInterface.cpp (100%) rename {src => libraries/lib-module-manager}/ConfigInterface.h (90%) rename {src => libraries/lib-module-manager}/ModuleManager.cpp (98%) rename {src => libraries/lib-module-manager}/ModuleManager.h (94%) rename {src => libraries/lib-module-manager}/ModuleSettings.cpp (97%) rename {src => libraries/lib-module-manager}/ModuleSettings.h (78%) rename {src => libraries/lib-module-manager}/PluginInterface.cpp (100%) rename {src => libraries/lib-module-manager}/PluginInterface.h (98%) rename {src => libraries/lib-module-manager}/PluginManager.cpp (99%) rename {src => libraries/lib-module-manager}/PluginManager.h (97%) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 5d30fd5596..8dfbaff631 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -9,6 +9,7 @@ set( LIBRARIES lib-ffmpeg-support lib-files lib-math + lib-module-manager lib-preferences lib-string-utils lib-registries diff --git a/libraries/lib-module-manager/CMakeLists.txt b/libraries/lib-module-manager/CMakeLists.txt new file mode 100644 index 0000000000..ced1a087aa --- /dev/null +++ b/libraries/lib-module-manager/CMakeLists.txt @@ -0,0 +1,27 @@ +#[[ +Management of dynamically loaded libraries for add-on functionality, and for +effect, generator, and analyzer plug-ins. + +Maintains persistent data in the configuration file for enablement of modules +and plug-ins, and preferred settings. +]] +set( SOURCES + ConfigInterface.cpp + ConfigInterface.h + ModuleManager.cpp + ModuleManager.h + ModuleSettings.cpp + ModuleSettings.h + PluginInterface.cpp + PluginInterface.h + PluginManager.cpp + PluginManager.h +) +set( LIBRARIES + lib-files-interface + PRIVATE + wxWidgets::wxWidgets +) +tenacity_library( lib-module-manager "${SOURCES}" "${LIBRARIES}" + "" "" +) diff --git a/src/ConfigInterface.cpp b/libraries/lib-module-manager/ConfigInterface.cpp similarity index 100% rename from src/ConfigInterface.cpp rename to libraries/lib-module-manager/ConfigInterface.cpp diff --git a/src/ConfigInterface.h b/libraries/lib-module-manager/ConfigInterface.h similarity index 90% rename from src/ConfigInterface.h rename to libraries/lib-module-manager/ConfigInterface.h index 5ccda52631..7692b6ceb8 100644 --- a/src/ConfigInterface.h +++ b/libraries/lib-module-manager/ConfigInterface.h @@ -54,13 +54,13 @@ class EffectDefinitionInterface; namespace PluginSettings { -TENACITY_DLL_API bool HasConfigGroup( EffectDefinitionInterface &ident, +MODULE_MANAGER_API bool HasConfigGroup( EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath & group); -TENACITY_DLL_API bool GetConfigSubgroups( EffectDefinitionInterface &ident, +MODULE_MANAGER_API bool GetConfigSubgroups( EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath & group, RegistryPaths & subgroups); -TENACITY_DLL_API bool GetConfigValue( EffectDefinitionInterface &ident, +MODULE_MANAGER_API bool GetConfigValue( EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath & group, const RegistryPath & key, ConfigReference var, ConfigConstReference value); @@ -89,7 +89,7 @@ inline bool GetConfig( EffectDefinitionInterface &ident, return GetConfig(ident, type, group, key, var, Value{}); } -TENACITY_DLL_API bool SetConfigValue( EffectDefinitionInterface &ident, +MODULE_MANAGER_API bool SetConfigValue( EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath & group, const RegistryPath & key, ConfigConstReference value); @@ -101,9 +101,9 @@ inline bool SetConfig( EffectDefinitionInterface &ident, return SetConfigValue(ident, type, group, key, std::cref(value)); } -TENACITY_DLL_API bool RemoveConfigSubgroup( EffectDefinitionInterface &ident, +MODULE_MANAGER_API bool RemoveConfigSubgroup( EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath & group); -TENACITY_DLL_API bool RemoveConfig( EffectDefinitionInterface &ident, +MODULE_MANAGER_API bool RemoveConfig( EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath & group, const RegistryPath & key); diff --git a/src/ModuleManager.cpp b/libraries/lib-module-manager/ModuleManager.cpp similarity index 98% rename from src/ModuleManager.cpp rename to libraries/lib-module-manager/ModuleManager.cpp index ada63fedd0..b376caf95e 100644 --- a/src/ModuleManager.cpp +++ b/libraries/lib-module-manager/ModuleManager.cpp @@ -18,17 +18,14 @@ i.e. an alternative to the usual interface, for Audacity. *//*******************************************************************/ - #include "ModuleManager.h" +#include "BasicUI.h" +#include "FileNames.h" +#include "MemoryX.h" +#include "ModuleInterface.h" #include "PluginInterface.h" -// Tenacity libraries -#include -#include -#include -#include - #include #include #include @@ -36,7 +33,7 @@ i.e. an alternative to the usual interface, for Audacity. #ifdef EXPERIMENTAL_MODULE_PREFS // Tenacity libraries -#include +#include "Prefs.h" #include "ModuleSettings.h" #endif diff --git a/src/ModuleManager.h b/libraries/lib-module-manager/ModuleManager.h similarity index 94% rename from src/ModuleManager.h rename to libraries/lib-module-manager/ModuleManager.h index 11e55cde2a..68a2a6a476 100644 --- a/src/ModuleManager.h +++ b/libraries/lib-module-manager/ModuleManager.h @@ -12,22 +12,25 @@ #ifndef __AUDACITY_MODULEMANAGER_H__ #define __AUDACITY_MODULEMANAGER_H__ -// Tenacity libraries -#include -#include -#include - +#include "Identifier.h" +#include "MemoryX.h" +#include "ModuleConstants.h" #include "PluginInterface.h" #include #include #include +#include + +#include "Identifier.h" class wxArrayString; class wxDynamicLibrary; class ComponentInterface; class ModuleInterface; class wxWindow; +using PluginID = wxString; +class TranslatableString; // // Module Manager @@ -68,7 +71,7 @@ using ModuleInterfaceHandle = std::unique_ptr< typedef std::map ModuleMap; typedef std::map> LibraryMap; -class TENACITY_DLL_API ModuleManager final +class MODULE_MANAGER_API ModuleManager final { public: @@ -143,9 +146,9 @@ class TENACITY_DLL_API ModuleManager final // ---------------------------------------------------------------------------- using ModuleMain = ModuleInterface *(*)(); -TENACITY_DLL_API +MODULE_MANAGER_API void RegisterProvider(ModuleMain rtn); -TENACITY_DLL_API +MODULE_MANAGER_API void UnregisterProvider(ModuleMain rtn); // Guarantee the registry exists before any registrations, so it will diff --git a/src/ModuleSettings.cpp b/libraries/lib-module-manager/ModuleSettings.cpp similarity index 97% rename from src/ModuleSettings.cpp rename to libraries/lib-module-manager/ModuleSettings.cpp index 588dd1f027..0dc968944e 100644 --- a/src/ModuleSettings.cpp +++ b/libraries/lib-module-manager/ModuleSettings.cpp @@ -10,8 +10,7 @@ #include "ModuleSettings.h" -// Tenacity libraries -#include +#include "Prefs.h" #include #include diff --git a/src/ModuleSettings.h b/libraries/lib-module-manager/ModuleSettings.h similarity index 78% rename from src/ModuleSettings.h rename to libraries/lib-module-manager/ModuleSettings.h index ebd08f7ae6..f266ed017e 100644 --- a/src/ModuleSettings.h +++ b/libraries/lib-module-manager/ModuleSettings.h @@ -11,8 +11,7 @@ #ifndef __AUDACITY_MODULE_SETTINGS__ #define __AUDACITY_MODULE_SETTINGS__ -// Tenacity libraries -#include +#include "Identifier.h" enum { kModuleDisabled = 0, @@ -24,8 +23,8 @@ enum { namespace ModuleSettings { -int GetModuleStatus( const FilePath &fname ); -void SetModuleStatus( const FilePath &fname, int iStatus ); +MODULE_MANAGER_API int GetModuleStatus( const FilePath &fname ); +MODULE_MANAGER_API void SetModuleStatus( const FilePath &fname, int iStatus ); } diff --git a/src/PluginInterface.cpp b/libraries/lib-module-manager/PluginInterface.cpp similarity index 100% rename from src/PluginInterface.cpp rename to libraries/lib-module-manager/PluginInterface.cpp diff --git a/src/PluginInterface.h b/libraries/lib-module-manager/PluginInterface.h similarity index 98% rename from src/PluginInterface.h rename to libraries/lib-module-manager/PluginInterface.h index 9a33987033..4727173ab9 100644 --- a/src/PluginInterface.h +++ b/libraries/lib-module-manager/PluginInterface.h @@ -80,7 +80,7 @@ using ConfigConstReference = } -class TENACITY_DLL_API PluginManagerInterface /* not final */ +class MODULE_MANAGER_API PluginManagerInterface /* not final */ { public: using ConfigurationType = PluginSettings::ConfigurationType; diff --git a/src/PluginManager.cpp b/libraries/lib-module-manager/PluginManager.cpp similarity index 99% rename from src/PluginManager.cpp rename to libraries/lib-module-manager/PluginManager.cpp index bdc87c1df7..cdba9a8749 100644 --- a/src/PluginManager.cpp +++ b/libraries/lib-module-manager/PluginManager.cpp @@ -28,12 +28,10 @@ for shared and private configs - which need to move out. #include #include "BasicUI.h" +#include "FileNames.h" +#include "MemoryX.h" #include "ModuleInterface.h" - -// Tenacity libraries -#include -#include -#include +#include "PluginInterface.h" #include "ModuleManager.h" #include "PlatformCompatibility.h" diff --git a/src/PluginManager.h b/libraries/lib-module-manager/PluginManager.h similarity index 97% rename from src/PluginManager.h rename to libraries/lib-module-manager/PluginManager.h index 6a75bf0212..4f65846de3 100644 --- a/src/PluginManager.h +++ b/libraries/lib-module-manager/PluginManager.h @@ -17,11 +17,9 @@ #include #include -// Tenacity libraries -#include -#include - +#include "EffectInterface.h" #include "PluginInterface.h" +#include "wxArrayStringEx.h" class wxArrayString; class FileConfig; @@ -43,7 +41,7 @@ typedef enum : unsigned { } PluginType; // TODO: Convert this to multiple derived classes -class TENACITY_DLL_API PluginDescriptor +class MODULE_MANAGER_API PluginDescriptor { public: PluginDescriptor(); @@ -173,7 +171,7 @@ typedef wxArrayString PluginIDs; class PluginRegistrationDialog; -class TENACITY_DLL_API PluginManager final : public PluginManagerInterface +class MODULE_MANAGER_API PluginManager final : public PluginManagerInterface { public: @@ -241,7 +239,7 @@ class TENACITY_DLL_API PluginManager final : public PluginManagerInterface //! @name iteration over plugins of certain types, supporting range-for syntax //! @{ - class Iterator { + class MODULE_MANAGER_API Iterator { public: //! Iterates all, even disabled explicit Iterator(PluginManager &manager); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41cd8f6eb9..d9e322bd06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,8 +106,6 @@ list( APPEND SOURCES Clipboard.h CommonCommandFlags.cpp CommonCommandFlags.h - ConfigInterface.cpp - ConfigInterface.h DBConnection.cpp DBConnection.h Diags.cpp @@ -158,20 +156,12 @@ list( APPEND SOURCES MixAndRender.h MixerBoard.cpp MixerBoard.h - ModuleManager.cpp - ModuleManager.h - ModuleSettings.cpp - ModuleSettings.h $<$:NoteTrack.cpp> $<$:NoteTrack.h> PitchName.cpp PitchName.h PlaybackSchedule.cpp PlaybackSchedule.h - PluginInterface.cpp - PluginInterface.h - PluginManager.cpp - PluginManager.h PluginRegistrationDialog.cpp PluginRegistrationDialog.h Printing.cpp diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index b0175aa320..e35d8dd814 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -46,10 +46,12 @@ This class now lists #include "../prefs/PrefsDialog.h" #include "../shuttle/Shuttle.h" -#include "../PluginManager.h" #include "../tracks/ui/TrackView.h" #include "../shuttle/ShuttleGui.h" +// Tenacity libraries +#include + #include #include #include diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 28e352164d..b0eeddafba 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -33,7 +33,7 @@ #include "widgets/wxWidgetsBasicUI.h" #include "../LabelTrack.h" #include "../MixAndRender.h" -#include "../PluginManager.h" +#include "PluginManager.h" #include "../ProjectAudioManager.h" #include "../ProjectSettings.h" #include "QualitySettings.h" diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index c8cb209f50..ed7a4cd33b 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -31,7 +31,7 @@ effects. #include "../shuttle/ShuttleGetDefinition.h" #include "../commands/CommandContext.h" #include "../commands/AudacityCommand.h" -#include "../PluginManager.h" +#include "PluginManager.h" /******************************************************************************* diff --git a/src/effects/EffectUI.cpp b/src/effects/EffectUI.cpp index 6715aca520..d9f50269f3 100644 --- a/src/effects/EffectUI.cpp +++ b/src/effects/EffectUI.cpp @@ -16,7 +16,7 @@ #include "ConfigInterface.h" #include "EffectManager.h" -#include "../PluginManager.h" +#include "PluginManager.h" #include "../ProjectHistory.h" #include "../ProjectWindowBase.h" #include "../TrackPanelAx.h" @@ -1202,7 +1202,7 @@ wxDialog *EffectUI::DialogFactory( wxWindow &parent, return nullptr; }; -#include "../PluginManager.h" +#include "PluginManager.h" #include "ProjectRate.h" #include "../ProjectWindow.h" #include "../SelectUtilities.h" diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 4dd44714c4..4e240ece11 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -26,7 +26,7 @@ #include "VSTEffect.h" -#include "../../ModuleManager.h" +#include "ModuleManager.h" #include "SampleCount.h" #include "../../widgets/ProgressDialog.h" diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 17f72eaa3a..06f2fc359e 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -18,12 +18,12 @@ #if USE_AUDIO_UNITS #include "AudioUnitEffect.h" -#include "../../ModuleManager.h" -#include "../../ConfigInterface.h" // Tenacity libraries #include #include +#include +#include #include #include diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index bda11d747b..6ecf7d89d6 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -25,9 +25,8 @@ effects from this one class. #include "LadspaEffect.h" // This class's header file -#include "../../ConfigInterface.h" - // Tenacity libraries +#include #include #include #include @@ -65,7 +64,7 @@ effects from this one class. #include "../../widgets/NumericTextCtrl.h" #include "../../widgets/valnum.h" #include "../../widgets/wxPanelWrapper.h" -#include "../../ModuleManager.h" +#include "ModuleManager.h" #if wxUSE_ACCESSIBILITY #include "../../widgets/WindowAccessible.h" diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index e3b84b3657..8e4eaca109 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -26,6 +26,7 @@ // Tenacity libraries #include #include +#include #include @@ -50,7 +51,6 @@ #include #include -#include "../../ConfigInterface.h" #include "../../shuttle/ShuttleGui.h" #include "../../EffectHostInterface.h" #include "../../widgets/valnum.h" diff --git a/src/effects/lv2/LoadLV2.cpp b/src/effects/lv2/LoadLV2.cpp index 2b28755d2c..e15ad0db22 100644 --- a/src/effects/lv2/LoadLV2.cpp +++ b/src/effects/lv2/LoadLV2.cpp @@ -23,7 +23,7 @@ Functions that find and load all LV2 plugins on the system. #endif #include "LoadLV2.h" -#include "../../ModuleManager.h" +#include "ModuleManager.h" #include #include diff --git a/src/effects/nyquist/LoadNyquist.cpp b/src/effects/nyquist/LoadNyquist.cpp index 0b2e31dfcb..a0f3ea8c7d 100644 --- a/src/effects/nyquist/LoadNyquist.cpp +++ b/src/effects/nyquist/LoadNyquist.cpp @@ -17,8 +17,8 @@ #include "Nyquist.h" #include "FileNames.h" -#include "../../PluginManager.h" -#include "../../ModuleManager.h" +#include "PluginManager.h" +#include "ModuleManager.h" // ============================================================================ // List of effects that ship with Audacity. These will be autoregistered. diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 3d4598fdf1..02e4ffdbaa 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -60,7 +60,7 @@ effects from this one class. #include "../../NoteTrack.h" #include "../../TimeTrack.h" #include "../../prefs/SpectrogramSettings.h" -#include "../../PluginManager.h" +#include "PluginManager.h" #include "Project.h" #include "ProjectRate.h" #include "../../shuttle/ShuttleGetDefinition.h" diff --git a/src/effects/vamp/LoadVamp.cpp b/src/effects/vamp/LoadVamp.cpp index 80c5da4d14..72c8cd35da 100644 --- a/src/effects/vamp/LoadVamp.cpp +++ b/src/effects/vamp/LoadVamp.cpp @@ -12,7 +12,7 @@ #if defined(USE_VAMP) #include "LoadVamp.h" -#include "../../ModuleManager.h" +#include "ModuleManager.h" #include diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index 01d55814ed..d9cbd821a3 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -16,7 +16,7 @@ #include "../Benchmark.h" #include "../CommonCommandFlags.h" #include "../Menus.h" -#include "../PluginManager.h" +#include "PluginManager.h" #include "../PluginRegistrationDialog.h" #include "../ProjectSettings.h" #include "../ProjectWindow.h" diff --git a/src/menus/TrackMenus.cpp b/src/menus/TrackMenus.cpp index 5948850a16..4e8826f04f 100644 --- a/src/menus/TrackMenus.cpp +++ b/src/menus/TrackMenus.cpp @@ -7,6 +7,7 @@ **********************************************************************/ // Tenacity libraries +#include #include #include #include @@ -22,7 +23,6 @@ #include "../ProjectHistory.h" #include "ProjectRate.h" #include "../ProjectSettings.h" -#include "../PluginManager.h" #include "../ProjectWindow.h" #include "../SelectUtilities.h" #include "../shuttle/ShuttleGui.h" diff --git a/src/prefs/EffectsPrefs.cpp b/src/prefs/EffectsPrefs.cpp index ce588679bb..28ab18c4da 100644 --- a/src/prefs/EffectsPrefs.cpp +++ b/src/prefs/EffectsPrefs.cpp @@ -24,10 +24,10 @@ #include // Tenacity libraries +#include #include #include -#include "../PluginManager.h" #include "../shuttle/ShuttleGui.h" EffectsPrefs::EffectsPrefs(wxWindow * parent, wxWindowID winid) diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index 0787126257..b82c60b6f7 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -22,10 +22,10 @@ with names like mod-script-pipe that add NEW features. #include // Tenacity libraries +#include #include #include "../shuttle/ShuttleGui.h" -#include "../ModuleSettings.h" ////////////////////////////////////////////////////////////////////////////////