Audacity  3.0.3
ComponentInterface.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ComponentInterface.h
6 
7  Leland Lucius
8 
9  Copyright (c) 2014, Audacity Team
10  All rights reserved.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions
14  are met:
15 
16  1. Redistributions of source code must retain the above copyright
17  notice, this list of conditions and the following disclaimer.
18 
19  2. Redistributions in binary form must reproduce the above copyright
20  notice, this list of conditions and the following disclaimer in the
21  documentation and/or other materials provided with the distribution.
22 
23  3. Neither the name of the copyright holder nor the names of its
24  contributors may be used to endorse or promote products derived from
25  this software without specific prior written permission.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  POSSIBILITY OF SUCH DAMAGE.
39 
40 **********************************************************************/
41 
42 #ifndef __AUDACITY_COMPONENT_INTERFACE_H__
43 #define __AUDACITY_COMPONENT_INTERFACE_H__
44 
45 #include "audacity/Types.h"
46 #include <wx/string.h> // member variables
47 
48 extern AUDACITY_DLL_API const wxString& GetCustomTranslation(const wxString& str1 );
49 
50 /**************************************************************************/
60 {
61 public:
63 
64  // Allows implicit construction from a msgid re-used as an internal string
66  : mInternal{ msgid.MSGID().GET(), }, mMsgid{ msgid }
67  {}
68 
69  // Allows implicit construction from an internal string re-used as a msgid
70  ComponentInterfaceSymbol( const wxString &internal )
71  : mInternal{ internal }, mMsgid{ internal, {} }
72  {}
73 
74  // Allows implicit construction from an internal string re-used as a msgid
75  ComponentInterfaceSymbol( const wxChar *msgid )
76  : mInternal{ msgid }, mMsgid{ msgid, {} }
77  {}
78 
79  // Two-argument version distinguishes internal from translatable string
80  // such as when the first squeezes spaces out
82  const TranslatableString &msgid )
83  : mInternal{ internal.GET() }
84  // Do not permit non-empty msgid with empty internal
85  , mMsgid{ internal.empty() ? TranslatableString{} : msgid }
86  {}
87 
88  const wxString &Internal() const { return mInternal; }
89  const TranslatableString &Msgid() const { return mMsgid; }
90  const TranslatableString Stripped() const { return mMsgid.Stripped(); }
91  const wxString Translation() const { return mMsgid.Translation(); }
92  const wxString StrippedTranslation() const
93  { return Stripped().Translation(); }
94 
95  bool empty() const { return mInternal.empty(); }
96 
97  friend inline bool operator == (
99  { return a.mInternal == b.mInternal; }
100 
101  friend inline bool operator != (
103  { return !( a == b ); }
104 
105 private:
106  wxString mInternal;
108 };
109 
110 
111 class ShuttleParams;
112 
113 /**************************************************************************/
120 class AUDACITY_DLL_API ComponentInterface /* not final */
121 {
122 public:
123  virtual ~ComponentInterface() {};
124 
125  // These should return an untranslated value
126  virtual PluginPath GetPath() = 0;
127 
128  // The internal string persists in configuration files
129  // So config compatibility will break if it is changed across Audacity versions
131 
132  virtual VendorSymbol GetVendor() = 0;
133 
134  virtual wxString GetVersion() = 0;
135 
136  // This returns a translated string
137  // Any verb should be present tense indicative, not imperative
139 
140  // non-virtual convenience function
141  TranslatableString GetName();
142 
143  // Parameters, if defined. false means no defined parameters.
144  virtual bool DefineParams( ShuttleParams & WXUNUSED(S) ){ return false;};
145 };
146 
147 #endif // __AUDACITY_IDENTINTERFACE_H__
TranslatableString
Definition: Types.h:290
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const wxChar *msgid)
Definition: ComponentInterface.h:75
TranslatableString::empty
bool empty() const
Definition: Types.h:329
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const TranslatableString &msgid)
Definition: ComponentInterface.h:65
ComponentInterfaceSymbol::Translation
const wxString Translation() const
Definition: ComponentInterface.h:91
ComponentInterfaceSymbol::StrippedTranslation
const wxString StrippedTranslation() const
Definition: ComponentInterface.h:92
ComponentInterface::GetSymbol
virtual ComponentInterfaceSymbol GetSymbol()=0
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const Identifier &internal, const TranslatableString &msgid)
Definition: ComponentInterface.h:81
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:61
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol()=default
ComponentInterfaceSymbol::Msgid
const TranslatableString & Msgid() const
Definition: ComponentInterface.h:89
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
ComponentInterfaceSymbol::mInternal
wxString mInternal
Definition: ComponentInterface.h:106
ComponentInterface::GetVendor
virtual VendorSymbol GetVendor()=0
Identifier
Definition: Types.h:64
ComponentInterfaceSymbol::Stripped
const TranslatableString Stripped() const
Definition: ComponentInterface.h:90
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const wxString &internal)
Definition: ComponentInterface.h:70
ComponentInterface::GetPath
virtual PluginPath GetPath()=0
PluginPath
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Types.h:257
ComponentInterface::GetDescription
virtual TranslatableString GetDescription()=0
Identifier::GET
const wxString & GET() const
Definition: Types.h:110
Types.h
GetCustomTranslation
AUDACITY_DLL_API const wxString & GetCustomTranslation(const wxString &str1)
Definition: Internat.cpp:76
ComponentInterfaceSymbol::Internal
const wxString & Internal() const
Definition: ComponentInterface.h:88
ComponentInterface
ComponentInterface provides name / vendor / version functions to identify plugins....
Definition: ComponentInterface.h:121
ComponentInterfaceSymbol::mMsgid
TranslatableString mMsgid
Definition: ComponentInterface.h:107
TranslatableString::MSGID
Identifier MSGID() const
Definition: Types.h:335
TranslatableString::Translation
wxString Translation() const
Definition: Types.h:337
ComponentInterfaceSymbol::empty
bool empty() const
Definition: ComponentInterface.h:95
ComponentInterfaceSymbol::operator==
friend bool operator==(const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b)
Definition: ComponentInterface.h:97
ComponentInterface::GetVersion
virtual wxString GetVersion()=0
TranslatableString::Stripped
TranslatableString Stripped(unsigned options=MenuCodes) const
Definition: Types.h:457
ComponentInterface::DefineParams
virtual bool DefineParams(ShuttleParams &WXUNUSED(S))
Definition: ComponentInterface.h:144
ComponentInterfaceSymbol::operator!=
friend bool operator!=(const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b)
Definition: ComponentInterface.h:101
ComponentInterface::~ComponentInterface
virtual ~ComponentInterface()
Definition: ComponentInterface.h:123