LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
dblock.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <QMutex>
12
#include <QString>
13
#include <QSet>
14
#include "
dbconfig.h
"
15
16
class
QSqlError;
17
class
QSqlQuery;
18
class
QSqlDatabase;
19
20
namespace
LC
21
{
22
namespace
Util
23
{
41
class
DBLock
42
{
43
QSqlDatabase& Database_;
44
45
bool
Good_ =
false
;
46
bool
Initialized_ =
false
;
47
48
static
QMutex LockedMutex_;
49
static
QSet<QString> LockedBases_;
50
public
:
51
DBLock
(
const
DBLock
&) =
delete
;
52
DBLock
&
operator=
(
const
DBLock
&) =
delete
;
53
54
DBLock
(
DBLock
&&) =
default
;
55
65
UTIL_DB_API
explicit
DBLock
(QSqlDatabase& database);
66
72
UTIL_DB_API
~DBLock
();
73
81
UTIL_DB_API
void
Init
();
82
89
UTIL_DB_API
void
Good
();
90
95
UTIL_DB_API
static
void
DumpError
(
const
QSqlError& error);
96
101
UTIL_DB_API
static
void
DumpError
(
const
QSqlQuery& query);
102
111
UTIL_DB_API
static
void
Execute
(QSqlQuery& query);
112
};
113
};
114
};
LC::Util::DBLock::DumpError
static UTIL_DB_API void DumpError(const QSqlError &error)
Dumps the error to the qWarning() stream.
Definition:
dblock.cpp:74
UTIL_DB_API
#define UTIL_DB_API
Definition:
dbconfig.h:16
dbconfig.h
LC::Util::DBLock::~DBLock
UTIL_DB_API ~DBLock()
Destructor.
Definition:
dblock.cpp:35
LC::Util::DBLock::operator=
DBLock & operator=(const DBLock &)=delete
LC::Util::DBLock::Init
UTIL_DB_API void Init()
Initializes the transaction.
Definition:
dblock.cpp:51
LC
Definition:
constants.h:14
LC::Util::DBLock::Good
UTIL_DB_API void Good()
Notifies the lock about successful higher-level operations.
Definition:
dblock.cpp:69
LC::Util::DBLock::DBLock
DBLock(const DBLock &)=delete
LC::Util::DBLock::Execute
static UTIL_DB_API void Execute(QSqlQuery &query)
Tries to execute the given query.
Definition:
dblock.cpp:87
LC::Util::DBLock
Provides database transaction lock.
Definition:
dblock.h:41
src
util
db
dblock.h
Generated by
1.8.17