22#include <unordered_map>
26VTK_ABI_NAMESPACE_BEGIN
29template <
typename CacheDataType>
48 typedef std::unordered_map<std::string, vtkSmartPointer<CacheDataType>> CacheMapper;
49 CacheMapper CacheData;
51 typename CacheMapper::iterator LastCacheAccess;
56template <
typename CacheDataType>
60 this->cacheSizeLimit = -1;
61 this->LastCacheAccess = CacheData.end();
64template <
typename CacheDataType>
67 this->cacheSizeLimit = size;
70template <
typename CacheDataType>
73 return this->cacheSizeLimit;
76template <
typename CacheDataType>
79 typename CacheMapper::iterator iter;
80 iter = this->CacheData.find(query);
81 if (iter == this->CacheData.end())
83 this->LastCacheAccess = iter;
87template <
typename CacheDataType>
92 if (this->cacheSizeLimit > 0 &&
93 this->CacheData.size() >=
static_cast<size_t>(this->cacheSizeLimit))
96 this->CacheData.erase(this->LastCacheAccess);
98 this->CacheData[key] = data;
99 this->LastCacheAccess = this->CacheData.find(key);
102template <
typename CacheDataType>
105 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.
This file defines functions used by vtkCGNSReader and vtkCGNSReaderInternal.