11#ifndef __AUDACITY_PROJECT_FILE_IO__
12#define __AUDACITY_PROJECT_FILE_IO__
16#include <unordered_set>
26struct sqlite3_context;
38namespace BasicUI{
class WindowPlacement; }
47using BlockIDs = std::unordered_set<SampleBlockID>;
64 ,
public std::enable_shared_from_this<ProjectFileIO>
75 void SetFileName(
const FilePath &fileName);
80 bool mCommitted{
false };
85 static bool InitializeSQL();
101 void SetProjectTitle(
int number = -1);
104 const FilePath &GetFileName()
const;
105 void SetFileName(
const FilePath &fileName );
107 bool IsModified()
const;
108 bool IsTemporary()
const;
109 bool IsRecovered()
const;
111 void MarkTemporary();
113 bool AutoSave(
bool recording =
false);
114 bool AutoSaveDelete(sqlite3 *db =
nullptr);
122 std::optional<TentativeConnection>
123 LoadProject(
const FilePath &fileName,
bool ignoreAutosave);
127 bool SaveCopy(
const FilePath& fileName);
129 wxLongLong GetFreeDiskSpace()
const;
135 int64_t GetCurrentUsage(
136 const std::vector<const TrackList*> &trackLists)
const;
140 int64_t GetTotalUsage();
150 const wxString &helpPage);
153 int GetLastErrorCode()
const;
154 const wxString &GetLastLog()
const;
173 static const std::vector<wxString> &AuxiliaryFileSuffixes();
186 static bool RemoveProject(
const FilePath &filename);
195 bool IsOk() {
return !mPath.empty(); }
206 const std::vector<const TrackList *> &
tracks,
bool force =
false);
216 bool DeleteBlocks(
const BlockIDs &blockids,
bool complement);
220 using ExecCB = std::function<int(
int cols,
char **vals,
char **
names)>;
223 bool HasConnection()
const;
229 wxString GenerateDoc();
232 void OnCheckpointFailure();
234 void WriteXMLHeader(
XMLWriter &xmlFile)
const;
235 void WriteXML(
XMLWriter &xmlFile,
bool recording =
false,
244 int Exec(
const char *query,
const ExecCB &callback,
bool silent =
false);
251 bool OpenConnection(
FilePath fileName = {});
252 bool CloseConnection();
256 void SaveConnection();
259 void DiscardConnection();
262 void RestoreConnection();
267 bool Query(
const char *sql,
const ExecCB &callback,
bool silent =
false);
269 bool GetValue(
const char *sql, wxString &value,
bool silent =
false);
270 bool GetValue(
const char *sql, int64_t &value,
bool silent =
false);
273 bool InstallSchema(sqlite3 *db,
const char *schema =
"main");
276 bool WriteDoc(
const char *table,
const ProjectSerializer &autosave,
const char *schema =
"main");
279 static void InSet(sqlite3_context *context,
int argc, sqlite3_value **
argv);
282 bool CopyTo(
const FilePath &destpath,
286 const std::vector<const TrackList *> &
tracks = {}
302 bool ShouldCompact(
const std::vector<const TrackList *> &
tracks);
Utility ClientData::Site to register hooks into a host class that attach client data.
std::unique_ptr< DBConnection > Connection
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
std::unordered_set< SampleBlockID > BlockIDs
ProjectFileIOMessage
Subscribe to ProjectFileIO to receive messages; always in idle time.
@ CheckpointFailure
Failure happened in a worker thread.
@ ProjectTitleChange
A normal occurrence.
@ ProjectFilePathChange
A normal occurrence.
std::vector< Attribute > AttributesList
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Subclasses may hold information such as a parent window pointer for a dialog.
Makes a temporary project that doesn't display on the screen.
AudacityProject & Project()
std::shared_ptr< AudacityProject > mpProject
An object that sends messages to an open-ended list of subscribed callbacks.
A listener notified of changes in preferences.
virtual void UpdatePrefs()=0
bool IsOk()
Returns false if the renaming in the constructor failed.
Object associated with a project that manages reading and writing of Audacity project file formats,...
ProjectFileIO & operator=(const ProjectFileIO &)=delete
AudacityProject & mProject
const wxString & GetProjectTitle() const
std::function< int(int cols, char **vals, char **names)> ExecCB
ProjectFileIO(const ProjectFileIO &)=delete
std::shared_ptr< DBConnectionErrors > mpErrors
a class used to (de)serialize the project catalog
Implementation of SampleBlock using Sqlite database.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
This class is an interface which should be implemented by classes which wish to be able to load and s...
virtual XMLTagHandler * HandleXMLChild(const std::string_view &tag)=0
virtual bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs)=0
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.
void ReopenProject(AudacityProject &project)
A convenient default parameter for class template Site.
ProjectFileIO & mProjectFileIO
TentativeConnection(const TentativeConnection &other)=delete