DYT/Tool/OpenSceneGraph-3.6.5/include/osgEarth/MemCache

62 lines
1.8 KiB
Plaintext
Raw Normal View History

2024-12-24 23:49:36 +00:00
/* -*-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 <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_MEMCACHE_H
#define OSGEARTH_MEMCACHE_H 1
#include <osgEarth/Cache>
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