Audacity  2.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 "ImportRaw.h" // defines TrackHolders
15 #include "ImportForwards.h"
16 #include <vector>
17 #include <wx/arrstr.h>
18 #include <wx/string.h>
19 #include <wx/listbox.h>
20 #include <wx/tokenzr.h>
21 
22 #include "../widgets/wxPanelWrapper.h"
23 
24 class Tags;
25 class TrackFactory;
26 class Track;
27 class ImportPlugin;
28 class ImportFileHandle;
30 typedef bool (*progress_callback_t)( void *userData, float percent );
31 
32 class Format {
33 public:
34  wxString formatName;
35  wxArrayString formatExtensions;
36 
37  Format(const wxString &_formatName, const wxArrayString &_formatExtensions):
38  formatName(_formatName),
39  formatExtensions(_formatExtensions)
40  {
41  }
42 };
43 
44 class ExtImportItem;
45 
46 using FormatList = std::vector<Format> ;
47 WX_DEFINE_ARRAY_PTR(ImportPlugin *, ImportPluginPtrArray);
48 using ExtImportItems = std::vector< movable_ptr<ExtImportItem> >;
49 
51 {
52  public:
60  wxArrayString filters;
61 
69  int divider;
70 
74  ImportPluginPtrArray filter_objects;
75 
80  wxArrayString extensions;
81 
86  wxArrayString mime_types;
87 };
88 
89 class Importer {
90 public:
91  Importer();
92  ~Importer();
93 
97  static Importer & Get();
98 
102  bool Initialize();
103  bool Terminate();
104 
108  void GetSupportedImportFormats(FormatList *formatList);
109 
114  void ReadImportItems();
115 
119  void WriteImportItems();
120 
126  void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod = wxTOKEN_RET_EMPTY_ALL);
127 
133 
139 
140  static bool IsMidi(const wxString &fName);
141 
142  // if false, the import failed and errorMessage will be set.
143  bool Import(const wxString &fName,
144  TrackFactory *trackFactory,
145  TrackHolders &tracks,
146  Tags *tags,
147  wxString &errorMessage);
148 
149 private:
151 
155 };
156 
157 //----------------------------------------------------------------------------
158 // ImportStreamDialog
159 //----------------------------------------------------------------------------
160 
162 {
163 public:
164  // constructors and destructors
166  wxWindow *parent, wxWindowID id, const wxString &title,
167  const wxPoint& pos = wxDefaultPosition,
168  const wxSize& size = wxDefaultSize,
169  long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
170  virtual ~ImportStreamDialog();
171 
172 private:
174  wxInt32 scount;
175  wxListBox *StreamList;
176 
177 private:
178  void OnOk( wxCommandEvent &event );
179  void OnCancel( wxCommandEvent &event );
180 
181 private:
182  DECLARE_EVENT_TABLE()
183 };
184 
185 #endif
void OnCancel(wxCommandEvent &event)
Definition: Import.cpp:738
Class which actulaly imports the auido, using functions defined in ImportPCM.cpp, ImportMP3...
Definition: Import.h:89
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:180
An ImportFileHandle for data.
Definition: ImportPlugin.h:120
std::unique_ptr< T > movable_ptr
Definition: MemoryX.h:683
static Importer mInstance
Definition: Import.h:150
wxArrayString filters
Definition: Import.h:60
Abstract base class used in importing a file.
Definition: Import.h:32
ExtImportItems mExtImportItems
Definition: Import.h:152
static bool IsMidi(const wxString &fName)
Definition: Import.cpp:331
wxInt32 scount
Definition: Import.h:174
Importer()
Definition: Import.cpp:78
bool Initialize()
Definition: Import.cpp:86
void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod=wxTOKEN_RET_EMPTY_ALL)
Definition: Import.cpp:139
bool Import(const wxString &fName, TrackFactory *trackFactory, TrackHolders &tracks, Tags *tags, wxString &errorMessage)
Definition: Import.cpp:341
Definition: wxPanelWrapper.h:19
ExtImportItems & GetImportItems()
Definition: Import.h:132
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:676
void GetSupportedImportFormats(FormatList *formatList)
Definition: Import.cpp:125
void ReadImportItems()
Definition: Import.cpp:147
void OnOk(wxCommandEvent &event)
Definition: Import.cpp:729
ImportPluginList mImportPluginList
Definition: Import.h:153
void WriteImportItems()
Definition: Import.cpp:255
virtual ~ImportStreamDialog()
Definition: Import.cpp:724
Format(const wxString &_formatName, const wxArrayString &_formatExtensions)
Definition: Import.h:37
~Importer()
Definition: Import.cpp:82
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:85
wxArrayString mime_types
Definition: Import.h:86
WX_DEFINE_ARRAY_PTR(ImportPlugin *, ImportPluginPtrArray)
ImportStreamDialog(ImportFileHandle *_mFile, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
Definition: Import.cpp:691
std::vector< movable_ptr< ExtImportItem > > ExtImportItems
Definition: Import.h:48
ID3 Tags (for MP3)
Definition: Tags.h:76
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:74
UnusableImportPluginList mUnusableImportPluginList
Definition: Import.h:154
ImportPluginPtrArray filter_objects
Definition: Import.h:74
Definition: Import.h:50
wxArrayString formatExtensions
Definition: Import.h:35
Definition: Import.h:161
wxListBox * StreamList
Definition: Import.h:175
bool(* progress_callback_t)(void *userData, float percent)
Definition: Import.h:30
An UnusableImportPlugin list.
An ImportPlugin list.
wxArrayString extensions
Definition: Import.h:80
movable_ptr< ExtImportItem > CreateDefaultImportItem()
Definition: Import.cpp:316
static Importer & Get()
Definition: Import.cpp:73
std::vector< std::unique_ptr< WaveTrack >> TrackHolders
Definition: ImportRaw.h:42
int divider
Definition: Import.h:69
ImportFileHandle * mFile
Definition: Import.h:173
std::vector< Format > FormatList
Definition: Import.h:46
wxString formatName
Definition: Import.h:34
bool Terminate()
Definition: Import.cpp:116