~ubuntu-branches/debian/sid/osgearth/sid

« back to all changes in this revision

Viewing changes to src/osgEarthDrivers/cache_sqlite3/Sqlite3CacheOptions

  • Committer: Bazaar Package Importer
  • Author(s): Pirmin Kalberer
  • Date: 2011-07-14 22:13:36 UTC
  • Revision ID: james.westby@ubuntu.com-20110714221336-94igk9rskxveh794
Tags: upstream-2.0+dfsg
ImportĀ upstreamĀ versionĀ 2.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*-c++-*- */
 
2
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 
3
 * Copyright 2008-2010 Pelican Mapping
 
4
 * http://osgearth.org
 
5
 *
 
6
 * osgEarth is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU Lesser General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 
18
 */
 
19
#ifndef OSGEARTH_DRIVER_SQLITE3_CACHE_DRIVEROPTIONS
 
20
#define OSGEARTH_DRIVER_SQLITE3_CACHE_DRIVEROPTIONS 1
 
21
 
 
22
#include <osgEarth/Common>
 
23
#include <osgEarth/Caching>
 
24
#include <osgEarth/TileSource>
 
25
 
 
26
// there is leak using the cache if compressed. It's resolved in
 
27
// rev 11609 of osg svn
 
28
 
 
29
namespace osgEarth { namespace Drivers
 
30
{
 
31
    using namespace osgEarth;
 
32
 
 
33
    class Sqlite3CacheOptions : public CacheOptions // NO EXPORT; header only
 
34
    {
 
35
    public:
 
36
        /**
 
37
         * Pathname of the database file.
 
38
         */
 
39
        optional<std::string>& path() { return _path; }
 
40
        const optional<std::string>& path() const { return _path; }
 
41
 
 
42
        optional<bool>& asyncWrites() { return _useAsyncWrites; }
 
43
        const optional<bool>& asyncWrites() const { return _useAsyncWrites; }
 
44
 
 
45
        optional<bool>& serialized() { return _serialized; }
 
46
        const optional<bool>& serialized() const { return _serialized; }
 
47
 
 
48
        optional<unsigned int>& maxSize() { return _maxSize; }
 
49
        const optional<unsigned int>& maxSize() const { return _maxSize; }
 
50
 
 
51
 
 
52
    public:
 
53
        Sqlite3CacheOptions( const ConfigOptions& options =ConfigOptions() )
 
54
            : CacheOptions( options ),
 
55
              _useAsyncWrites( true ), 
 
56
              _serialized( false ),
 
57
              _maxSize(100)
 
58
        {
 
59
            setDriver( "sqlite3" );
 
60
            fromConfig( _conf );
 
61
        }
 
62
 
 
63
        Config getConfig() const {
 
64
            Config conf = CacheOptions::getConfig();
 
65
            conf.updateIfSet( "path", _path );
 
66
            conf.updateIfSet( "async_writes", _useAsyncWrites );
 
67
            conf.updateIfSet( "serialized", _serialized );
 
68
            conf.updateIfSet( "max_size", _maxSize );
 
69
            return conf;
 
70
        }
 
71
 
 
72
        void mergeConfig( const Config& conf ) {
 
73
            CacheOptions::mergeConfig( conf );
 
74
            fromConfig( conf );
 
75
        }
 
76
 
 
77
        void fromConfig( const Config& conf ) {
 
78
            conf.getIfSet( "path", _path );
 
79
            conf.getIfSet( "async_writes", _useAsyncWrites );
 
80
            conf.getIfSet( "serialized", _serialized );
 
81
            conf.getIfSet( "max_size", _maxSize );
 
82
        }
 
83
 
 
84
        optional<std::string> _path;
 
85
        optional<bool> _useAsyncWrites;
 
86
        optional<bool> _serialized;
 
87
        optional<unsigned int>_maxSize; // layer - MB
 
88
    };
 
89
 
 
90
} } // namespace osgEarth::Drivers
 
91
 
 
92
#endif // OSGEARTH_DRIVER_SQLITE3_CACHE_DRIVEROPTIONS
 
93