lolautoaccept/include/memoryimagecache.h

29 lines
586 B
C++

#pragma once
#include <functional>
#include <QString>
#include <QPixmap>
class MemoryImageCache {
public:
MemoryImageCache(size_t maxsize = 25);
void addImage(QPixmap, const QString& title, int type);
QPixmap getImage(const QString& title, int type);
private:
void cleanUp();
struct CachedImage {
time_t lastaccessed = 0;
QPixmap imageref;
QString title;
int type;
bool operator<(const CachedImage& other) const;
};
static std::function<bool(const CachedImage&)> getImageMatcher(const QString& title, int type);
std::list<CachedImage> cache;
size_t maxsize;
};