Debian Codegraph @

maz-db/src/MazDBBatch.h

raw symbols SCIP
1 /* Copyright (C) 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef MAZDBBATCH_H
19 #define MAZDBBATCH_H
20
21 #include <QObject>
22 #include <QMutex>
23 #include <QSet>
24 #include <QScopedPointer>
25 #include "MazDB.h"
26 #include "MazUtils.h"
27
28 namespace leveldb {
29 class DB;
30 class WriteBatch;
31 }
32
33 class MazDBBatch : public QObject
34 {
35 Q_OBJECT
36 public:
37 explicit MazDBBatch(QWeakPointer<leveldb::DB> db, QObject *parent = 0);
38 ~MazDBBatch();
39
40 Q_INVOKABLE MazDBBatch *del(const QString &key);
41 Q_INVOKABLE MazDBBatch *put(const QString &key, const QVariant &value);
42 Q_INVOKABLE MazDBBatch *clear();
43 Q_INVOKABLE bool write();
44
45 signals:
46 void batchWritten(QSet<QString> keys);
47
48 private:
49 Q_DISABLE_COPY(MazDBBatch)
50 QSharedPointer<leveldb::DB> m_leveldb;
51 leveldb::WriteBatch *m_batch;
52 QSet<QString> m_keys;
53 QMutex m_mutex;
54 };
55
56 #endif // MAZDBBATCH_H