QGIS API Documentation  2.99.0-Master (e077efd)
Public Types | Public Member Functions | Protected Member Functions | Protected 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]

Public Types

enum  CompileStatus { NoCompilation, PartiallyCompiled, Compiled }
 Status of expression compilation for filter expression requests. More...
 

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 close ()=0
 end of iterating: free the resources / lock More...
 
CompileStatus compileStatus () const
 Returns the status of expression compilation for filter expression requests. 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 void setInterruptionChecker (QgsInterruptionChecker *interruptionChecker)
 Attach an object that can be queried regularly by the iterator to check if it must stopped. More...
 

Protected Member Functions

void deref ()
 Remove reference, delete if refs == 0. More...
 
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...
 
virtual bool prepareSimplification (const QgsSimplifyMethod &simplifyMethod)
 Setup the simplification of geometries to fetch using the specified simplify method. More...
 
void ref ()
 Add reference. More...
 

Protected Attributes

bool mClosed
 Set to true, as soon as the iterator is closed. More...
 
CompileStatus mCompileStatus
 Status of compilation of filter expression. More...
 
long mFetchedCount
 Number of features already fetched by iterator. More...
 
QgsFeatureRequest mRequest
 A copy of the feature request. More...
 
bool mZombie
 A feature iterator may be closed already but still be serving features from the cache. More...
 
int refs
 reference counting (to allow seamless copying of QgsFeatureIterator instances) TODO QGIS3: make this private More...
 

Friends

class QgsFeatureIterator
 

Detailed Description

Internal feature iterator to be implemented within data providers.

Definition at line 38 of file qgsfeatureiterator.h.

Member Enumeration Documentation

§ CompileStatus

Status of expression compilation for filter expression requests.

Enumerator
NoCompilation 

Expression could not be compiled or not attempt was made to compile expression.

PartiallyCompiled 

Expression was partially compiled, but extra checks need to be applied to features.

Compiled 

Expression was fully compiled and delegated to data provider source.

Definition at line 43 of file qgsfeatureiterator.h.

Constructor & Destructor Documentation

§ QgsAbstractFeatureIterator()

QgsAbstractFeatureIterator::QgsAbstractFeatureIterator ( const QgsFeatureRequest request)

base class constructor - stores the iteration parameters

Definition at line 22 of file qgsfeatureiterator.cpp.

§ ~QgsAbstractFeatureIterator()

QgsAbstractFeatureIterator::~QgsAbstractFeatureIterator ( )
virtual

destructor makes sure that the iterator is closed properly

Definition at line 33 of file qgsfeatureiterator.cpp.

Member Function Documentation

§ close()

virtual bool QgsAbstractFeatureIterator::close ( )
pure virtual

end of iterating: free the resources / lock

Implemented in QgsCachedFeatureWriterIterator, QgsVectorLayerFeatureIterator, and QgsCachedFeatureIterator.

§ compileStatus()

CompileStatus QgsAbstractFeatureIterator::compileStatus ( ) const
inline

Returns the status of expression compilation for filter expression requests.

Note
added in QGIS 2.16

Definition at line 77 of file qgsfeatureiterator.h.

§ deref()

void QgsAbstractFeatureIterator::deref ( )
protected

Remove reference, delete if refs == 0.

Definition at line 122 of file qgsfeatureiterator.cpp.

§ fetchFeature()

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.

§ nextFeature()

bool QgsAbstractFeatureIterator::nextFeature ( QgsFeature f)
virtual

fetch next feature, return true on success

Definition at line 37 of file qgsfeatureiterator.cpp.

§ nextFeatureFilterExpression()

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 84 of file qgsfeatureiterator.cpp.

§ nextFeatureFilterFids()

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 95 of file qgsfeatureiterator.cpp.

§ prepareSimplification()

bool QgsAbstractFeatureIterator::prepareSimplification ( const QgsSimplifyMethod simplifyMethod)
protectedvirtual

Setup the simplification of geometries to fetch using the specified simplify method.

Reimplemented in QgsVectorLayerFeatureIterator.

Definition at line 129 of file qgsfeatureiterator.cpp.

§ ref()

void QgsAbstractFeatureIterator::ref ( )
protected

Add reference.

Definition at line 105 of file qgsfeatureiterator.cpp.

§ rewind()

virtual bool QgsAbstractFeatureIterator::rewind ( )
pure virtual

reset the iterator to the starting position

Implemented in QgsCachedFeatureWriterIterator, QgsVectorLayerFeatureIterator, and QgsCachedFeatureIterator.

§ setInterruptionChecker()

void QgsAbstractFeatureIterator::setInterruptionChecker ( QgsInterruptionChecker interruptionChecker)
virtual

Attach an object that can be queried regularly by the iterator to check if it must stopped.

This is mostly useful for iterators where a single nextFeature()/fetchFeature() iteration might be very long. A typical use case is the WFS provider. When nextFeature()/fetchFeature() is reasonably fast, it is not necessary to implement this method. The default implementation does nothing.

Note
added in QGIS 2.16
not available in Python bindings

Reimplemented in QgsVectorLayerFeatureIterator.

Definition at line 193 of file qgsfeatureiterator.cpp.

Friends And Related Function Documentation

§ QgsFeatureIterator

friend class QgsFeatureIterator
friend

Definition at line 135 of file qgsfeatureiterator.h.

Member Data Documentation

§ mClosed

bool QgsAbstractFeatureIterator::mClosed
protected

Set to true, as soon as the iterator is closed.

Definition at line 119 of file qgsfeatureiterator.h.

§ mCompileStatus

CompileStatus QgsAbstractFeatureIterator::mCompileStatus
protected

Status of compilation of filter expression.

Definition at line 141 of file qgsfeatureiterator.h.

§ mFetchedCount

long QgsAbstractFeatureIterator::mFetchedCount
protected

Number of features already fetched by iterator.

Definition at line 138 of file qgsfeatureiterator.h.

§ mRequest

QgsFeatureRequest QgsAbstractFeatureIterator::mRequest
protected

A copy of the feature request.

Definition at line 116 of file qgsfeatureiterator.h.

§ mZombie

bool QgsAbstractFeatureIterator::mZombie
protected

A feature iterator may be closed already but still be serving features from the cache.

This is done when we serve features which have been pre-fetched and the order by has been locally sorted. In such a scenario, all resources have been released (mClosed is true) but the deads are still alive.

Definition at line 128 of file qgsfeatureiterator.h.

§ refs

int QgsAbstractFeatureIterator::refs
protected

reference counting (to allow seamless copying of QgsFeatureIterator instances) TODO QGIS3: make this private

Definition at line 132 of file qgsfeatureiterator.h.


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