osgEarth 2.1.1
Public Member Functions | Protected Attributes

osgEarth::Cache Class Reference

Inheritance diagram for osgEarth::Cache:
Collaboration diagram for osgEarth::Cache:

List of all members.

Public Member Functions

virtual bool getImage (const TileKey &key, const CacheSpec &spec, osg::ref_ptr< const osg::Image > &out_image)=0
virtual void setImage (const TileKey &key, const CacheSpec &spec, const osg::Image *image)=0
virtual bool getHeightField (const TileKey &key, const CacheSpec &spec, osg::ref_ptr< const osg::HeightField > &out_hf)
virtual void setHeightField (const TileKey &key, const CacheSpec &spec, const osg::HeightField *hf)
virtual const std::string & getReferenceURI ()
virtual void setReferenceURI (const std::string &value)
virtual bool isCached (const TileKey &key, const CacheSpec &spec) const
virtual void storeProperties (const CacheSpec &spec, const Profile *profile, unsigned int tileSize)
virtual bool loadProperties (const std::string &cacheId, CacheSpec &out_spec, osg::ref_ptr< const Profile > &out_profile, unsigned int &out_tileSize)
virtual bool compact (bool async=true)
virtual bool purge (const std::string &cacheId, int olderThanTimeStamp=0L, bool async=true)
const CacheOptionsgetCacheOptions () const
 Cache (const CacheOptions &options=CacheOptions())
 Cache (const Cache &rhs, const osg::CopyOp &op=osg::CopyOp::DEEP_COPY_ALL)

Protected Attributes

CacheOptions _options
std::string _refURI

Detailed Description

A Cache is an object that stores and retrieves image or heightfield rasters. This is the base class for all such implementations.

Definition at line 209 of file Caching.


Constructor & Destructor Documentation

Cache::Cache ( const CacheOptions options = CacheOptions())

Definition at line 41 of file Caching.cpp.

                                          :
osg::Object( true ),
_options(options)
{
    //NOP
}
Cache::Cache ( const Cache rhs,
const osg::CopyOp &  op = osg::CopyOp::DEEP_COPY_ALL 
)

Definition at line 48 of file Caching.cpp.

                                                  :
osg::Object(rhs),
_refURI( rhs._refURI )
{
    //NOP
}

Member Function Documentation

virtual bool osgEarth::Cache::compact ( bool  async = true) [inline, virtual]

Compact the cache, if supported by the underlying implementation. You can optionally specify that the compaction operation run in a background thread if supported.

This method will return false if the implementation does not support compaction.

Definition at line 270 of file Caching.

{ return false; }
const CacheOptions& osgEarth::Cache::getCacheOptions ( ) const [inline]

Definition at line 285 of file Caching.

{ return _options; }

Here is the caller graph for this function:

bool Cache::getHeightField ( const TileKey key,
const CacheSpec spec,
osg::ref_ptr< const osg::HeightField > &  out_hf 
) [virtual]

Gets the cached heightfield for the given TileKey

Reimplemented in osgEarth::MemCache.

Definition at line 56 of file Caching.cpp.

{
        //Try to get an image from the cache
        osg::ref_ptr<const osg::Image> image;
    if ( getImage( key, spec, image ) )
        {
                OE_DEBUG << LC << "Read cached heightfield " << std::endl;
                ImageToHeightFieldConverter conv;
                out_hf = conv.convert(image.get());
        return out_hf.valid();
        }
    else return false;
}

Here is the call graph for this function:

virtual bool osgEarth::Cache::getImage ( const TileKey key,
const CacheSpec spec,
osg::ref_ptr< const osg::Image > &  out_image 
) [pure virtual]

Gets the cached image for the given TileKey

Implemented in osgEarth::MemCache, osgEarth::DiskCache, and Sqlite3Cache.

Here is the caller graph for this function:

virtual const std::string& osgEarth::Cache::getReferenceURI ( ) [inline, virtual]

Gets the current MapConfig filename. This is used for getting relative paths to the MapConfig.

Definition at line 235 of file Caching.

{ return _refURI; }
virtual bool osgEarth::Cache::isCached ( const TileKey key,
const CacheSpec spec 
) const [inline, virtual]

Gets whether the given TileKey is cached or not

Reimplemented in osgEarth::MemCache, osgEarth::DiskCache, and Sqlite3Cache.

Definition at line 245 of file Caching.

{ return false; }
virtual bool osgEarth::Cache::loadProperties ( const std::string &  cacheId,
CacheSpec out_spec,
osg::ref_ptr< const Profile > &  out_profile,
unsigned int &  out_tileSize 
) [inline, virtual]

Loads the TileMap for the given cacheId.

Reimplemented in osgEarth::DiskCache, and Sqlite3Cache.

Definition at line 256 of file Caching.

                                                    { return false; }
virtual bool osgEarth::Cache::purge ( const std::string &  cacheId,
int  olderThanTimeStamp = 0L,
bool  async = true 
) [inline, virtual]

Delete old entries from the cache. The timestamp is UTC, second since epoch. You can optionally control whether the purge operation should run in the background (async=true) if supported.

This method will return false if the implementation does not support the operation.

Reimplemented in osgEarth::MemCache, and Sqlite3Cache.

Definition at line 280 of file Caching.

                           { return false; }
void Cache::setHeightField ( const TileKey key,
const CacheSpec spec,
const osg::HeightField *  hf 
) [virtual]

Sets the cached heightfield for the given TileKey

Reimplemented in osgEarth::MemCache.

Definition at line 71 of file Caching.cpp.

{
        ImageToHeightFieldConverter conv;
        //Take a reference to the returned image so it gets deleted properly
    osg::ref_ptr<osg::Image> image = conv.convert(hf);
        setImage( key, spec, image.get() );
}

Here is the call graph for this function:

virtual void osgEarth::Cache::setImage ( const TileKey key,
const CacheSpec spec,
const osg::Image *  image 
) [pure virtual]

Sets the cached image for the given TileKey

Implemented in osgEarth::MemCache, osgEarth::DiskCache, and Sqlite3Cache.

Here is the caller graph for this function:

virtual void osgEarth::Cache::setReferenceURI ( const std::string &  value) [inline, virtual]

Sets the current MapConfig filename.

Definition at line 240 of file Caching.

{ _refURI = value; }
virtual void osgEarth::Cache::storeProperties ( const CacheSpec spec,
const Profile profile,
unsigned int  tileSize 
) [inline, virtual]

Store the TileMap for the given profile.

Reimplemented in osgEarth::DiskCache, and Sqlite3Cache.

Definition at line 250 of file Caching.

        { }

Member Data Documentation

Reimplemented in osgEarth::DiskCache, osgEarth::TMSCache, and Sqlite3Cache.

Definition at line 292 of file Caching.

std::string osgEarth::Cache::_refURI [protected]

Definition at line 293 of file Caching.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines