From 37d730edfe971ddae8b4f08b365069a2e06a3624 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 8 Mar 2020 16:18:47 -0400 Subject: [PATCH] Break dependency cycle of Effect and EffectManager --- src/effects/Effect.cpp | 32 +++++++++++++++++++++++++++----- src/effects/Effect.h | 2 ++ src/effects/EffectManager.cpp | 26 +------------------------- src/effects/EffectManager.h | 1 - 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index ef97d9f4c..7db471394 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -17,7 +17,6 @@ #include "../Audacity.h" #include "Effect.h" -#include "EffectManager.h" #include "../Experimental.h" @@ -25,6 +24,7 @@ #include #include +#include #include "../AudioIO.h" #include "../LabelTrack.h" @@ -667,8 +667,7 @@ void Effect::ExportPresets() { wxString params; GetAutomationParameters(params); - EffectManager & em = EffectManager::Get(); - wxString commandId = em.GetSquashedName(GetSymbol().Internal()).GET(); + wxString commandId = GetSquashedName(GetSymbol().Internal()).GET(); params = commandId + ":" + params; auto path = FileNames::DefaultToDocumentsFolder(wxT("Presets/Path")); @@ -745,8 +744,7 @@ void Effect::ImportPresets() wxString ident = params.BeforeFirst(':'); params = params.AfterFirst(':'); - EffectManager & em = EffectManager::Get(); - wxString commandId = em.GetSquashedName(GetSymbol().Internal()).GET(); + wxString commandId = GetSquashedName(GetSymbol().Internal()).GET(); if (ident != commandId) { // effect identifiers are a sensible length! @@ -775,6 +773,30 @@ void Effect::ImportPresets() } +CommandID Effect::GetSquashedName(wxString name) +{ + // Get rid of leading and trailing white space + name.Trim(true).Trim(false); + + if (name.empty()) + { + return name; + } + + wxStringTokenizer st(name, wxT(" ")); + wxString id; + + // CamelCase the name + while (st.HasMoreTokens()) + { + wxString tok = st.GetNextToken(); + + id += tok.Left(1).MakeUpper() + tok.Mid(1).MakeLower(); + } + + return id; +} + bool Effect::HasOptions() { return false; diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 6509c4fc0..722a0b266 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -168,6 +168,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, void ExportPresets() override; void ImportPresets() override; + static CommandID GetSquashedName(wxString name); + bool HasOptions() override; void ShowOptions() override; diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index 20604feab..380e3c6d1 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -122,31 +122,7 @@ TranslatableString EffectManager::GetVendorName(const PluginID & ID) CommandID EffectManager::GetCommandIdentifier(const PluginID & ID) { wxString name = PluginManager::Get().GetSymbol(ID).Internal(); - return GetSquashedName(name); -} - -CommandID EffectManager::GetSquashedName(wxString name) -{ - // Get rid of leading and trailing white space - name.Trim(true).Trim(false); - - if (name.empty()) - { - return name; - } - - wxStringTokenizer st(name, wxT(" ")); - wxString id; - - // CamelCase the name - while (st.HasMoreTokens()) - { - wxString tok = st.GetNextToken(); - - id += tok.Left(1).MakeUpper() + tok.Mid(1).MakeLower(); - } - - return id; + return Effect::GetSquashedName(name); } TranslatableString EffectManager::GetCommandDescription(const PluginID & ID) diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index 209533d6d..ea3f3be3e 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -94,7 +94,6 @@ public: ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID); TranslatableString GetCommandName(const PluginID & ID); CommandID GetCommandIdentifier(const PluginID & ID); - CommandID GetSquashedName(wxString name); TranslatableString GetCommandDescription(const PluginID & ID); wxString GetCommandUrl(const PluginID & ID); wxString GetCommandTip(const PluginID & ID);