Audacity 3.2.0
|
#include <DBConnection.h>
Public Types | |
enum | StatementID { GetSamples , GetSummary256 , GetSummary64k , LoadSampleBlock , InsertSampleBlock , DeleteSampleBlock , GetSampleBlockSize , GetAllSampleBlocksSize } |
using | CheckpointFailureCallback = std::function< void()> |
Public Member Functions | |
DBConnection (const std::weak_ptr< AudacityProject > &pProject, const std::shared_ptr< DBConnectionErrors > &pErrors, CheckpointFailureCallback callback) | |
~DBConnection () | |
int | Open (const FilePath fileName) |
bool | Close () |
void | ThrowException (bool write) const |
throw and show appropriate message box More... | |
int | SafeMode (const char *schema="main") |
int | FastMode (const char *schema="main") |
int | SetPageSize (const char *schema="main") |
bool | Assign (sqlite3 *handle) |
sqlite3 * | Detach () |
sqlite3 * | DB () |
int | GetLastRC () const |
const wxString | GetLastMessage () const |
sqlite3_stmt * | Prepare (enum StatementID id, const char *sql) |
void | SetBypass (bool bypass) |
bool | ShouldBypass () |
void | SetError (const TranslatableString &msg, const TranslatableString &libraryError={}, int errorCode={}) |
Just set stored errors. More... | |
void | SetDBError (const TranslatableString &msg, const TranslatableString &libraryError={}, int errorCode=-1) |
Set stored errors and write to log; and default libraryError to what database library reports. More... | |
Private Types | |
using | StatementIndex = std::pair< enum StatementID, std::thread::id > |
Private Member Functions | |
int | OpenStepByStep (const FilePath fileName) |
int | ModeConfig (sqlite3 *db, const char *schema, const char *config) |
void | CheckpointThread (sqlite3 *db, const FilePath &fileName) |
Static Private Member Functions | |
static int | CheckpointHook (void *data, sqlite3 *db, const char *schema, int pages) |
Private Attributes | |
std::weak_ptr< AudacityProject > | mpProject |
sqlite3 * | mDB |
sqlite3 * | mCheckpointDB |
std::thread | mCheckpointThread |
std::condition_variable | mCheckpointCondition |
std::mutex | mCheckpointMutex |
std::atomic_bool | mCheckpointStop { false } |
std::atomic_bool | mCheckpointPending { false } |
std::atomic_bool | mCheckpointActive { false } |
std::mutex | mStatementMutex |
std::map< StatementIndex, sqlite3_stmt * > | mStatements |
std::shared_ptr< DBConnectionErrors > | mpErrors |
CheckpointFailureCallback | mCallback |
bool | mBypass |
Definition at line 39 of file DBConnection.h.
using DBConnection::CheckpointFailureCallback = std::function<void()> |
Definition at line 42 of file DBConnection.h.
|
private |
Definition at line 122 of file DBConnection.h.
Enumerator | |
---|---|
GetSamples | |
GetSummary256 | |
GetSummary64k | |
LoadSampleBlock | |
InsertSampleBlock | |
DeleteSampleBlock | |
GetSampleBlockSize | |
GetAllSampleBlocksSize |
Definition at line 74 of file DBConnection.h.
DBConnection::DBConnection | ( | const std::weak_ptr< AudacityProject > & | pProject, |
const std::shared_ptr< DBConnectionErrors > & | pErrors, | ||
CheckpointFailureCallback | callback | ||
) |
callback | Invoked in the main thread in idle time after detection of checkpoint failure, which might have been in a worker thread |
Definition at line 51 of file DBConnection.cpp.
References mBypass, mCheckpointDB, and mDB.
DBConnection::~DBConnection | ( | ) |
bool DBConnection::Assign | ( | sqlite3 * | handle | ) |
|
staticprivate |
Definition at line 587 of file DBConnection.cpp.
References mCheckpointCondition, mCheckpointMutex, and mCheckpointPending.
Referenced by OpenStepByStep().
|
private |
Definition at line 493 of file DBConnection.cpp.
References FileNames::AbbreviatePath(), ADD_EXCEPTION_CONTEXT, BadEnvironment, GuardedCall(), Internal, mCallback, mCheckpointActive, mCheckpointCondition, mCheckpointMutex, mCheckpointPending, mCheckpointStop, name, and XO().
Referenced by OpenStepByStep().
bool DBConnection::Close | ( | ) |
Definition at line 233 of file DBConnection.cpp.
References ADD_EXCEPTION_CONTEXT, BasicUI::MakeGenericProgress(), mCheckpointActive, mCheckpointCondition, mCheckpointDB, mCheckpointMutex, mCheckpointPending, mCheckpointStop, mCheckpointThread, mDB, mpProject, mStatementMutex, mStatements, project, title, and XO().
sqlite3 * DBConnection::DB | ( | ) |
Definition at line 422 of file DBConnection.cpp.
References mDB.
Referenced by ProjectFileIO::DB(), SqliteSampleBlock::DB(), SetDBError(), DBConnectionTransactionScopeImpl::TransactionCommit(), DBConnectionTransactionScopeImpl::TransactionRollback(), and DBConnectionTransactionScopeImpl::TransactionStart().
sqlite3 * DBConnection::Detach | ( | ) |
int DBConnection::FastMode | ( | const char * | schema = "main" | ) |
Definition at line 360 of file DBConnection.cpp.
References FastConfig, mDB, and ModeConfig().
const wxString DBConnection::GetLastMessage | ( | ) | const |
Definition at line 434 of file DBConnection.cpp.
References mDB.
int DBConnection::GetLastRC | ( | ) | const |
Definition at line 429 of file DBConnection.cpp.
References mDB.
|
private |
Definition at line 393 of file DBConnection.cpp.
References ADD_EXCEPTION_CONTEXT, mDB, and wxT().
Referenced by FastMode(), OpenStepByStep(), SafeMode(), and SetPageSize().
int DBConnection::Open | ( | const FilePath | fileName | ) |
Definition at line 142 of file DBConnection.cpp.
References mCheckpointActive, mCheckpointDB, mCheckpointPending, mCheckpointStop, mDB, and OpenStepByStep().
|
private |
Definition at line 169 of file DBConnection.cpp.
References ADD_EXCEPTION_CONTEXT, CheckpointHook(), CheckpointThread(), mCheckpointDB, mCheckpointThread, mDB, ModeConfig(), name, SafeConfig, SafeMode(), SetDBError(), SetPageSize(), and XO().
Referenced by Open().
sqlite3_stmt * DBConnection::Prepare | ( | enum StatementID | id, |
const char * | sql | ||
) |
Definition at line 439 of file DBConnection.cpp.
References ADD_EXCEPTION_CONTEXT, mDB, mStatementMutex, mStatements, and THROW_INCONSISTENCY_EXCEPTION.
Referenced by SqliteSampleBlock::Commit(), SqliteSampleBlock::Delete(), SqliteSampleBlock::DoGetSamples(), ProjectFileIO::GetDiskUsage(), SqliteSampleBlock::GetSummary(), and SqliteSampleBlock::Load().
int DBConnection::SafeMode | ( | const char * | schema = "main" | ) |
Definition at line 355 of file DBConnection.cpp.
References mDB, ModeConfig(), and SafeConfig.
Referenced by OpenStepByStep().
void DBConnection::SetBypass | ( | bool | bypass | ) |
void DBConnection::SetDBError | ( | const TranslatableString & | msg, |
const TranslatableString & | libraryError = {} , |
||
int | errorCode = -1 |
||
) |
Set stored errors and write to log; and default libraryError to what database library reports.
Definition at line 110 of file DBConnection.cpp.
References DB(), TranslatableString::empty(), AudacityLogger::Get(), mpErrors, Verbatim(), and XO().
Referenced by OpenStepByStep(), DBConnectionTransactionScopeImpl::TransactionCommit(), DBConnectionTransactionScopeImpl::TransactionRollback(), and DBConnectionTransactionScopeImpl::TransactionStart().
void DBConnection::SetError | ( | const TranslatableString & | msg, |
const TranslatableString & | libraryError = {} , |
||
int | errorCode = {} |
||
) |
Just set stored errors.
Definition at line 84 of file DBConnection.cpp.
References TranslatableString::empty(), AudacityLogger::Get(), mpErrors, and XO().
int DBConnection::SetPageSize | ( | const char * | schema = "main" | ) |
Definition at line 365 of file DBConnection.cpp.
References mDB, ModeConfig(), and PageSizeConfig.
Referenced by OpenStepByStep().
bool DBConnection::ShouldBypass | ( | ) |
void DBConnection::ThrowException | ( | bool | write | ) | const |
throw and show appropriate message box
write | If true, a database update failed; if false, only a SELECT failed |
Definition at line 341 of file DBConnection.cpp.
References mDB, FileException::Read, and FileException::Write.
Referenced by SqliteSampleBlock::Commit(), SqliteSampleBlock::Delete(), SqliteSampleBlock::GetBlob(), ProjectFileIO::GetDiskUsage(), and SqliteSampleBlock::Load().
|
private |
Definition at line 129 of file DBConnection.h.
Referenced by DBConnection(), SetBypass(), and ShouldBypass().
|
private |
Definition at line 126 of file DBConnection.h.
Referenced by CheckpointThread().
|
private |
Definition at line 119 of file DBConnection.h.
Referenced by CheckpointThread(), Close(), and Open().
|
private |
Definition at line 115 of file DBConnection.h.
Referenced by CheckpointHook(), CheckpointThread(), and Close().
|
private |
Definition at line 112 of file DBConnection.h.
Referenced by Close(), DBConnection(), Open(), and OpenStepByStep().
|
private |
Definition at line 116 of file DBConnection.h.
Referenced by CheckpointHook(), CheckpointThread(), and Close().
|
private |
Definition at line 118 of file DBConnection.h.
Referenced by CheckpointHook(), CheckpointThread(), Close(), and Open().
|
private |
Definition at line 117 of file DBConnection.h.
Referenced by CheckpointThread(), Close(), and Open().
|
private |
Definition at line 114 of file DBConnection.h.
Referenced by Close(), and OpenStepByStep().
|
private |
Definition at line 111 of file DBConnection.h.
Referenced by Close(), DB(), DBConnection(), FastMode(), GetLastMessage(), GetLastRC(), ModeConfig(), Open(), OpenStepByStep(), Prepare(), SafeMode(), SetPageSize(), ThrowException(), and ~DBConnection().
|
private |
Definition at line 125 of file DBConnection.h.
Referenced by SetDBError(), and SetError().
|
private |
Definition at line 110 of file DBConnection.h.
Referenced by Close().
|
private |
Definition at line 121 of file DBConnection.h.
|
private |
Definition at line 123 of file DBConnection.h.