created disk manager class

This is a singleton class that will manage the disk cache to ensure the size
stays at sane levels.
This commit is contained in:
itsmattkc
2020-01-09 20:20:47 +11:00
parent 7df52b7fd5
commit 9c2c384833
3 changed files with 170 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
#ifndef DISKMANAGER_H
#define DISKMANAGER_H
#include <QObject>
class DiskManager : public QObject
{
Q_OBJECT
public:
static void CreateInstance();
static void DestroyInstance();
static DiskManager* instance();
void Accessed(const QByteArray& hash);
void CreatedFile(const QString& file_name, const QByteArray& hash);
signals:
void DeletedFrame(const QByteArray& hash);
private:
DiskManager();
virtual ~DiskManager() override;
static DiskManager* instance_;
void DeleteLeastRecent();
qint64 DiskLimit();
struct HashTime {
QString file_name;
QByteArray hash;
qint64 access_time;
qint64 file_size;
};
QList<HashTime> disk_data_;
qint64 consumption_;
};
#endif // DISKMANAGER_H