#ifndef CACHE_H #define CACHE_H #include #include "Common.h" class WorldModelRoot; class Model; template class GenericCache { public: GenericCache() {} static const int32 FlushLimit = 1000; void Insert(std::string key, T* val) { if (_items.size() > FlushLimit) Clear(); _items[key] = val; } T* Get(std::string key) { UNORDERED_MAP::iterator itr = _items.find(key); if (itr != _items.end()) return itr->second; return NULL; } void Clear() { _items.clear(); } private: UNORDERED_MAP _items; }; class CacheClass { public: CacheClass() {} GenericCache ModelCache; GenericCache WorldModelCache; }; extern CacheClass* Cache; #endif