diff options
author | Don Bright <hugh.m.bright@gmail.com> | 2011-09-12 22:40:51 (GMT) |
---|---|---|
committer | Don Bright <hugh.m.bright@gmail.com> | 2011-09-12 22:40:51 (GMT) |
commit | f5f06c8e976ca45aebea42fe8c04bf7404357ac8 (patch) | |
tree | 8d0cdd2698e7806c1b12cc49e743b561e1082961 /src/PolySetCache.h | |
parent | 007c40848db9efd704694f2e7596cabed80da50f (diff) | |
parent | 5ac9162f1c67fd21737ead11d7ebc638bf4eef5f (diff) |
merge
Merge remote branch 'upstream/visitor' into visitortests
Conflicts:
src/export.cc
src/openscad.cc
src/polyset.cc
src/transform.cc
tests/CMakeLists.txt
tests/FindGLEW.cmake
tests/csgtermtest.cc
Diffstat (limited to 'src/PolySetCache.h')
-rw-r--r-- | src/PolySetCache.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/PolySetCache.h b/src/PolySetCache.h new file mode 100644 index 0000000..da51c5e --- /dev/null +++ b/src/PolySetCache.h @@ -0,0 +1,34 @@ +#ifndef POLYSETCACHE_H_ +#define POLYSETCACHE_H_ + +#include "myqhash.h" +#include <QCache> +#include "memory.h" + +class PolySetCache +{ +public: + PolySetCache(size_t polygonlimit = 100000) : cache(polygonlimit) {} + + static PolySetCache *instance() { if (!inst) inst = new PolySetCache; return inst; } + + bool contains(const std::string &id) const { return this->cache.contains(id); } + shared_ptr<class PolySet> get(const std::string &id) const { return this->cache[id]->ps; } + void insert(const std::string &id, const shared_ptr<PolySet> &ps); + void clear() { cache.clear(); } + void print(); + +private: + static PolySetCache *inst; + + struct cache_entry { + shared_ptr<class PolySet> ps; + QString msg; + cache_entry(const shared_ptr<PolySet> &ps); + ~cache_entry() { } + }; + + QCache<std::string, cache_entry> cache; +}; + +#endif |