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
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
20
24
class
CORE_EXPORT
QgsAbstractFeatureIterator
25
{
26
public
:
28
QgsAbstractFeatureIterator
(
const
QgsFeatureRequest
& request );
29
31
virtual
~
QgsAbstractFeatureIterator
();
32
34
virtual
bool
nextFeature(
QgsFeature
& f ) = 0;
36
virtual
bool
rewind() = 0;
38
virtual
bool
close() = 0;
39
40
protected
:
41
QgsFeatureRequest
mRequest
;
42
43
bool
mClosed
;
44
45
// reference counting (to allow seamless copying of QgsFeatureIterator instances)
46
int
refs
;
47
void
ref();
// add reference
48
void
deref();
// remove reference, delete if refs == 0
49
friend
class
QgsFeatureIterator
;
50
};
51
52
57
class
CORE_EXPORT
QgsFeatureIterator
58
{
59
public
:
61
QgsFeatureIterator
();
63
QgsFeatureIterator
(
QgsAbstractFeatureIterator
* iter );
65
QgsFeatureIterator
(
const
QgsFeatureIterator
& fi );
67
~
QgsFeatureIterator
();
68
69
QgsFeatureIterator
& operator=(
const
QgsFeatureIterator
& other );
70
71
bool
nextFeature(
QgsFeature
& f );
72
bool
rewind();
73
bool
close();
74
76
bool
isClosed()
const
;
77
78
friend
bool
operator==
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 );
79
friend
bool
operator!=
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 );
80
81
protected
:
82
QgsAbstractFeatureIterator
*
mIter
;
83
};
84
86
87
inline
QgsFeatureIterator::QgsFeatureIterator
()
88
: mIter( NULL )
89
{
90
}
91
92
inline
QgsFeatureIterator::QgsFeatureIterator
(
QgsAbstractFeatureIterator
* iter )
93
: mIter( iter )
94
{
95
if
( iter )
96
iter->
ref
();
97
}
98
99
inline
QgsFeatureIterator::QgsFeatureIterator
(
const
QgsFeatureIterator
& fi )
100
: mIter( fi.mIter )
101
{
102
if
(
mIter
)
103
mIter
->
ref
();
104
}
105
106
inline
QgsFeatureIterator::~QgsFeatureIterator
()
107
{
108
if
(
mIter
)
109
mIter
->
deref
();
110
}
111
112
inline
bool
QgsFeatureIterator::nextFeature
(
QgsFeature
& f )
113
{
114
return
mIter
?
mIter
->
nextFeature
( f ) :
false
;
115
}
116
117
inline
bool
QgsFeatureIterator::rewind
()
118
{
119
return
mIter
?
mIter
->
rewind
() :
false
;
120
}
121
122
inline
bool
QgsFeatureIterator::close
()
123
{
124
return
mIter
?
mIter
->
close
() :
false
;
125
}
126
127
inline
bool
QgsFeatureIterator::isClosed
()
const
128
{
129
return
mIter
?
mIter
->
mClosed
:
true
;
130
}
131
132
inline
bool
operator==
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 )
133
{
134
return
( fi1.
mIter
== fi2.
mIter
);
135
}
136
137
inline
bool
operator!=
(
const
QgsFeatureIterator
&fi1,
const
QgsFeatureIterator
&fi2 )
138
{
139
return
!( fi1 == fi2 );
140
}
141
142
#endif // QGSFEATUREITERATOR_H
Generated on Tue Sep 24 2013 14:41:46 for QGIS API Documentation by
1.8.1.2