QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
QgsAbstractFeatureIterator Class Referenceabstract

Internal feature iterator to be implemented within data providers. More...

#include <qgsfeatureiterator.h>

Inheritance diagram for QgsAbstractFeatureIterator:
Inheritance graph
[legend]
Collaboration diagram for QgsAbstractFeatureIterator:
Collaboration graph
[legend]

Public Member Functions

 QgsAbstractFeatureIterator (const QgsFeatureRequest &request)
 base class constructor - stores the iteration parameters More...
 
virtual ~QgsAbstractFeatureIterator ()
 destructor makes sure that the iterator is closed properly More...
 
virtual bool nextFeature (QgsFeature &f)
 fetch next feature, return true on success More...
 
virtual bool rewind ()=0
 reset the iterator to the starting position More...
 
virtual bool close ()=0
 end of iterating: free the resources / lock More...
 

Protected Member Functions

virtual bool fetchFeature (QgsFeature &f)=0
 If you write a feature iterator for your provider, this is the method you need to implement!! More...
 
virtual bool nextFeatureFilterExpression (QgsFeature &f)
 By default, the iterator will fetch all features and check if the feature matches the expression. More...
 
virtual bool nextFeatureFilterFids (QgsFeature &f)
 By default, the iterator will fetch all features and check if the id is in the request. More...
 
void ref ()
 add reference More...
 
void deref ()
 remove reference, delete if refs == 0 More...
 
virtual bool prepareSimplification (const QgsSimplifyMethod &simplifyMethod)
 Setup the simplification of geometries to fetch using the specified simplify method. More...
 

Protected Attributes

QgsFeatureRequest mRequest
 A copy of the feature request. More...
 
bool mClosed
 Set to true, as soon as the iterator is closed. More...
 
int refs
 reference counting (to allow seamless copying of QgsFeatureIterator instances) More...
 

Private Member Functions

virtual bool providerCanSimplify (QgsSimplifyMethod::MethodType methodType) const
 returns whether the iterator supports simplify geometries on provider side More...
 
virtual bool simplify (QgsFeature &feature)
 simplify the specified geometry if it was configured More...
 

Private Attributes

QgsAbstractGeometrySimplifiermGeometrySimplifier
 optional object to locally simplify geometries fetched by this feature iterator More...
 
bool mLocalSimplification
 this iterator runs local simplification More...
 

Friends

class QgsFeatureIterator
 

Detailed Description

Internal feature iterator to be implemented within data providers.

Definition at line 26 of file qgsfeatureiterator.h.

Constructor & Destructor Documentation

QgsAbstractFeatureIterator::QgsAbstractFeatureIterator ( const QgsFeatureRequest request)

base class constructor - stores the iteration parameters

Definition at line 21 of file qgsfeatureiterator.cpp.

QgsAbstractFeatureIterator::~QgsAbstractFeatureIterator ( )
virtual

destructor makes sure that the iterator is closed properly

Definition at line 30 of file qgsfeatureiterator.cpp.

References mGeometrySimplifier.

Member Function Documentation

virtual bool QgsAbstractFeatureIterator::close ( )
pure virtual
void QgsAbstractFeatureIterator::deref ( )
protected

remove reference, delete if refs == 0

Definition at line 99 of file qgsfeatureiterator.cpp.

References refs.

Referenced by QgsFeatureIterator::operator=(), and QgsFeatureIterator::~QgsFeatureIterator().

virtual bool QgsAbstractFeatureIterator::fetchFeature ( QgsFeature f)
protectedpure virtual

If you write a feature iterator for your provider, this is the method you need to implement!!

Parameters
fThe feature to write to
Returns
true if a feature was written to f

Implemented in QgsCachedFeatureWriterIterator, QgsVectorLayerFeatureIterator, and QgsCachedFeatureIterator.

Referenced by nextFeature(), nextFeatureFilterExpression(), QgsVectorLayerFeatureIterator::nextFeatureFilterExpression(), nextFeatureFilterFids(), and QgsCachedFeatureIterator::nextFeatureFilterFids().

