14 #ifndef vtkCGNSCache_h
15 #define vtkCGNSCache_h
22 #include <unordered_map>
26 VTK_ABI_NAMESPACE_BEGIN
29 template <
typename CacheDataType>
48 typedef std::unordered_map<std::string, vtkSmartPointer<CacheDataType>> CacheMapper;
49 CacheMapper CacheData;
51 typename CacheMapper::iterator LastCacheAccess;
56 template <
typename CacheDataType>
60 this->cacheSizeLimit = -1;
61 this->LastCacheAccess = CacheData.end();
64 template <
typename CacheDataType>
67 this->cacheSizeLimit =
size;
70 template <
typename CacheDataType>
73 return this->cacheSizeLimit;
76 template <
typename CacheDataType>
79 typename CacheMapper::iterator iter;
80 iter = this->CacheData.find(query);
81 if (iter == this->CacheData.end())
83 this->LastCacheAccess = iter;
87 template <
typename CacheDataType>
92 if (this->cacheSizeLimit > 0 &&
93 this->CacheData.size() >=
static_cast<size_t>(this->cacheSizeLimit))
96 this->CacheData.erase(this->LastCacheAccess);
99 this->LastCacheAccess = this->CacheData.find(
key);
102 template <
typename CacheDataType>
105 this->CacheData.clear();
107 VTK_ABI_NAMESPACE_END
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.