QGIS API Documentation
2.8.2-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
core
qgsvectorlayercache.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsvectorlayercache.h
3
Cache features of a vector layer
4
-------------------
5
begin : January 2013
6
copyright : (C) Matthias Kuhn
7
email : matthias dot kuhn at gmx dot ch
8
9
***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
19
#ifndef QgsVectorLayerCache_H
20
#define QgsVectorLayerCache_H
21
22
#include <QCache>
23
24
#include "
qgsvectorlayer.h
"
25
26
class
QgsCachedFeatureIterator
;
27
class
QgsAbstractCacheIndex
;
28
38
class
CORE_EXPORT
QgsVectorLayerCache
:
public
QObject
39
{
40
Q_OBJECT
41
42
private
:
48
class
QgsCachedFeature
49
{
50
public
:
57
QgsCachedFeature(
const
QgsFeature
& feat,
QgsVectorLayerCache
* vlCache )
58
: mCache( vlCache )
59
{
60
mFeature =
new
QgsFeature
( feat );
61
}
62
63
~QgsCachedFeature()
64
{
65
// That's the reason we need this wrapper:
66
// Inform the cache that this feature has been removed
67
mCache->featureRemoved( mFeature->id() );
68
delete
mFeature;
69
}
70
71
inline
const
QgsFeature
* feature() {
return
mFeature; }
72
73
private
:
74
QgsFeature
* mFeature;
75
QgsVectorLayerCache
* mCache;
76
77
friend
class
QgsVectorLayerCache
;
78
Q_DISABLE_COPY(
QgsCachedFeature
)
79
};
80
81
public
:
82
QgsVectorLayerCache
(
QgsVectorLayer
*
layer
,
int
cacheSize
, QObject* parent = NULL );
83
~QgsVectorLayerCache
();
84
91
void
setCacheSize
(
int
cacheSize );
92
100
int
cacheSize
();
101
107
void
setCacheGeometry
(
bool
cacheGeometry );
108
109
115
void
setCacheSubsetOfAttributes
(
const
QgsAttributeList
& attributes );
116
123
void
setCacheAddedAttributes
(
bool
cacheAddedAttributes );
124
135
void
setFullCache
(
bool
fullCache );
136
145
void
addCacheIndex
(
QgsAbstractCacheIndex
*cacheIndex );
146
156
QgsFeatureIterator
getFeatures
(
const
QgsFeatureRequest
& featureRequest =
QgsFeatureRequest
() );
157
163
bool
isFidCached
(
const
QgsFeatureId
fid );
164
172
bool
featureAtId
(
QgsFeatureId
featureId,
QgsFeature
&feature,
bool
skipCache =
false
);
173
179
bool
removeCachedFeature
(
QgsFeatureId
fid );
180
184
QgsVectorLayer
*
layer
();
185
186
protected
:
195
void
requestCompleted
(
QgsFeatureRequest
featureRequest,
QgsFeatureIds
fids );
196
204
void
featureRemoved
(
QgsFeatureId
fid );
205
216
bool
checkInformationCovered
(
const
QgsFeatureRequest
& featureRequest );
217
218
219
signals:
220
230
void
progress
(
int
i,
bool
& cancel );
231
235
void
finished
();
236
242
void
cachedLayerDeleted
();
243
248
void
attributeValueChanged
(
const
QgsFeatureId
& fid,
const
int
& field,
const
QVariant &value );
249
257
void
featureAdded
(
QgsFeatureId
fid );
258
259
private
slots:
260
void
onAttributeValueChanged(
QgsFeatureId
fid,
int
field,
const
QVariant& value );
261
void
featureDeleted(
QgsFeatureId
fid );
262
void
onFeatureAdded(
QgsFeatureId
fid );
263
void
attributeAdded(
int
field );
264
void
attributeDeleted(
int
field );
265
void
geometryChanged(
QgsFeatureId
fid,
QgsGeometry
& geom );
266
void
layerDeleted();
267
void
updatedFields();
268
269
private
:
270
271
inline
void
cacheFeature(
QgsFeature
& feat )
272
{
273
QgsCachedFeature
* cachedFeature =
new
QgsCachedFeature
( feat,
this
);
274
mCache.insert( feat.
id
(), cachedFeature );
275
}
276
277
QgsVectorLayer
* mLayer;
278
QCache< QgsFeatureId, QgsCachedFeature > mCache;
279
280
bool
mCacheGeometry;
281
bool
mFullCache;
282
QList<QgsAbstractCacheIndex*> mCacheIndices;
283
284
QgsAttributeList
mCachedAttributes;
285
286
friend
class
QgsCachedFeatureIterator
;
287
friend
class
QgsCachedFeatureWriterIterator
;
288
friend
class
QgsCachedFeature;
289
};
290
#endif // QgsVectorLayerCache_H
Generated on Sun May 10 2015 16:33:25 for QGIS API Documentation by
1.8.1.2