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 "FileNames.h" // for FileType
20
21#include "Registry.h"
22
23class wxArrayString;
24class AudacityProject;
25class Tags;
27class Track;
28class TrackList;
29class ImportPlugin;
32typedef bool (*progress_callback_t)( void *userData, float percent );
33
34class ExtImportItem;
35class WaveTrack;
36
37using ExtImportItems = std::vector<std::unique_ptr<ExtImportItem>>;
38using TrackHolders = std::vector<std::shared_ptr<TrackList>>;
39
41{
42 public:
50 wxArrayString filters;
51
60
64 std::vector<ImportPlugin*> filter_objects;
65
70 wxArrayString extensions;
71
76 wxArrayString mime_types;
77};
78
79class IMPORT_EXPORT_API Importer {
80 struct ImporterItem;
81public:
82
83 // Objects of this type are statically constructed in files implementing
84 // subclasses of ImportPlugin
85 struct IMPORT_EXPORT_API RegisteredImportPlugin final
86 : Registry::RegisteredItem<ImporterItem>
87 {
89 const Identifier &id, // an internal string naming the plug-in
90 std::unique_ptr<ImportPlugin>,
91 const Registry::Placement &placement = { wxEmptyString, {} } );
92 };
93
94 // Objects of this type are statically constructed in files, to identify
95 // unsupported import formats; typically in a conditional compilation
97 RegisteredUnusableImportPlugin( std::unique_ptr<UnusableImportPlugin> );
98 };
99
100 Importer();
101 ~Importer();
102
103 Importer( const Importer& ) = delete;
105
109 static Importer & Get();
110
114 bool Initialize();
115 bool Terminate();
116
122 GetFileTypes( const FileNames::FileType &extraType = {} );
123
127 static void
128 SetLastOpenType( const FileNames::FileType &type );
129
133 static void
134 SetDefaultOpenType( const FileNames::FileType &type );
135
139 static size_t
140 SelectDefaultOpenType( const FileNames::FileTypes &fileTypes );
141
146 void ReadImportItems();
147
151 void WriteImportItems();
152
158 void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod = wxTOKEN_RET_EMPTY_ALL);
159
164 ExtImportItems &GetImportItems() { return mExtImportItems; }
165
170 std::unique_ptr<ExtImportItem> CreateDefaultImportItem();
171
172 // if false, the import failed and errorMessage will be set.
173 bool Import( AudacityProject &project,
174 const FilePath &fName,
175 ImportProgressListener* importProgressListener,
176 WaveTrackFactory *trackFactory,
178 Tags *tags,
179 TranslatableString &errorMessage);
180
181private:
184 };
185 struct IMPORT_EXPORT_API ImporterItem final : Registry::SingleItem {
187
188 ImporterItem( const Identifier &id, std::unique_ptr<ImportPlugin> pPlugin );
190 std::unique_ptr<ImportPlugin> mpPlugin;
191 };
192
194
196 static ImportPluginList &sImportPluginList();
197 static UnusableImportPluginList &sUnusableImportPluginList();
198};
199
200extern IMPORT_EXPORT_API BoolSetting NewImportingSession;
201
202#endif
#define str(a)
std::vector< std::unique_ptr< ExtImportItem > > ExtImportItems
Definition: Import.h:37
bool(* progress_callback_t)(void *userData, float percent)
Definition: Import.h:32
IMPORT_EXPORT_API BoolSetting NewImportingSession
Definition: Import.cpp:846
std::vector< std::unique_ptr< UnusableImportPlugin > > UnusableImportPluginList
std::vector< ImportPlugin * > ImportPluginList
std::vector< std::shared_ptr< TrackList > > TrackHolders
Definition: ImportRaw.h:24
wxString FilePath
Definition: Project.h:21
const auto tracks
const auto project
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:344
wxArrayString filters
Definition: Import.h:50
int divider
Definition: Import.h:59
wxArrayString extensions
Definition: Import.h:70
wxArrayString mime_types
Definition: Import.h:76
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:64
std::vector< FileType > FileTypes
Definition: FileNames.h:75
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:67
Interface used to report on import state and progress.
Singleton class which actually imports the audio, using ImportPlugin objects that are registered by m...
Definition: Import.h:79
Importer & operator=(Importer &)=delete
static Importer mInstance
Definition: Import.h:193
Importer(const Importer &)=delete
ExtImportItems mExtImportItems
Definition: Import.h:195
ExtImportItems & GetImportItems()
Definition: Import.h:164
Generates classes whose instances register items at construction.
Definition: Registry.h:388
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:122
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:975
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:178
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:1254
A Track that contains audio waveform data.
Definition: WaveTrack.h:222
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
std::unique_ptr< ImportPlugin > mpPlugin
Definition: Import.h:190
Common abstract base class for items that are not groups.
Definition: Registry.h:224
Primary template for a list of arbitrary types.
Definition: TypeList.h:61