34#include <unordered_map>
40template <
typename CacheDataType>
59 typedef std::unordered_map<std::string, vtkSmartPointer<CacheDataType>> CacheMapper;
60 CacheMapper CacheData;
62 typename CacheMapper::iterator LastCacheAccess;
67template <
typename CacheDataType>
71 this->cacheSizeLimit = -1;
72 this->LastCacheAccess = CacheData.end();
75template <
typename CacheDataType>
78 this->cacheSizeLimit = size;
81template <
typename CacheDataType>
84 return this->cacheSizeLimit;
87template <
typename CacheDataType>
90 typename CacheMapper::iterator iter;
91 iter = this->CacheData.find(query);
92 if (iter == this->CacheData.end())
94 this->LastCacheAccess = iter;
98template <
typename CacheDataType>
103 if (this->cacheSizeLimit > 0 &&
104 this->CacheData.size() >=
static_cast<size_t>(this->cacheSizeLimit))
107 this->CacheData.erase(this->LastCacheAccess);
109 this->CacheData[key] = data;
110 this->LastCacheAccess = this->CacheData.find(key);
113template <
typename CacheDataType>
116 this->CacheData.clear();
vtkSmartPointer< CacheDataType > Find(const std::string &query)
void Insert(const std::string &key, const vtkSmartPointer< CacheDataType > &data)
void SetCacheSizeLimit(int size)
Hold a reference to a vtkObjectBase instance.