Audacity  3.0.3
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
BuiltinEffectsModule Class Referencefinal

Internal module to auto register all built in effects.
More...

#include <LoadEffects.h>

Inheritance diagram for BuiltinEffectsModule:
[legend]
Collaboration diagram for BuiltinEffectsModule:
[legend]

Classes

struct  Entry
 
struct  Registration
 

Public Types

using Factory = std::function< std::unique_ptr< Effect >() >
 
- Public Types inherited from ModuleInterface
using RegistrationCallback = std::function< const PluginID &(ModuleInterface *, ComponentInterface *) >
 

Public Member Functions

 BuiltinEffectsModule ()
 
virtual ~BuiltinEffectsModule ()
 
PluginPath GetPath () override
 
ComponentInterfaceSymbol GetSymbol () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
bool Initialize () override
 
void Terminate () override
 
EffectFamilySymbol GetOptionalFamilySymbol () override
 
const FileExtensionsGetFileExtensions () override
 
FilePath InstallPath () override
 
bool AutoRegisterPlugins (PluginManagerInterface &pm) override
 
PluginPaths FindPluginPaths (PluginManagerInterface &pm) override
 
unsigned DiscoverPluginsAtPath (const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
 
bool IsPluginValid (const PluginPath &path, bool bFast) override
 
std::unique_ptr< ComponentInterfaceCreateInstance (const PluginPath &path) override
 
- Public Member Functions inherited from ModuleInterface
virtual ~ModuleInterface ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 

Private Types

using EffectHash = std::unordered_map< wxString, const Entry * >
 

Private Member Functions

std::unique_ptr< EffectInstantiate (const PluginPath &path)
 

Static Private Member Functions

static void DoRegistration (const ComponentInterfaceSymbol &name, const Factory &factory, bool excluded)
 

Private Attributes

EffectHash mEffects
 

Detailed Description

Internal module to auto register all built in effects.

Definition at line 29 of file LoadEffects.h.

Member Typedef Documentation

◆ EffectHash

using BuiltinEffectsModule::EffectHash = std::unordered_map< wxString, const Entry* >
private

Definition at line 86 of file LoadEffects.h.

◆ Factory

using BuiltinEffectsModule::Factory = std::function< std::unique_ptr<Effect> () >

Definition at line 35 of file LoadEffects.h.

Constructor & Destructor Documentation

◆ BuiltinEffectsModule()

BuiltinEffectsModule::BuiltinEffectsModule ( )

Definition at line 71 of file LoadEffects.cpp.

72 {
73 }

◆ ~BuiltinEffectsModule()

BuiltinEffectsModule::~BuiltinEffectsModule ( )
virtual

Definition at line 75 of file LoadEffects.cpp.

76 {
77 }

Member Function Documentation

◆ AutoRegisterPlugins()

bool BuiltinEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 142 of file LoadEffects.cpp.

143 {
144  TranslatableString ignoredErrMsg;
145  for (const auto &pair : mEffects)
146  {
147  const auto &path = pair.first;
148  if (!pm.IsPluginRegistered(path, &pair.second->name.Msgid()))
149  {
150  if ( pair.second->excluded )
151  continue;
152  // No checking of error ?
153  DiscoverPluginsAtPath(path, ignoredErrMsg,
155  }
156  }
157 
158  // We still want to be called during the normal registration process
159  return false;
160 }

References PluginManagerInterface::DefaultRegistrationCallback(), DiscoverPluginsAtPath(), PluginManagerInterface::IsPluginRegistered(), and mEffects.

Here is the call graph for this function:

◆ CreateInstance()

std::unique_ptr< ComponentInterface > BuiltinEffectsModule::CreateInstance ( const PluginPath path)
overridevirtual

Implements ModuleInterface.

Definition at line 195 of file LoadEffects.cpp.

196 {
197  // Acquires a resource for the application.
198  return Instantiate(path);
199 }

References Instantiate().

Here is the call graph for this function:

◆ DiscoverPluginsAtPath()

unsigned BuiltinEffectsModule::DiscoverPluginsAtPath ( const PluginPath path,
TranslatableString errMsg,
const RegistrationCallback callback 
)
overridevirtual

Implements ModuleInterface.

Definition at line 170 of file LoadEffects.cpp.

173 {
174  errMsg = {};
175  auto effect = Instantiate(path);
176  if (effect)
177  {
178  if (callback)
179  callback(this, effect.get());
180  return 1;
181  }
182 
183  errMsg = XO("Unknown built-in effect name");
184  return 0;
185 }

References Instantiate(), and XO.

Referenced by AutoRegisterPlugins().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoRegistration()

void BuiltinEffectsModule::DoRegistration ( const ComponentInterfaceSymbol name,
const Factory factory,
bool  excluded 
)
staticprivate

Definition at line 37 of file LoadEffects.cpp.

39 {
40  wxASSERT( !sInitialized );
41  Entry::Registry().emplace_back( Entry{ name, factory, excluded } );
42 }

References factory, name, BuiltinEffectsModule::Entry::Registry(), and sInitialized.

Here is the call graph for this function:

◆ FindPluginPaths()

PluginPaths BuiltinEffectsModule::FindPluginPaths ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 162 of file LoadEffects.cpp.

163 {
165  for ( const auto &pair : mEffects )
166  names.push_back( pair.first );
167  return names;
168 }

References mEffects, and names.

◆ GetDescription()

TranslatableString BuiltinEffectsModule::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 104 of file LoadEffects.cpp.

105 {
106  return XO("Provides builtin effects to Audacity");
107 }

References XO.

◆ GetFileExtensions()

const FileExtensions & BuiltinEffectsModule::GetFileExtensions ( )
overridevirtual

Implements ModuleInterface.

Definition at line 136 of file LoadEffects.cpp.

137 {
138  static FileExtensions empty;
139  return empty;
140 }

◆ GetOptionalFamilySymbol()

EffectFamilySymbol BuiltinEffectsModule::GetOptionalFamilySymbol ( )
overridevirtual

Implements ModuleInterface.

Definition at line 129 of file LoadEffects.cpp.

130 {
131  // Returns empty, because there should not be an option in Preferences to
132  // disable the built-in effects.
133  return {};
134 }

◆ GetPath()

PluginPath BuiltinEffectsModule::GetPath ( )
overridevirtual

Implements ComponentInterface.

Definition at line 83 of file LoadEffects.cpp.

84 {
85  return {};
86 }

◆ GetSymbol()

ComponentInterfaceSymbol BuiltinEffectsModule::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 88 of file LoadEffects.cpp.

89 {
90  return XO("Builtin Effects");
91 }

References XO.

◆ GetVendor()

VendorSymbol BuiltinEffectsModule::GetVendor ( )
overridevirtual

Implements ComponentInterface.

Definition at line 93 of file LoadEffects.cpp.

94 {
95  return XO("The Audacity Team");
96 }

References XO.

◆ GetVersion()

wxString BuiltinEffectsModule::GetVersion ( )
overridevirtual

Implements ComponentInterface.

Definition at line 98 of file LoadEffects.cpp.

99 {
100  // This "may" be different if this were to be maintained as a separate DLL
101  return AUDACITY_VERSION_STRING;
102 }

◆ Initialize()

bool BuiltinEffectsModule::Initialize ( )
overridevirtual

Implements ModuleInterface.

Definition at line 113 of file LoadEffects.cpp.

114 {
115  for ( const auto &entry : Entry::Registry() ) {
116  auto path = wxString(BUILTIN_EFFECT_PREFIX) + entry.name.Internal();
117  mEffects[ path ] = &entry;
118  }
119  sInitialized = true;
120  return true;
121 }

References BUILTIN_EFFECT_PREFIX, entry, mEffects, BuiltinEffectsModule::Entry::Registry(), and sInitialized.

Here is the call graph for this function:

◆ InstallPath()

FilePath BuiltinEffectsModule::InstallPath ( )
inlineoverridevirtual

Implements ModuleInterface.

Definition at line 61 of file LoadEffects.h.

61 { return {}; }

◆ Instantiate()

std::unique_ptr< Effect > BuiltinEffectsModule::Instantiate ( const PluginPath path)
private

Definition at line 205 of file LoadEffects.cpp.

206 {
207  wxASSERT(path.StartsWith(BUILTIN_EFFECT_PREFIX));
208  auto iter = mEffects.find( path );
209  if ( iter != mEffects.end() )
210  return iter->second->factory();
211 
212  wxASSERT( false );
213  return nullptr;
214 }

References BUILTIN_EFFECT_PREFIX, and mEffects.

Referenced by CreateInstance(), and DiscoverPluginsAtPath().

Here is the caller graph for this function:

◆ IsPluginValid()

bool BuiltinEffectsModule::IsPluginValid ( const PluginPath path,
bool  bFast 
)
overridevirtual

Implements ModuleInterface.

Definition at line 187 of file LoadEffects.cpp.

188 {
189  // bFast is unused as checking in the list is fast.
190  static_cast<void>(bFast);
191  return mEffects.find( path ) != mEffects.end();
192 }

References mEffects.

◆ Terminate()

void BuiltinEffectsModule::Terminate ( )
overridevirtual

Implements ModuleInterface.

Definition at line 123 of file LoadEffects.cpp.

124 {
125  // Nothing to do here
126  return;
127 }

Member Data Documentation

◆ mEffects

EffectHash BuiltinEffectsModule::mEffects
private

The documentation for this class was generated from the following files:
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
entry
static ProjectFileIORegistry::WriterEntry entry
Definition: ProjectSettings.cpp:193
BUILTIN_EFFECT_PREFIX
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:43
XO
#define XO(s)
Definition: Internat.h:31
sInitialized
static bool sInitialized
Definition: LoadEffects.cpp:22
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
Entry
Definition: EditToolBar.cpp:225
PluginManagerInterface::IsPluginRegistered
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)?
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:806
BuiltinEffectsModule::Instantiate
std::unique_ptr< Effect > Instantiate(const PluginPath &path)
Definition: LoadEffects.cpp:205
BuiltinEffectsModule::DiscoverPluginsAtPath
unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
Definition: LoadEffects.cpp:170
name
const TranslatableString name
Definition: Distortion.cpp:98
PluginManagerInterface::DefaultRegistrationCallback
static const PluginID & DefaultRegistrationCallback(ModuleInterface *provider, ComponentInterface *ident)
Definition: PluginManager.cpp:329
PluginPaths
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
names
static TranslatableStrings names
Definition: Tags.cpp:744
BuiltinEffectsModule::Entry::Registry
static Entries & Registry()
Definition: LoadEffects.cpp:30
BuiltinEffectsModule::mEffects
EffectHash mEffects
Definition: LoadEffects.h:87