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
qgsfeatureiterator.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsfeatureiterator.h
3
---------------------
4
begin : Juli 2012
5
copyright : (C) 2012 by Martin Dobias
6
email : wonder dot sk at gmail dot com
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
#ifndef QGSFEATUREITERATOR_H
16
#define QGSFEATUREITERATOR_H
17
18
#include "
qgsfeaturerequest.h
"
19
#include "
qgslogger.h
"
20
21
class
QgsAbstractGeometrySimplifier
;
22
26
class
CORE_EXPORT
QgsAbstractFeatureIterator
27
{
28
public
:
30
QgsAbstractFeatureIterator
(
const
QgsFeatureRequest
& request );
31
33
virtual
~
QgsAbstractFeatureIterator
();
34
36
virtual
bool
nextFeature(
QgsFeature
& f );
37
39
virtual
bool
rewind() = 0;
41
virtual
bool
close() = 0;
42
43
protected
:
51
virtual
bool
fetchFeature(
QgsFeature
& f ) = 0;
52
63
virtual
bool
nextFeatureFilterExpression(
QgsFeature
&f );
64
76
virtual
bool
nextFeatureFilterFids(
QgsFeature
& f );
77
79
QgsFeatureRequest
mRequest
;
80
82
bool
mClosed
;
83
85
int
refs
;
86
void
ref();
87
void
deref();
88
friend
class
QgsFeatureIterator
;
89
91
virtual
bool
prepareSimplification(
const
QgsSimplifyMethod
& simplifyMethod );
92
93
private
:
95
QgsAbstractGeometrySimplifier
* mGeometrySimplifier;
97
bool
mLocalSimplification;
98
100
virtual
bool
providerCanSimplify(
QgsSimplifyMethod::MethodType
methodType )
const
;
101
103
virtual
bool
simplify(
QgsFeature
& feature );
104
};
105
106
107
109
template
<
typename
T>
110
class
QgsAbstractFeatureIteratorFromSource
:
public
QgsAbstractFeatureIterator
111
{
112
public
:
113
QgsAbstractFeatureIteratorFromSource
( T* source,
bool
ownSource,
const
QgsFeatureRequest
& request )
114
:
QgsAbstractFeatureIterator
( request ),
mSource
( source ),
mOwnSource
( ownSource )
115
{
116
mSource
->iteratorOpened(
this
);
117
}
118
119
~QgsAbstractFeatureIteratorFromSource
()
120
{
121
if
(
mOwnSource
)
122
delete
mSource
;
123
}
124
125
protected
:
127
void
iteratorClosed
() {
mSource
->iteratorClosed(
this
); }
128
129
T*
mSource
;
130
bool
mOwnSource
;
131
};
132
133
134
139
class
CORE_EXPORT
QgsFeatureIterator
140
{
141
public
:
143
QgsFeatureIterator
();
145
QgsFeatureIterator
(
QgsAbstractFeatureIterator
* iter );
147
QgsFeatureIterator
(
const
QgsFeatureIterator
& fi );
149
~
QgsFeatureIterator
();
150
151
QgsFeatureIterator
& operator=(
const
QgsFeatureIterator
& other );
152
153
bool
nextFeature(
QgsFeature
& f );
154
bool
rewind();
155
bool
close();
156
158
bool
isClosed()
const
;
159
160
friend
bool
operator==
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 );
161
friend
bool
operator!=
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 );
162
163
protected
:
164
QgsAbstractFeatureIterator
*
mIter
;
165
};
166
168
169
inline
QgsFeatureIterator::QgsFeatureIterator
()
170
: mIter( NULL )
171
{
172
}
173
174
inline
QgsFeatureIterator::QgsFeatureIterator
(
QgsAbstractFeatureIterator
* iter )
175
: mIter( iter )
176
{
177
if
( iter )
178
iter->
ref
();
179
}
180
181
inline
QgsFeatureIterator::QgsFeatureIterator
(
const
QgsFeatureIterator
& fi )
182
: mIter( fi.mIter )
183
{
184
if
(
mIter
)
185
mIter
->
ref
();
186
}
187
188
inline
QgsFeatureIterator::~QgsFeatureIterator
()
189
{
190
if
(
mIter
)
191
mIter
->
deref
();
192
}
193
194
inline
bool
QgsFeatureIterator::nextFeature
(
QgsFeature
& f )
195
{
196
return
mIter
?
mIter
->
nextFeature
( f ) :
false
;
197
}
198
199
inline
bool
QgsFeatureIterator::rewind
()
200
{
201
return
mIter
?
mIter
->
rewind
() :
false
;
202
}
203
204
inline
bool
QgsFeatureIterator::close
()
205
{
206
return
mIter
?
mIter
->
close
() :
false
;
207
}
208
209
inline
bool
QgsFeatureIterator::isClosed
()
const
210
{
211
return
mIter
?
mIter
->
mClosed
:
true
;
212
}
213
214
inline
bool
operator==
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 )
215
{
216
return
( fi1.
mIter
== fi2.
mIter
);
217
}
218
219
inline
bool
operator!=
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 )
220
{
221
return
!( fi1 == fi2 );
222
}
223
224
#endif // QGSFEATUREITERATOR_H
Generated on Sun May 10 2015 16:33:24 for QGIS API Documentation by
1.8.1.2