QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgscacheindexfeatureid.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscacheindexfeatureid.cpp
3 --------------------------------------
4 Date : 13.2.2013
5 Copyright : (C) 2013 Matthias Kuhn
6 Email : matthias at opengis 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
17#include "qgsfeaturerequest.h"
19#include "qgsvectorlayercache.h"
20
22 : C( cachedVectorLayer )
23{
24
25}
26
28{
29 Q_UNUSED( fid )
30}
31
33{
34}
35
37{
38 Q_UNUSED( featureRequest )
39 Q_UNUSED( fids )
40}
41
43{
44 switch ( featureRequest.filterType() )
45 {
47 {
48 if ( C->isFidCached( featureRequest.filterFid() ) )
49 {
50 featureIterator = QgsFeatureIterator( new QgsCachedFeatureIterator( C, featureRequest ) );
51 return true;
52 }
53 break;
54 }
56 {
57 if ( C->cachedFeatureIds().contains( featureRequest.filterFids() ) )
58 {
59 featureIterator = QgsFeatureIterator( new QgsCachedFeatureIterator( C, featureRequest ) );
60 return true;
61 }
62 break;
63 }
66 {
67 if ( C->hasFullCache() )
68 {
69 featureIterator = QgsFeatureIterator( new QgsCachedFeatureIterator( C, featureRequest ) );
70 return true;
71 }
72 break;
73 }
74 }
75
76 return false;
77}
78
QgsCacheIndexFeatureId(QgsVectorLayerCache *)
void requestCompleted(const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids) override
Implement this method to update the the indices, in case you need information contained by the reques...
void flush() override
Sometimes, the whole cache changes its state and its easier to just withdraw everything.
bool getCacheIterator(QgsFeatureIterator &featureIterator, const QgsFeatureRequest &featureRequest) override
Is called when a feature request is issued on a cached layer.
void flushFeature(QgsFeatureId fid) override
Is called whenever a feature is removed from the cache.
Delivers features from the cache.
Wrapper for iterator of features from vector data provider or vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
FilterType filterType() const
Returns the attribute/ID filter type which is currently set on this request.
@ FilterFid
Filter using feature ID.
@ FilterFids
Filter using feature IDs.
@ FilterNone
No filter is applied.
@ FilterExpression
Filter using expression.
const QgsFeatureIds & filterFids() const
Returns the feature IDs that should be fetched.
QgsFeatureId filterFid() const
Returns the feature ID that should be fetched.
This class caches features of a given QgsVectorLayer.
bool isFidCached(QgsFeatureId fid) const
Check if a certain feature id is cached.
bool hasFullCache() const
Returns true if the cache is complete, ie it contains all features.
QgsFeatureIds cachedFeatureIds() const
Returns the set of feature IDs for features which are cached.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28