QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
Wrapper for iterator of features from vector data provider or vector layer.
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.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
QgsFeatureId filterFid() const
Gets the feature ID that should be fetched.
const QgsFeatureIds & filterFids() const
Gets feature IDs that should be fetched.
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QgsFeatureIds cachedFeatureIds() const
Returns the set of feature IDs for features which are cached.
QgsCacheIndexFeatureId(QgsVectorLayerCache *)
bool isFidCached(QgsFeatureId fid) const
Check if a certain feature id is cached.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
FilterType filterType() const
Returns 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.
void flushFeature(QgsFeatureId fid) override
Is called, whenever a feature is removed from the cache.
No filter is applied.
Delivers features from the cache.
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.