Audacity  2.2.2
Public Member Functions | 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:
ModuleInterface IdentInterface

Public Member Functions

 BuiltinEffectsModule (ModuleManagerInterface *moduleManager, const wxString *path)
 
virtual ~BuiltinEffectsModule ()
 
wxString GetPath () override
 
IdentInterfaceSymbol GetSymbol () override
 
IdentInterfaceSymbol GetVendor () override
 
wxString GetVersion () override
 
wxString GetDescription () override
 
bool Initialize () override
 
void Terminate () override
 
wxArrayString FileExtensions () override
 
wxString InstallPath () override
 
bool AutoRegisterPlugins (PluginManagerInterface &pm) override
 
wxArrayString FindPluginPaths (PluginManagerInterface &pm) override
 
unsigned DiscoverPluginsAtPath (const wxString &path, wxString &errMsg, const RegistrationCallback &callback) override
 
bool IsPluginValid (const wxString &path, bool bFast) override
 
IdentInterfaceCreateInstance (const wxString &path) override
 
void DeleteInstance (IdentInterface *instance) override
 
- Public Member Functions inherited from ModuleInterface
virtual ~ModuleInterface ()
 
- Public Member Functions inherited from IdentInterface
virtual ~IdentInterface ()
 
const wxString & GetTranslatedName ()
 

Private Member Functions

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

Private Attributes

ModuleManagerInterfacemModMan
 
wxString mPath
 
wxArrayString mNames
 

Additional Inherited Members

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

Detailed Description

Internal module to auto register all built in effects.

Definition at line 24 of file LoadEffects.h.

Constructor & Destructor Documentation

BuiltinEffectsModule::BuiltinEffectsModule ( ModuleManagerInterface moduleManager,
const wxString *  path 
)

Definition at line 220 of file LoadEffects.cpp.

References mModMan, and mPath.

222 {
223  mModMan = moduleManager;
224  if (path)
225  {
226  mPath = *path;
227  }
228 }
ModuleManagerInterface * mModMan
Definition: LoadEffects.h:64
BuiltinEffectsModule::~BuiltinEffectsModule ( )
virtual

Definition at line 230 of file LoadEffects.cpp.

References mPath.

231 {
232  mPath.Clear();
233 }

Member Function Documentation

bool BuiltinEffectsModule::AutoRegisterPlugins ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 292 of file LoadEffects.cpp.

References BUILTIN_EFFECT_PREFIX, PluginManagerInterface::DefaultRegistrationCallback(), DiscoverPluginsAtPath(), PluginManagerInterface::IsPluginRegistered(), kEffectNames(), name, and names().

