osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/cache_sqlite3/Sqlite3CacheOptions

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2010 Pelican Mapping
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 #ifndef OSGEARTH_DRIVER_SQLITE3_CACHE_DRIVEROPTIONS
00020 #define OSGEARTH_DRIVER_SQLITE3_CACHE_DRIVEROPTIONS 1
00021 
00022 #include <osgEarth/Common>
00023 #include <osgEarth/Caching>
00024 #include <osgEarth/TileSource>
00025 
00026 // there is leak using the cache if compressed. It's resolved in
00027 // rev 11609 of osg svn
00028 
00029 namespace osgEarth { namespace Drivers
00030 {
00031     using namespace osgEarth;
00032 
00033     class Sqlite3CacheOptions : public CacheOptions // NO EXPORT; header only
00034     {
00035     public:
00039         optional<std::string>& path() { return _path; }
00040         const optional<std::string>& path() const { return _path; }
00041 
00042         optional<bool>& asyncWrites() { return _useAsyncWrites; }
00043         const optional<bool>& asyncWrites() const { return _useAsyncWrites; }
00044 
00045         optional<bool>& serialized() { return _serialized; }
00046         const optional<bool>& serialized() const { return _serialized; }
00047 
00048         optional<unsigned int>& maxSize() { return _maxSize; }
00049         const optional<unsigned int>& maxSize() const { return _maxSize; }
00050 
00051 
00052     public:
00053         Sqlite3CacheOptions( const ConfigOptions& options =ConfigOptions() )
00054             : CacheOptions( options ),
00055               _useAsyncWrites( true ), 
00056               _serialized( false ),
00057               _maxSize(100)
00058         {
00059             setDriver( "sqlite3" );
00060             fromConfig( _conf );
00061         }
00062 
00063         Config getConfig() const {
00064             Config conf = CacheOptions::getConfig();
00065             conf.updateIfSet( "path", _path );
00066             conf.updateIfSet( "async_writes", _useAsyncWrites );
00067             conf.updateIfSet( "serialized", _serialized );
00068             conf.updateIfSet( "max_size", _maxSize );
00069             return conf;
00070         }
00071 
00072         void mergeConfig( const Config& conf ) {
00073             CacheOptions::mergeConfig( conf );
00074             fromConfig( conf );
00075         }
00076 
00077         void fromConfig( const Config& conf ) {
00078             conf.getIfSet( "path", _path );
00079             conf.getIfSet( "async_writes", _useAsyncWrites );
00080             conf.getIfSet( "serialized", _serialized );
00081             conf.getIfSet( "max_size", _maxSize );
00082         }
00083 
00084         optional<std::string> _path;
00085         optional<bool> _useAsyncWrites;
00086         optional<bool> _serialized;
00087         optional<unsigned int>_maxSize; // layer - MB
00088     };
00089 
00090 } } // namespace osgEarth::Drivers
00091 
00092 #endif // OSGEARTH_DRIVER_SQLITE3_CACHE_DRIVEROPTIONS
00093 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines