1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-20 09:31:15 +02:00

Create ComponentInterface

It combines the old IdentInterface with the ParamsInterface, providing an identifier and parameters (if needed).
The main purpose of the change is to make the class hierarchy (as viewed via doxygen) much easier to follow.
This commit is contained in:
James Crook
2018-11-02 15:31:44 +00:00
parent c63dcbd3ca
commit 466e9c179e
161 changed files with 875 additions and 597 deletions

View File

@@ -2,7 +2,7 @@
Audacity: A Digital Audio Editor
IdentInterface.h
ComponentInterface.h
Leland Lucius
@@ -39,39 +39,39 @@
**********************************************************************/
#ifndef __AUDACITY_IDENTINTERFACE_H__
#define __AUDACITY_IDENTINTERFACE_H__
#ifndef __AUDACITY_COMPONENT_INTERFACE_H__
#define __AUDACITY_COMPONENT_INTERFACE_H__
#include "audacity/Types.h"
extern AUDACITY_DLL_API const wxString& GetCustomTranslation(const wxString& str1 );
/**************************************************************************//**
\brief IdentInterfaceSymbol pairs a persistent string identifier used internally
\brief ComponentInterfaceSymbol pairs a persistent string identifier used internally
with an optional, different string as msgid for lookup in a translation catalog.
\details If there is need to change a msgid in a later version of the
program, change the constructor call to supply a second argument but leave the
first the same, so that compatibility of older configuration files containing
that internal string is not broken.
********************************************************************************/
class IdentInterfaceSymbol
class ComponentInterfaceSymbol
{
public:
IdentInterfaceSymbol() = default;
ComponentInterfaceSymbol() = default;
// Allows implicit construction from a msgid re-used as an internal string
IdentInterfaceSymbol( const wxString &msgid )
ComponentInterfaceSymbol( const wxString &msgid )
: mInternal{ msgid }, mMsgid{ msgid }
{}
// Allows implicit construction from a msgid re-used as an internal string
IdentInterfaceSymbol( const wxChar *msgid )
ComponentInterfaceSymbol( const wxChar *msgid )
: mInternal{ msgid }, mMsgid{ msgid }
{}
// Two-argument version distinguishes internal from translatable string
// such as when the first squeezes spaces out
IdentInterfaceSymbol( const wxString &internal, const wxString &msgid )
ComponentInterfaceSymbol( const wxString &internal, const wxString &msgid )
: mInternal{ internal }
// Do not permit non-empty msgid with empty internal
, mMsgid{ internal.empty() ? wxString{} : msgid }
@@ -85,11 +85,11 @@ public:
bool empty() const { return mInternal.empty(); }
friend inline bool operator == (
const IdentInterfaceSymbol &a, const IdentInterfaceSymbol &b )
const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b )
{ return a.mInternal == b.mInternal; }
friend inline bool operator != (
const IdentInterfaceSymbol &a, const IdentInterfaceSymbol &b )
const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b )
{ return !( a == b ); }
private:
@@ -97,24 +97,29 @@ private:
wxString mMsgid;
};
class ShuttleParams;
/**************************************************************************//**
\brief IdentInterface provides name / vendor / version functions to identify
plugins. It is what makes a class a plug-in.
\brief ComponentInterface provides name / vendor / version functions to identify
plugins. It is what makes a class a plug-in. Additionally it provides an
optional parameter definitions function, for those components such as commands,
effects and (soon) preference pagess that define parameters.
********************************************************************************/
class AUDACITY_DLL_API IdentInterface /* not final */
class AUDACITY_DLL_API ComponentInterface /* not final */
{
public:
virtual ~IdentInterface() {};
virtual ~ComponentInterface() {};
// These should return an untranslated value
virtual wxString GetPath() = 0;
// The internal string persists in configuration files
// So config compatibility will break if it is changed across Audacity versions
virtual IdentInterfaceSymbol GetSymbol() = 0;
virtual ComponentInterfaceSymbol GetSymbol() = 0;
virtual IdentInterfaceSymbol GetVendor() = 0;
virtual ComponentInterfaceSymbol GetVendor() = 0;
virtual wxString GetVersion() = 0;
@@ -124,6 +129,9 @@ public:
// non-virtual convenience function
const wxString& GetTranslatedName();
// Parameters, if defined. false means no defined parameters.
virtual bool DefineParams( ShuttleParams & WXUNUSED(S) ){ return false;};
};
#endif // __AUDACITY_IDENTINTERFACE_H__

View File

@@ -50,7 +50,7 @@
#include <wx/intl.h>
#include <algorithm>
#include "IdentInterface.h"
#include "ComponentInterface.h"
/**
@@ -164,7 +164,7 @@ public:
using ObsoleteMap = std::pair< wxString, size_t >;
bool ReadEnum(const wxString & key, int *pi,
const IdentInterfaceSymbol choices[], size_t nChoices,
const ComponentInterfaceSymbol choices[], size_t nChoices,
const ObsoleteMap obsoletes[] = nullptr,
size_t nObsoletes = 0) const
{
@@ -174,7 +174,7 @@ public:
return false;
}
*pi = std::find( choices, choices + nChoices,
IdentInterfaceSymbol{ s, {} } ) - choices;
ComponentInterfaceSymbol{ s, {} } ) - choices;
if (*pi == (int)nChoices)
*pi = -1;
if (*pi < 0 && obsoletes) {
@@ -189,7 +189,7 @@ public:
}
bool ReadEnum(const wxString & key, int *pi, int defVal,
const IdentInterfaceSymbol choices[], size_t nChoices,
const ComponentInterfaceSymbol choices[], size_t nChoices,
const ObsoleteMap obsoletes[] = nullptr,
size_t nObsoletes = 0) const
{
@@ -201,7 +201,7 @@ public:
}
bool WriteEnum(const wxString & key, int value,
const IdentInterfaceSymbol choices[], size_t nChoices)
const ComponentInterfaceSymbol choices[], size_t nChoices)
{
if (value < 0 || value >= (int)nChoices)
{
@@ -248,7 +248,7 @@ public:
}
bool ReadAndVerify(const wxString & key, int *val, int defVal,
const IdentInterfaceSymbol choices[], size_t nChoices,
const ComponentInterfaceSymbol choices[], size_t nChoices,
const ObsoleteMap obsoletes[] = nullptr,
size_t nObsoletes = 0) const
{

View File

@@ -43,7 +43,7 @@
#define __AUDACITY_EFFECTINTERFACE_H__
#include "audacity/Types.h"
#include "audacity/IdentInterface.h"
#include "audacity/ComponentInterface.h"
#include "audacity/ConfigInterface.h"
#include "audacity/EffectAutomationParameters.h" // for command automation
@@ -59,46 +59,18 @@ typedef enum EffectType : int
EffectTypeTool,
} EffectType;
using NumericFormatId = IdentInterfaceSymbol;
class ShuttleParams;
using NumericFormatId = ComponentInterfaceSymbol;
/*************************************************************************************//**
\class ParamsInterface
\brief ParamsInterface provides a DefineParameters virtual function,
that defines the parameters of the command.
*******************************************************************************************/
class AUDACITY_DLL_API ParamsInterface /* not final */
{
public:
virtual ~ParamsInterface() {};
// returns true if implemented.
virtual bool DefineParams( ShuttleParams & WXUNUSED(S) ){ return false;};
};
/*************************************************************************************//**
\class CommandDefinitionInterface
\brief CommandDefinitionInterface is an IdentInterface (to name the command) along with a
DefineParameters virtual function, that defines the parameters of the command.
*******************************************************************************************/
class AUDACITY_DLL_API CommandDefinitionInterface /* not final */ : public IdentInterface, public ParamsInterface
{
public:
virtual ~CommandDefinitionInterface() {};
};
/*************************************************************************************//**
\class EffectDefinitionInterface
\brief EffectDefinitionInterface is a CommandDefinitionInterface that additionally tracks
\brief EffectDefinitionInterface is a ComponentInterface that additionally tracks
flag-functions for interactivity, play-preview and whether the effect can run without a GUI.
*******************************************************************************************/
class AUDACITY_DLL_API EffectDefinitionInterface /* not final */ : public IdentInterface, public ParamsInterface
class AUDACITY_DLL_API EffectDefinitionInterface /* not final */ : public ComponentInterface
{
public:
virtual ~EffectDefinitionInterface() {};
@@ -108,7 +80,7 @@ public:
// Classification determines which menu it appears in.
virtual EffectType GetClassification() { return GetType();};
virtual IdentInterfaceSymbol GetFamilyId() = 0;
virtual ComponentInterfaceSymbol GetFamilyId() = 0;
// These should move to the "EffectClientInterface" class once all
// effects have been converted.

View File

@@ -44,7 +44,7 @@
#include "audacity/Types.h"
#include "audacity/ConfigInterface.h"
#include "audacity/IdentInterface.h"
#include "audacity/ComponentInterface.h"
// ============================================================================
//
@@ -54,7 +54,7 @@
class ImporterHostInterface;
class ImporterClientInterface;
class ImporterInterface : public IdentInterface
class ImporterInterface : public ComponentInterface
{
public:
virtual ~ImporterInterface() {};

View File

@@ -44,7 +44,7 @@
#include <functional>
#include "audacity/Types.h"
#include "audacity/IdentInterface.h"
#include "audacity/ComponentInterface.h"
#include "audacity/PluginInterface.h"
// ============================================================================
@@ -64,7 +64,7 @@
///
// ============================================================================
class ModuleInterface /* not final */ : public IdentInterface
class ModuleInterface /* not final */ : public ComponentInterface
{
public:
virtual ~ModuleInterface() {};
@@ -113,7 +113,7 @@ public:
// Return value is the number of plugins found.
using RegistrationCallback =
std::function<
const PluginID &(ModuleInterface *, IdentInterface *) >;
const PluginID &(ModuleInterface *, ComponentInterface *) >;
virtual unsigned DiscoverPluginsAtPath(
const wxString & path, wxString &errMsg,
const RegistrationCallback &callback )
@@ -124,10 +124,10 @@ public:
virtual bool IsPluginValid(const wxString & path, bool bFast) = 0;
// When appropriate, CreateInstance() will be called to instantiate the plugin.
virtual IdentInterface *CreateInstance(const wxString & path) = 0;
virtual ComponentInterface *CreateInstance(const wxString & path) = 0;
// When appropriate, DeleteInstance() will be called to delete the plugin.
virtual void DeleteInstance(IdentInterface *instance) = 0;
virtual void DeleteInstance(ComponentInterface *instance) = 0;
};
// ============================================================================

View File

@@ -44,7 +44,7 @@
#include "audacity/ConfigInterface.h"
#include "audacity/EffectInterface.h"
#include "audacity/IdentInterface.h"
#include "audacity/ComponentInterface.h"
#include "audacity/ImporterInterface.h"
#include "audacity/ModuleInterface.h"
@@ -57,9 +57,9 @@ class PluginManagerInterface /* not final */
public:
static const PluginID &DefaultRegistrationCallback(
ModuleInterface *provider, IdentInterface *ident );
ModuleInterface *provider, ComponentInterface *ident );
static const PluginID &AudacityCommandRegistrationCallback(
ModuleInterface *provider, IdentInterface *ident );
ModuleInterface *provider, ComponentInterface *ident );
virtual bool IsPluginRegistered(const wxString & path) = 0;