QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
QgsFeatureRequest::FilterFid
@ FilterFid
Filter using feature ID.
Definition: qgsfeaturerequest.h:116
QgsCacheIndexFeatureId::flushFeature
void flushFeature(QgsFeatureId fid) override
Is called whenever a feature is removed from the cache.
Definition: qgscacheindexfeatureid.cpp:27
qgsfeaturerequest.h
qgsvectorlayercache.h
QgsFeatureRequest::filterFids
const QgsFeatureIds & filterFids() const
Returns the feature IDs that should be fetched.
Definition: qgsfeaturerequest.h:492
QgsVectorLayerCache
This class caches features of a given QgsVectorLayer.
Definition: qgsvectorlayercache.h:46
QgsFeatureRequest::filterFid
QgsFeatureId filterFid() const
Returns the feature ID that should be fetched.
Definition: qgsfeaturerequest.h:474
QgsFeatureRequest::filterType
FilterType filterType() const
Returns the attribute/ID filter type which is currently set on this request.
Definition: qgsfeaturerequest.h:355
QgsFeatureRequest::FilterFids
@ FilterFids
Filter using feature IDs.
Definition: qgsfeaturerequest.h:118
qgscachedfeatureiterator.h
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:83
QgsCacheIndexFeatureId::getCacheIterator
bool getCacheIterator(QgsFeatureIterator &featureIterator, const QgsFeatureRequest &featureRequest) override
Is called when a feature request is issued on a cached layer.
Definition: qgscacheindexfeatureid.cpp:42
QgsCacheIndexFeatureId::flush
void flush() override
Sometimes, the whole cache changes its state and its easier to just withdraw everything.
Definition: qgscacheindexfeatureid.cpp:32
qgscacheindexfeatureid.h
QgsFeatureRequest::FilterExpression
@ FilterExpression
Filter using expression.
Definition: qgsfeaturerequest.h:117
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
QgsVectorLayerCache::isFidCached
bool isFidCached(QgsFeatureId fid) const
Check if a certain feature id is cached.
Definition: qgsvectorlayercache.cpp:446
QgsCacheIndexFeatureId::requestCompleted
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...
Definition: qgscacheindexfeatureid.cpp:36
QgsVectorLayerCache::hasFullCache
bool hasFullCache() const
Returns true if the cache is complete, ie it contains all features.
Definition: qgsvectorlayercache.h:164
QgsCachedFeatureIterator
Delivers features from the cache.
Definition: qgscachedfeatureiterator.h:32
QgsFeatureRequest::FilterNone
@ FilterNone
No filter is applied.
Definition: qgsfeaturerequest.h:115
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:289
QgsCacheIndexFeatureId::QgsCacheIndexFeatureId
QgsCacheIndexFeatureId(QgsVectorLayerCache *)
Definition: qgscacheindexfeatureid.cpp:21
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QgsVectorLayerCache::cachedFeatureIds
QgsFeatureIds cachedFeatureIds() const
Returns the set of feature IDs for features which are cached.
Definition: qgsvectorlayercache.h:235