| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 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 |