~ubuntu-branches/ubuntu/saucy/qgis/saucy

« back to all changes in this revision

Viewing changes to src/core/spatialindex/storagemanager/Buffer.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Spatial Index Library
 
2
//
 
3
// Copyright (C) 2002 Navel Ltd.
 
4
//
 
5
// This library is free software; you can redistribute it and/or
 
6
// modify it under the terms of the GNU Lesser General Public
 
7
// License as published by the Free Software Foundation; either
 
8
// version 2.1 of the License, or (at your option) any later version.
 
9
//
 
10
// This library is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
// Lesser General Public License for more details.
 
14
//
 
15
// You should have received a copy of the GNU Lesser General Public
 
16
// License along with this library; if not, write to the Free Software
 
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
//
 
19
//  Email:
 
20
//    mhadji@gmail.com
 
21
 
 
22
#ifndef __storagemanager_buffer_h
 
23
#define __storagemanager_buffer_h
 
24
 
 
25
#include <cstring>
 
26
 
 
27
namespace SpatialIndex
 
28
{
 
29
  namespace StorageManager
 
30
  {
 
31
    class Buffer : public IBuffer
 
32
    {
 
33
      public:
 
34
        Buffer( IStorageManager& sm, Tools::PropertySet& ps );
 
35
        // String                   Value     Description
 
36
        // ----------------------------------------------
 
37
        // Capacity  VT_ULONG Buffer maximum capacity.
 
38
        // WriteThrough VT_BOOL Enable or disable write through policy.
 
39
 
 
40
        virtual ~Buffer();
 
41
 
 
42
        virtual void loadByteArray( const long id, unsigned long& len, byte** data );
 
43
        virtual void storeByteArray( long& id, const unsigned long len, const byte* const data );
 
44
        virtual void deleteByteArray( const long id );
 
45
 
 
46
        virtual void clear();
 
47
        virtual unsigned long getHits();
 
48
 
 
49
      protected:
 
50
        class Entry
 
51
        {
 
52
          public:
 
53
            Entry( unsigned long l, const byte* const d ) : m_pData( 0 ), m_length( l ), m_bDirty( false )
 
54
            {
 
55
              m_pData = new byte[m_length];
 
56
              memcpy( m_pData, d, m_length );
 
57
            }
 
58
 
 
59
            ~Entry() { delete[] m_pData; }
 
60
 
 
61
            byte* m_pData;
 
62
            unsigned long m_length;
 
63
            bool m_bDirty;
 
64
        }; // Entry
 
65
 
 
66
        virtual void addEntry( long id, Entry* pEntry ) = 0;
 
67
        virtual void removeEntry() = 0;
 
68
 
 
69
        unsigned long m_capacity;
 
70
        bool m_bWriteThrough;
 
71
        IStorageManager* m_pStorageManager;
 
72
        std::map<long, Entry*> m_buffer;
 
73
        unsigned long m_hits;
 
74
    }; // Buffer
 
75
  }
 
76
}
 
77
 
 
78
#endif /*__storagemanager_buffer_h*/