QGIS API Documentation  2.99.0-Master (08ee180)
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 
23  , C( cachedVectorLayer )
24 {
25 
26 }
27 
29 {
30  Q_UNUSED( fid )
31 }
32 
34 {
35 }
36 
38 {
39  Q_UNUSED( featureRequest )
40  Q_UNUSED( fids )
41 }
42 
43 bool QgsCacheIndexFeatureId::getCacheIterator( QgsFeatureIterator &featureIterator, const QgsFeatureRequest &featureRequest )
44 {
45  switch ( featureRequest.filterType() )
46  {
48  {
49  if ( C->isFidCached( featureRequest.filterFid() ) )
50  {
51  featureIterator = QgsFeatureIterator( new QgsCachedFeatureIterator( C, featureRequest ) );
52  return true;
53  }
54  break;
55  }
57  {
58  if ( C->cachedFeatureIds().contains( featureRequest.filterFids() ) )
59  {
60  featureIterator = QgsFeatureIterator( new QgsCachedFeatureIterator( C, featureRequest ) );
61  return true;
62  }
63  break;
64  }
68  {
69  if ( C->hasFullCache() )
70  {
71  featureIterator = QgsFeatureIterator( new QgsCachedFeatureIterator( C, featureRequest ) );
72  return true;
73  }
74  break;
75  }
76  }
77 
78  return false;
79 }
80 
Wrapper for iterator of features from vector data provider or vector layer.
virtual 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...
Filter using feature ID.
Filter using feature IDs.
QgsFeatureId filterFid() const
Get the feature ID that should be fetched.
bool isFidCached(const QgsFeatureId fid) const
Check if a certain feature id is cached.
virtual void flushFeature(const QgsFeatureId fid) override
Is called, whenever a feature is removed from the cache.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:355
const QgsFeatureIds & filterFids() const
Get feature IDs that should be fetched.
QgsFeatureIds cachedFeatureIds() const
Returns the set of feature IDs for features which are cached.
QgsCacheIndexFeatureId(QgsVectorLayerCache *)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Obsolete, will be ignored. If a filterRect is set it will be used anyway. Filter using a rectangle...
FilterType filterType() const
Return the filter type which is currently set on this request.
bool hasFullCache() const
Returns true if the cache is complete, ie it contains all features.
This class caches features of a given QgsVectorLayer.
Abstract base class for cache indices.
Definition: qgscacheindex.h:29
No filter is applied.
qint64 QgsFeatureId
Definition: qgsfeature.h:32
Delivers features from the cache.
virtual void flush() override
Sometimes, the whole cache changes its state and its easier to just withdraw everything.
virtual bool getCacheIterator(QgsFeatureIterator &featureIterator, const QgsFeatureRequest &featureRequest) override
Is called, when a feature request is issued on a cached layer.