QGIS API Documentation
2.2.0-Valmiera
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
};
79
80
public
:
81
QgsVectorLayerCache
(
QgsVectorLayer
*
layer
,
int
cacheSize
, QObject* parent = NULL );
82
89
void
setCacheSize
(
int
cacheSize
);
90
98
int
cacheSize
();
99
105
void
setCacheGeometry
(
bool
cacheGeometry );
106
107
113
void
setCacheSubsetOfAttributes
(
const
QgsAttributeList
& attributes );
114
121
void
setCacheAddedAttributes
(
bool
cacheAddedAttributes );
122
133
void
setFullCache
(
bool
fullCache );
134
142
void
addCacheIndex
(
QgsAbstractCacheIndex
*cacheIndex );
143
153
QgsFeatureIterator
getFeatures
(
const
QgsFeatureRequest
& featureRequest =
QgsFeatureRequest
() );
154
160
bool
isFidCached
(
const
QgsFeatureId
fid );
161
169
bool
featureAtId
(
QgsFeatureId
featureId,
QgsFeature
&feature,
bool
skipCache =
false
);
170
176
bool
removeCachedFeature
(
QgsFeatureId
fid );
177
181
QgsVectorLayer
*
layer
();
182
183
protected
:
192
void
requestCompleted
(
QgsFeatureRequest
featureRequest,
QgsFeatureIds
fids );
193
201
void
featureRemoved
(
QgsFeatureId
fid );
202
213
bool
checkInformationCovered
(
const
QgsFeatureRequest
& featureRequest );
214
215
216
signals:
217
227
void
progress
(
int
i,
bool
& cancel );
228
232
void
finished
();
233
239
void
cachedLayerDeleted
();
240
245
void
attributeValueChanged
(
const
QgsFeatureId
& fid,
const
int
& field,
const
QVariant &value );
246
254
void
featureAdded
(
QgsFeatureId
fid );
255
256
private
slots:
257
void
onAttributeValueChanged
(
QgsFeatureId
fid,
int
field,
const
QVariant& value );
258
void
featureDeleted
(
QgsFeatureId
fid );
259
void
onFeatureAdded
(
QgsFeatureId
fid );
260
void
attributeAdded
(
int
field );
261
void
attributeDeleted
(
int
field );
262
void
geometryChanged
(
QgsFeatureId
fid,
QgsGeometry
& geom );
263
void
layerDeleted
();
264
void
updatedFields
();
265
266
private
:
267
268
inline
void
cacheFeature
(
QgsFeature
& feat )
269
{
270
QgsCachedFeature
* cachedFeature =
new
QgsCachedFeature
( feat,
this
);
271
mCache
.insert( feat.
id
(), cachedFeature );
272
}
273
274
QgsVectorLayer
*
mLayer
;
275
QCache< QgsFeatureId, QgsCachedFeature >
mCache
;
276
277
bool
mCacheGeometry
;
278
bool
mFullCache
;
279
QList<QgsAbstractCacheIndex*>
mCacheIndices
;
280
281
QgsAttributeList
mCachedAttributes
;
282
283
friend
class
QgsCachedFeatureIterator
;
284
friend
class
QgsCachedFeatureWriterIterator
;
285
friend
class
QgsCachedFeature
;
286
};
287
#endif // QgsVectorLayerCache_H
Generated on Sun Feb 23 2014 14:27:19 for QGIS API Documentation by
1.8.1.2