bool QgsAbstractFeatureIterator::nextFeature ( QgsFeature f)
virtual
bool QgsAbstractFeatureIterator::nextFeatureFilterExpression ( QgsFeature f)
protectedvirtual

By default, the iterator will fetch all features and check if the feature matches the expression.

If you have a more sophisticated metodology (SQL request for the features...) and you check for the expression in your fetchFeature method, you can just redirect this call to fetchFeature so the default check will be omitted.

Parameters
fThe feature to write to
Returns
true if a feature was written to f

Reimplemented in QgsVectorLayerFeatureIterator.

Definition at line 65 of file qgsfeatureiterator.cpp.

References QgsExpression::evaluate(), fetchFeature(), QgsFeatureRequest::filterExpression(), and mRequest.

Referenced by nextFeature().

bool QgsAbstractFeatureIterator::nextFeatureFilterFids ( QgsFeature f)
protectedvirtual

By default, the iterator will fetch all features and check if the id is in the request.

If you have a more sophisticated metodology (SQL request for the features...) and you are sure, that any feature you return from fetchFeature will match if the request was FilterFids you can just redirect this call to fetchFeature so the default check will be omitted.

Parameters
fThe feature to write to
Returns
true if a feature was written to f

Reimplemented in QgsCachedFeatureIterator.

Definition at line 75 of file qgsfeatureiterator.cpp.

References fetchFeature(), QgsFeatureRequest::filterFids(), QgsFeature::id(), and mRequest.

Referenced by nextFeature().

bool QgsAbstractFeatureIterator::prepareSimplification ( const QgsSimplifyMethod simplifyMethod)
protectedvirtual
bool QgsAbstractFeatureIterator::providerCanSimplify ( QgsSimplifyMethod::MethodType  methodType) const
privatevirtual

returns whether the iterator supports simplify geometries on provider side

Reimplemented in QgsVectorLayerFeatureIterator.

Definition at line 123 of file qgsfeatureiterator.cpp.

Referenced by prepareSimplification().

void QgsAbstractFeatureIterator::ref ( )
protected
virtual bool QgsAbstractFeatureIterator::rewind ( )
pure virtual

reset the iterator to the starting position

Implemented in QgsCachedFeatureWriterIterator, QgsVectorLayerFeatureIterator, and QgsCachedFeatureIterator.

Referenced by QgsFeatureIterator::rewind().

bool QgsAbstractFeatureIterator::simplify ( QgsFeature feature)
privatevirtual

simplify the specified geometry if it was configured

Definition at line 129 of file qgsfeatureiterator.cpp.

References QgsFeature::geometry(), QGis::Line, mGeometrySimplifier, QGis::Polygon, QgsAbstractGeometrySimplifier::simplifyGeometry(), and QgsGeometry::type().

Referenced by nextFeature().

Friends And Related Function Documentation

friend class QgsFeatureIterator
friend

Definition at line 88 of file qgsfeatureiterator.h.

Member Data Documentation

bool QgsAbstractFeatureIterator::mClosed
protected
QgsAbstractGeometrySimplifier* QgsAbstractFeatureIterator::mGeometrySimplifier
private

optional object to locally simplify geometries fetched by this feature iterator

Definition at line 95 of file qgsfeatureiterator.h.

Referenced by prepareSimplification(), simplify(), and ~QgsAbstractFeatureIterator().

bool QgsAbstractFeatureIterator::mLocalSimplification
private

this iterator runs local simplification

Definition at line 97 of file qgsfeatureiterator.h.

Referenced by nextFeature(), and prepareSimplification().

QgsFeatureRequest QgsAbstractFeatureIterator::mRequest
protected
int QgsAbstractFeatureIterator::refs
protected

reference counting (to allow seamless copying of QgsFeatureIterator instances)

Definition at line 85 of file qgsfeatureiterator.h.

Referenced by deref(), and ref().


The documentation for this class was generated from the following files: