2014-04-28 21:09:25 +04:00
|
|
|
#pragma once
|
2011-09-11 13:07:18 +04:00
|
|
|
|
2011-11-09 06:18:32 +04:00
|
|
|
#include "cache.h"
|
2013-12-02 10:48:22 +04:00
|
|
|
#include "memory.h"
|
2011-09-11 13:07:18 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*/
|
|
|
|
class CGALCache
|
|
|
|
{
|
|
|
|
public:
|
2012-01-08 05:45:58 +04:00
|
|
|
CGALCache(size_t limit = 100*1024*1024);
|
2011-09-11 13:07:18 +04:00
|
|
|
|
|
|
|
static CGALCache *instance() { if (!inst) inst = new CGALCache; return inst; }
|
|
|
|
|
|
|
|
bool contains(const std::string &id) const { return this->cache.contains(id); }
|
2013-12-02 10:48:22 +04:00
|
|
|
shared_ptr<const class CGAL_Nef_polyhedron> get(const std::string &id) const;
|
|
|
|
bool insert(const std::string &id, const shared_ptr<const CGAL_Nef_polyhedron> &N);
|
2012-01-06 22:10:33 +04:00
|
|
|
size_t maxSize() const;
|
|
|
|
void setMaxSize(size_t limit);
|
|
|
|
void clear();
|
2011-09-11 13:07:18 +04:00
|
|
|
void print();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static CGALCache *inst;
|
|
|
|
|
2013-12-02 10:48:22 +04:00
|
|
|
struct cache_entry {
|
|
|
|
shared_ptr<const CGAL_Nef_polyhedron> N;
|
|
|
|
std::string msg;
|
|
|
|
cache_entry(const shared_ptr<const CGAL_Nef_polyhedron> &N);
|
|
|
|
~cache_entry() { }
|
|
|
|
};
|
|
|
|
|
|
|
|
Cache<std::string, cache_entry> cache;
|
2011-09-11 13:07:18 +04:00
|
|
|
};
|