QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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:106
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
Gets feature IDs that should be fetched.
Definition: qgsfeaturerequest.h:358
QgsVectorLayerCache
The cached features can be indexed by QgsAbstractCacheIndex.
Definition: qgsvectorlayercache.h:45
QgsFeatureRequest::filterFid
QgsFeatureId filterFid() const
Gets the feature ID that should be fetched.
Definition: qgsfeaturerequest.h:353
QgsFeatureRequest::filterType
FilterType filterType() const
Returns the filter type which is currently set on this request.
Definition: qgsfeaturerequest.h:325
QgsFeatureRequest::FilterFids
@ FilterFids
Filter using feature IDs.
Definition: qgsfeaturerequest.h:108
qgscachedfeatureiterator.h
QgsFeatureRequest
Definition: qgsfeaturerequest.h:75
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:107
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
QgsVectorLayerCache::isFidCached
bool isFidCached(QgsFeatureId fid) const
Check if a certain feature id is cached.
Definition: qgsvectorlayercache.cpp:424
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:163
QgsCachedFeatureIterator
Delivers features from the cache.
Definition: qgscachedfeatureiterator.h:31
QgsFeatureRequest::FilterNone
@ FilterNone
No filter is applied.
Definition: qgsfeaturerequest.h:105
QgsFeatureIterator
Definition: qgsfeatureiterator.h:263
QgsCacheIndexFeatureId::QgsCacheIndexFeatureId
QgsCacheIndexFeatureId(QgsVectorLayerCache *)
Definition: qgscacheindexfeatureid.cpp:21
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QgsVectorLayerCache::cachedFeatureIds
QgsFeatureIds cachedFeatureIds() const
Returns the set of feature IDs for features which are cached.
Definition: qgsvectorlayercache.h:234