/* -*-c++-*- */ /* osgEarth - Geospatial SDK for OpenSceneGraph * Copyright 2020 Pelican Mapping * http://osgearth.org * * osgEarth is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see */ #ifndef OSGEARTH_MEMCACHE_H #define OSGEARTH_MEMCACHE_H 1 #include namespace osgEarth { /** * An in-memory cache. * Each bin in this cache has its own locking mechanism for thread-safety. Each * bin also maintains an LRU list for maintaining the size cap. */ class OSGEARTH_EXPORT MemCache : public Cache { public: MemCache( unsigned maxBinSize =16 ); META_Object( osgEarth, MemCache ); /** dtor */ virtual ~MemCache() { } void dumpStats(const std::string& binID); public: // Cache interface virtual CacheBin* addBin(const std::string& binID); virtual CacheBin* getOrCreateBin(const std::string& binID); virtual CacheBin* getOrCreateDefaultBin(); private: MemCache( const MemCache& rhs, const osg::CopyOp& op =osg::CopyOp::DEEP_COPY_ALL ) : Cache( rhs, op ) , _maxBinSize(rhs._maxBinSize) { } unsigned _maxBinSize; }; } // namespace osgEarth #endif // OSGEARTH_MEMCACHE_H