QGIS API Documentation
2.0.1-Dufour
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
qgscachedfeatureiterator.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgscachedfeatureiterator.cpp
3
--------------------------------------
4
Date : 12.2.2013
5
Copyright : (C) 2013 Matthias Kuhn
6
Email : matthias dot kuhn at gmx dot ch
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgscachedfeatureiterator.h
"
17
#include "
qgsvectorlayercache.h
"
18
19
QgsCachedFeatureIterator::QgsCachedFeatureIterator
(
QgsVectorLayerCache
*vlCache,
QgsFeatureRequest
featureRequest,
QgsFeatureIds
featureIds )
20
:
QgsAbstractFeatureIterator
( featureRequest )
21
, mFeatureIds( featureIds )
22
, mVectorLayerCache( vlCache )
23
{
24
mFeatureIdIterator
= featureIds.begin();
25
}
26
27
bool
QgsCachedFeatureIterator::nextFeature
(
QgsFeature
& f )
28
{
29
mFeatureIdIterator
++;
30
31
if
(
mFeatureIdIterator
==
mFeatureIds
.end() )
32
{
33
return
false
;
34
}
35
else
36
{
37
f =
QgsFeature
( *
mVectorLayerCache
->
mCache
[*
mFeatureIdIterator
]->feature() );
38
return
true
;
39
}
40
}
41
42
bool
QgsCachedFeatureIterator::rewind
()
43
{
44
mFeatureIdIterator
=
mFeatureIds
.begin();
45
return
true
;
46
}
47
48
bool
QgsCachedFeatureIterator::close
()
49
{
50
// Nothing to clean...
51
return
true
;
52
}
53
54
QgsCachedFeatureWriterIterator::QgsCachedFeatureWriterIterator
(
QgsVectorLayerCache
*vlCache,
QgsFeatureRequest
featureRequest )
55
:
QgsAbstractFeatureIterator
( featureRequest )
56
, mVectorLayerCache( vlCache )
57
{
58
mFeatIt
= vlCache->
layer
()->
getFeatures
( featureRequest );
59
}
60
61
bool
QgsCachedFeatureWriterIterator::nextFeature
(
QgsFeature
& f )
62
{
63
if
(
mFeatIt
.
nextFeature
( f ) )
64
{
65
// As long as features can be fetched from the provider: Write them to cache
66
mVectorLayerCache
->
cacheFeature
( f );
67
mFids
.insert( f.
id
() );
68
return
true
;
69
}
70
else
71
{
72
// Once no more features can be fetched: Inform the cache, that
73
// the request has been completed
74
mVectorLayerCache
->
requestCompleted
(
mRequest
,
mFids
);
75
return
false
;
76
}
77
}
78
79
bool
QgsCachedFeatureWriterIterator::rewind
()
80
{
81
mFids
.clear();
82
return
mFeatIt
.
rewind
();
83
}
84
85
bool
QgsCachedFeatureWriterIterator::close
()
86
{
87
return
mFeatIt
.
close
();
88
}
Generated on Tue Sep 24 2013 14:41:46 for QGIS API Documentation by
1.8.1.2