lolautoaccept/include/memoryimagecache.h
2022-04-23 22:28:01 +02:00

29 lines
612 B
C++

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