-
Notifications
You must be signed in to change notification settings - Fork 2
/
CacheDatabase.hpp
46 lines (42 loc) · 1.38 KB
/
CacheDatabase.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef CACHEDATABASE_HPP
#define CACHEDATABASE_HPP
// Qt
#include <QObject>
#include <QString>
#include <QFile>
#include <QSqlDatabase>
#include <QSqlError>
class CacheDatabase : public QObject
{
public:
// Singleton
static CacheDatabase &getInstance();
// Constants
static const QString CacheTableName;
static const QString CacheColumnCloudPath;
static const QString CacheColumnSegmentBase;
static const QString CacheColumnMap;
bool openDB();
bool prepareDB();
int insertCacheEntry(const QString& cloud_path, const QString& segment_path, const QString& mapStr);
bool updateCacheEntry(const QString& cloud_path, const QString& segment_path, const QString& mapStr);
void saveCacheEntry(const QString& cloud_path, const QString& segment_path, const QString& mapStr);
QString getSegmentPath(const QString& cloud_path);
QString getCloudPath(const QString& segment_path);
QString getMap(const QString& cloud_path);
void closeDB();
bool deleteDB();
QSqlError lastError();
private:
// Singleton
CacheDatabase(QObject *parent = 0);
CacheDatabase(const CacheDatabase&); // Non copyable!
~CacheDatabase();
// Get field where...
QString getField(const QString& what, const QString& where, const QString& value);
// Database path
QString mDbPath;
// Database
QSqlDatabase mDb;
};
#endif // CACHEDATABASE_HPP