27 lines
570 B
C++
27 lines
570 B
C++
#pragma once
|
|
|
|
#include <pdfengine/ocr_types.hpp>
|
|
#include <unordered_map>
|
|
#include <mutex>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace pdfengine {
|
|
|
|
class OCRCache {
|
|
public:
|
|
static OCRCache& instance();
|
|
|
|
void put(const std::string& imageHash, const OCRPage& ocrPage);
|
|
[[nodiscard]] std::optional<OCRPage> get(const std::string& imageHash) const;
|
|
void clear();
|
|
[[nodiscard]] size_t size() const;
|
|
|
|
private:
|
|
OCRCache() = default;
|
|
mutable std::mutex m_mutex;
|
|
std::unordered_map<std::string, OCRPage> m_cache;
|
|
};
|
|
|
|
} // namespace pdfengine
|