293 {
294  wxString ignoredErrMsg;
295  const auto &names = kEffectNames();
296  for (const auto &name : names)
297  {
298  wxString path(wxString(BUILTIN_EFFECT_PREFIX) + name);
299 
300  if (!pm.IsPluginRegistered(path))
301  {
302  // No checking of error ?
303  DiscoverPluginsAtPath(path, ignoredErrMsg,
305  }
306  }
307 
308  // We still want to be called during the normal registration process
309  return false;
310 }
static wxArrayString names()
Definition: Tags.cpp:697
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:47
static const PluginID & DefaultRegistrationCallback(ModuleInterface *provider, IdentInterface *ident)
virtual bool IsPluginRegistered(const wxString &path)=0
static const std::vector< wxString > kEffectNames()
const wxChar * name
Definition: Distortion.cpp:94
unsigned DiscoverPluginsAtPath(const wxString &path, wxString &errMsg, const RegistrationCallback &callback) override
IdentInterface * BuiltinEffectsModule::CreateInstance ( const wxString &  path)
overridevirtual

Implements ModuleInterface.

Definition at line 341 of file LoadEffects.cpp.

References Instantiate().

342 {
343  // Acquires a resource for the application.
344  // Safety of this depends on complementary calls to DeleteInstance on the module manager side.
345  return Instantiate(path).release();
346 }
std::unique_ptr< Effect > Instantiate(const wxString &path)
void BuiltinEffectsModule::DeleteInstance ( IdentInterface instance)
overridevirtual

Implements ModuleInterface.

Definition at line 348 of file LoadEffects.cpp.

349 {
350  // Releases the resource.
351  std::unique_ptr < Effect > {
352  dynamic_cast<Effect *>(instance)
353  };
354 }
Base class for many of the effects in Audacity.
Definition: Effect.h:62
unsigned BuiltinEffectsModule::DiscoverPluginsAtPath ( const wxString &  path,
wxString &  errMsg,
const RegistrationCallback callback 
)
overridevirtual

Implements ModuleInterface.

Definition at line 317 of file LoadEffects.cpp.

References _(), and Instantiate().

Referenced by AutoRegisterPlugins().

320 {
321  errMsg.clear();
322  auto effect = Instantiate(path);
323  if (effect)
324  {
325  if (callback)
326  callback(this, effect.get());
327  return 1;
328  }
329 
330  errMsg = _("Unknown built-in effect name");
331  return 0;
332 }
std::unique_ptr< Effect > Instantiate(const wxString &path)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxArrayString BuiltinEffectsModule::FileExtensions ( )
inlineoverridevirtual

Implements ModuleInterface.

Definition at line 43 of file LoadEffects.h.

43 { return {}; }
wxArrayString BuiltinEffectsModule::FindPluginPaths ( PluginManagerInterface pm)
overridevirtual

Implements ModuleInterface.

Definition at line 312 of file LoadEffects.cpp.

References mNames.

313 {
314  return mNames;
315 }
wxArrayString mNames
Definition: LoadEffects.h:67
wxString BuiltinEffectsModule::GetDescription ( )
overridevirtual

Implements IdentInterface.

Definition at line 260 of file LoadEffects.cpp.

References _().

261 {
262  return _("Provides builtin effects to Audacity");
263 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxString BuiltinEffectsModule::GetPath ( )
overridevirtual

Implements IdentInterface.

Definition at line 239 of file LoadEffects.cpp.

References mPath.

240 {
241  return mPath;
242 }
IdentInterfaceSymbol BuiltinEffectsModule::GetSymbol ( )
overridevirtual

Implements IdentInterface.

Definition at line 244 of file LoadEffects.cpp.

References XO.

245 {
246  return XO("Builtin Effects");
247 }
#define XO(s)
Definition: Internat.h:33
IdentInterfaceSymbol BuiltinEffectsModule::GetVendor ( )
overridevirtual

Implements IdentInterface.

Definition at line 249 of file LoadEffects.cpp.

References XO.

250 {
251  return XO("The Audacity Team");
252 }
#define XO(s)
Definition: Internat.h:33
wxString BuiltinEffectsModule::GetVersion ( )
overridevirtual

Implements IdentInterface.

Definition at line 254 of file LoadEffects.cpp.

References AUDACITY_VERSION_STRING.

255 {
256  // This "may" be different if this were to be maintained as a separate DLL
258 }
#define AUDACITY_VERSION_STRING
Definition: Audacity.h:81
bool BuiltinEffectsModule::Initialize ( )
overridevirtual

Implements ModuleInterface.

Definition at line 269 of file LoadEffects.cpp.

References BUILTIN_EFFECT_PREFIX, kEffectNames(), kExcludedNames(), mNames, name, and names().

270 {
271  const auto &names = kEffectNames();
272  for (const auto &name : names)
273  {
274  mNames.Add(wxString(BUILTIN_EFFECT_PREFIX) + name);
275  }
276 
277  const auto &excluded = kExcludedNames();
278  for (const auto &name : excluded)
279  {
280  mNames.Add(wxString(BUILTIN_EFFECT_PREFIX) + name);
281  }
282 
283  return true;
284 }
static wxArrayString names()
Definition: Tags.cpp:697
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:47
static const std::vector< wxString > kExcludedNames()
wxArrayString mNames
Definition: LoadEffects.h:67
static const std::vector< wxString > kEffectNames()
const wxChar * name
Definition: Distortion.cpp:94
wxString BuiltinEffectsModule::InstallPath ( )
inlineoverridevirtual

Implements ModuleInterface.

Definition at line 44 of file LoadEffects.h.

44 { return {}; }
std::unique_ptr< Effect > BuiltinEffectsModule::Instantiate ( const wxString &  path)
private

Definition at line 360 of file LoadEffects.cpp.

References BUILTIN_EFFECT_PREFIX, EFFECT_LIST, EXCLUDE_LIST, and mNames.

Referenced by CreateInstance(), and DiscoverPluginsAtPath().

361 {
362  wxASSERT(path.StartsWith(BUILTIN_EFFECT_PREFIX));
363  wxASSERT(mNames.Index(path) != wxNOT_FOUND);
364 
365  switch (mNames.Index(path))
366  {
367  EFFECT_LIST;
368  EXCLUDE_LIST;
369  }
370 
371  return nullptr;
372 }
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:47
#define EFFECT_LIST
wxArrayString mNames
Definition: LoadEffects.h:67
#define EXCLUDE_LIST
bool BuiltinEffectsModule::IsPluginValid ( const wxString &  path,
bool  bFast 
)
overridevirtual

Implements ModuleInterface.

Definition at line 334 of file LoadEffects.cpp.

References mNames.

335 {
336  // bFast is unused as checking in the list is fast.
337  static_cast<void>(bFast);
338  return mNames.Index(path) != wxNOT_FOUND;
339 }
wxArrayString mNames
Definition: LoadEffects.h:67
void BuiltinEffectsModule::Terminate ( )
overridevirtual

Implements ModuleInterface.

Definition at line 286 of file LoadEffects.cpp.

287 {
288  // Nothing to do here
289  return;
290 }

Member Data Documentation

ModuleManagerInterface* BuiltinEffectsModule::mModMan
private

Definition at line 64 of file LoadEffects.h.

Referenced by BuiltinEffectsModule().

wxArrayString BuiltinEffectsModule::mNames
private

Definition at line 67 of file LoadEffects.h.

Referenced by FindPluginPaths(), Initialize(), Instantiate(), and IsPluginValid().

wxString BuiltinEffectsModule::mPath
private

Definition at line 65 of file LoadEffects.h.

Referenced by BuiltinEffectsModule(), GetPath(), and ~BuiltinEffectsModule().


The documentation for this class was generated from the following files: