26 #ifndef vtkCGNSCache_h
27 #define vtkCGNSCache_h
34 #include <unordered_map>
38 VTK_ABI_NAMESPACE_BEGIN
41 template <
typename CacheDataType>
60 typedef std::unordered_map<std::string, vtkSmartPointer<CacheDataType>> CacheMapper;
61 CacheMapper CacheData;
63 typename CacheMapper::iterator LastCacheAccess;
68 template <
typename CacheDataType>
72 this->cacheSizeLimit = -1;
73 this->LastCacheAccess = CacheData.end();
76 template <
typename CacheDataType>
79 this->cacheSizeLimit =
size;
82 template <
typename CacheDataType>
85 return this->cacheSizeLimit;
88 template <
typename CacheDataType>
91 typename CacheMapper::iterator iter;
92 iter = this->CacheData.find(query);
93 if (iter == this->CacheData.end())
95 this->LastCacheAccess = iter;
99 template <
typename CacheDataType>
104 if (this->cacheSizeLimit > 0 &&
105 this->CacheData.size() >=
static_cast<size_t>(this->cacheSizeLimit))
108 this->CacheData.erase(this->LastCacheAccess);
111 this->LastCacheAccess = this->CacheData.find(
key);
114 template <
typename CacheDataType>
117 this->CacheData.clear();
119 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.