Audacity 3.2.0
Import.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Import.h
6
7 Dominic Mazzoni
8
9**********************************************************************/
10
11#ifndef _IMPORT_
12#define _IMPORT_
13
14#include "ImportForwards.h"
15#include "Identifier.h"
16#include <vector>
17#include <wx/tokenzr.h> // for enum wxStringTokenizerMode
18
19#include "wxPanelWrapper.h" // to inherit
20#include "FileNames.h" // for FileType
21
22#include "Registry.h"
23
24class wxArrayString;
25class wxListBox;
26class AudacityProject;
27class Tags;
29class Track;
30class ImportPlugin;
33typedef bool (*progress_callback_t)( void *userData, float percent );
34
35class ExtImportItem;
36class WaveTrack;
37
38using ExtImportItems = std::vector< std::unique_ptr<ExtImportItem> >;
39using TrackHolders = std::vector< std::vector< std::shared_ptr<WaveTrack> > >;
40
42{
43 public:
51 wxArrayString filters;
52
61
65 std::vector<ImportPlugin*> filter_objects;
66
71 wxArrayString extensions;
72
77 wxArrayString mime_types;
78};
79
80class AUDACITY_DLL_API Importer {
81 struct ImporterItem;
82public:
83
84 // Objects of this type are statically constructed in files implementing
85 // subclasses of ImportPlugin
86 struct AUDACITY_DLL_API RegisteredImportPlugin final
87 : public Registry::RegisteredItem<ImporterItem>
88 {
90 const Identifier &id, // an internal string naming the plug-in
91 std::unique_ptr<ImportPlugin>,
92 const Registry::Placement &placement = { wxEmptyString, {} } );
93 };
94
95 // Objects of this type are statically constructed in files, to identify
96 // unsupported import formats; typically in a conditional compilation
98 RegisteredUnusableImportPlugin( std::unique_ptr<UnusableImportPlugin> );
99 };
100
101 Importer();
102 ~Importer();
103
104 Importer( const Importer& ) PROHIBITED;
105 Importer &operator=( Importer& ) PROHIBITED;
106
110 static Importer & Get();
111
115 bool Initialize();
116 bool Terminate();
117
123 GetFileTypes( const FileNames::FileType &extraType = {} );
124
128 static void
129 SetLastOpenType( const FileNames::FileType &type );
130
134 static void
135 SetDefaultOpenType( const FileNames::FileType &type );
136
140 static size_t
141 SelectDefaultOpenType( const FileNames::FileTypes &fileTypes );
142
147 void ReadImportItems();
148
152 void WriteImportItems();
153
159 void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod = wxTOKEN_RET_EMPTY_ALL);
160
165 ExtImportItems &GetImportItems() { return mExtImportItems; }
166
171 std::unique_ptr<ExtImportItem> CreateDefaultImportItem();
172
173 // if false, the import failed and errorMessage will be set.
174 bool Import( AudacityProject &project,
175 const FilePath &fName,
176 WaveTrackFactory *trackFactory,
177 TrackHolders &tracks,
178 Tags *tags,
179 TranslatableString &errorMessage);
180
181private:
182 struct AUDACITY_DLL_API ImporterItem final : Registry::SingleItem {
184
185 ImporterItem( const Identifier &id, std::unique_ptr<ImportPlugin> pPlugin );
187 std::unique_ptr<ImportPlugin> mpPlugin;
188 };
189
191
193 static ImportPluginList &sImportPluginList();
194 static UnusableImportPluginList &sUnusableImportPluginList();
195};
196
197//----------------------------------------------------------------------------
198// ImportStreamDialog
199//----------------------------------------------------------------------------
200
202{
203public:
204 // constructors and destructors
206 wxWindow *parent, wxWindowID id, const TranslatableString &title,
207 const wxPoint& pos = wxDefaultPosition,
208 const wxSize& size = wxDefaultSize,
209 long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
210 virtual ~ImportStreamDialog();
211
212private:
214 wxInt32 scount;
215 wxListBox *StreamList;
216
217private:
218 void OnOk( wxCommandEvent &event );
219 void OnCancel( wxCommandEvent &event );
220
221private:
222 DECLARE_EVENT_TABLE()
223};
224
225extern AUDACITY_DLL_API BoolSetting NewImportingSession;
226
227#endif
#define str(a)
AUDACITY_DLL_API BoolSetting NewImportingSession
Definition: Import.cpp:899
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
Definition: Import.h:39
std::vector< std::unique_ptr< ExtImportItem > > ExtImportItems
Definition: Import.h:38
bool(* progress_callback_t)(void *userData, float percent)
Definition: Import.h:33
std::vector< std::unique_ptr< UnusableImportPlugin > > UnusableImportPluginList
std::vector< ImportPlugin * > ImportPluginList
static const auto title
wxString FilePath
Definition: Project.h:21
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
This specialization of Setting for bool adds a Toggle method to negate the saved value.
Definition: Prefs.h:339
wxArrayString filters
Definition: Import.h:51
int divider
Definition: Import.h:60
wxArrayString extensions
Definition: Import.h:71
wxArrayString mime_types
Definition: Import.h:77
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:65
std::vector< FileType > FileTypes
Definition: FileNames.h:75
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
An ImportFileHandle for data.
Definition: ImportPlugin.h:112
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:68
void OnOk(wxCommandEvent &event)
Definition: Import.cpp:885
virtual ~ImportStreamDialog()
Definition: Import.cpp:880
ImportFileHandle * mFile
Definition: Import.h:213
wxListBox * StreamList
Definition: Import.h:215
ImportStreamDialog(ImportFileHandle *_mFile, wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
Definition: Import.cpp:846
void OnCancel(wxCommandEvent &event)
Definition: Import.cpp:894
wxInt32 scount
Definition: Import.h:214
Class which actually imports the auido, using functions defined in ImportPCM.cpp, ImportMP3_*....
Definition: Import.h:80
static Importer mInstance
Definition: Import.h:190
ExtImportItems mExtImportItems
Definition: Import.h:192
Importer(const Importer &) PROHIBITED
ExtImportItems & GetImportItems()
Definition: Import.h:165
Importer & operator=(Importer &) PROHIBITED
Generates classes whose instances register items at construction.
Definition: Registry.h:242
ID3 Tags (for MP3)
Definition: Tags.h:73
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:162
Holds a msgid for the translation catalog; may also bind format arguments.
Used in place of a real plug in for plug ins that have not been compiled or are not available in this...
Definition: ImportPlugin.h:170
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:561
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
Definition: Menus.h:35
std::unique_ptr< ImportPlugin > mpPlugin
Definition: Import.h:187
Common abstract base class for items that group other items.
Definition: Registry.h:130