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 "../widgets/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 {
81public:
82
83 // Objects of this type are statically constructed in files implementing
84 // subclasses of ImportPlugin
85 struct AUDACITY_DLL_API RegisteredImportPlugin{
87 const Identifier &id, // an internal string naming the plug-in
88 std::unique_ptr<ImportPlugin>,
89 const Registry::Placement &placement = { wxEmptyString, {} } );
90 };
91
92 // Objects of this type are statically constructed in files, to identify
93 // unsupported import formats; typically in a conditional compilation
95 RegisteredUnusableImportPlugin( std::unique_ptr<UnusableImportPlugin> );
96 };
97
98 Importer();
99 ~Importer();
100
101 Importer( const Importer& ) PROHIBITED;
102 Importer &operator=( Importer& ) PROHIBITED;
103
107 static Importer & Get();
108
112 bool Initialize();
113 bool Terminate();
114
120 GetFileTypes( const FileNames::FileType &extraType = {} );
121
125 static void
126 SetLastOpenType( const FileNames::FileType &type );
127
131 static void
132 SetDefaultOpenType( const FileNames::FileType &type );
133
137 static size_t
138 SelectDefaultOpenType( const FileNames::FileTypes &fileTypes );
139
144 void ReadImportItems();
145
149 void WriteImportItems();
150
156 void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod = wxTOKEN_RET_EMPTY_ALL);
157
162 ExtImportItems &GetImportItems() { return mExtImportItems; }
163
168 std::unique_ptr<ExtImportItem> CreateDefaultImportItem();
169
170 // if false, the import failed and errorMessage will be set.
171 bool Import( AudacityProject &project,
172 const FilePath &fName,
173 WaveTrackFactory *trackFactory,
174 TrackHolders &tracks,
175 Tags *tags,
176 TranslatableString &errorMessage);
177
178private:
180
182 static ImportPluginList &sImportPluginList();
183 static UnusableImportPluginList &sUnusableImportPluginList();
184};
185
186//----------------------------------------------------------------------------
187// ImportStreamDialog
188//----------------------------------------------------------------------------
189
191{
192public:
193 // constructors and destructors
195 wxWindow *parent, wxWindowID id, const TranslatableString &title,
196 const wxPoint& pos = wxDefaultPosition,
197 const wxSize& size = wxDefaultSize,
198 long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
199 virtual ~ImportStreamDialog();
200
201private:
203 wxInt32 scount;
204 wxListBox *StreamList;
205
206private:
207 void OnOk( wxCommandEvent &event );
208 void OnCancel( wxCommandEvent &event );
209
210private:
211 DECLARE_EVENT_TABLE()
212};
213
214extern AUDACITY_DLL_API BoolSetting NewImportingSession;
215
216#endif
#define str(a)
AUDACITY_DLL_API BoolSetting NewImportingSession
Definition: Import.cpp:897
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:20
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
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:76
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
An ImportFileHandle for data.
Definition: ImportPlugin.h:107
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:67
void OnOk(wxCommandEvent &event)
Definition: Import.cpp:883
virtual ~ImportStreamDialog()
Definition: Import.cpp:878
ImportFileHandle * mFile
Definition: Import.h:202
wxListBox * StreamList
Definition: Import.h:204
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:844
void OnCancel(wxCommandEvent &event)
Definition: Import.cpp:892
wxInt32 scount
Definition: Import.h:203
Class which actually imports the auido, using functions defined in ImportPCM.cpp, ImportMP3_*....
Definition: Import.h:80
static Importer mInstance
Definition: Import.h:179
ExtImportItems mExtImportItems
Definition: Import.h:181
Importer(const Importer &) PROHIBITED
ExtImportItems & GetImportItems()
Definition: Import.h:162
Importer & operator=(Importer &) PROHIBITED
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:225
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:165
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:612
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26