QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
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 
16 #include "qgscacheindexfeatureid.h"
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 
42 bool QgsCacheIndexFeatureId::getCacheIterator( QgsFeatureIterator &featureIterator, const QgsFeatureRequest &featureRequest )
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 
@ Fid
Filter using feature ID.
@ Fids
Filter using feature IDs.
@ Expression
Filter using expression.
@ NoFilter
No filter is applied.
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).
Qgis::FeatureRequestFilterType filterType() const
Returns the attribute/ID filter type which is currently set on this request.
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