19 #ifndef QgsVectorLayerCache_H 20 #define QgsVectorLayerCache_H 22 #include "qgis_core.h" 53 class QgsCachedFeature
73 mCache->featureRemoved( mFeature->id() );
77 inline const QgsFeature *feature() {
return mFeature; }
277 sipRes = sipCpp->featureCount();
369 void onAttributeValueChanged(
QgsFeatureId fid,
int field,
const QVariant &value );
370 void onJoinAttributeValueChanged(
QgsFeatureId fid,
int field,
const QVariant &value );
373 void attributeAdded(
int field );
374 void attributeDeleted(
int field );
381 void connectJoinedLayers()
const;
386 mCache.insert( feat.
id(), cachedFeature );
390 QCache< QgsFeatureId, QgsCachedFeature > mCache;
392 bool mCacheGeometry =
true;
393 bool mFullCache =
false;
394 QList<QgsAbstractCacheIndex *> mCacheIndices;
400 friend class QgsCachedFeature;
412 friend class TestVectorLayerCache;
414 #endif // QgsVectorLayerCache_H QgsFeatureIterator getFeatures(const QString &expression)
Query the layer for features matching a given expression.
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
QgsVectorLayerCache(QgsVectorLayer *layer, int cacheSize, QObject *parent=nullptr)
QgsFeatureIterator getFeatures(const QgsFeatureIds &fids)
Query the layer for the features with the given ids.
void invalidated()
The cache has been invalidated and cleared.
bool cacheGeometry() const
Returns true if the cache will fetch and cache feature geometries.
QSet< QgsFeatureId > QgsFeatureIds
bool removeCachedFeature(QgsFeatureId fid)
Removes the feature identified by fid from the cache if present.
~QgsVectorLayerCache() override
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
void requestCompleted(const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids)
Gets called, whenever the full list of feature ids for a certain request is known.
QgsVectorLayer * layer()
Returns the layer to which this cache belongs.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void attributeValueChanged(QgsFeatureId fid, int field, const QVariant &value)
Is emitted when an attribute is changed.
void setCacheSubsetOfAttributes(const QgsAttributeList &attributes)
Set the subset of attributes to be cached.
void featureAdded(QgsFeatureId fid)
Is emitted, when a new feature has been added to the layer and this cache.
Type
The WKB type describes the number of dimensions a geometry has.
bool isFidCached(QgsFeatureId fid) const
Check if a certain feature id is cached.
Uses another iterator as backend and writes features to the cache.
QgsCoordinateReferenceSystem sourceCrs() const
Returns the coordinate reference system for features in the cache.
QgsFeatureIds cachedFeatureIds() const
Returns the set of feature IDs for features which are cached.
void progress(int i, bool &cancel)
When filling the cache, this signal gets emitted periodically to notify about the progress and to be ...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFields fields() const
Returns the fields associated with features in the cache.
void cachedLayerDeleted()
Is emitted when the cached layer is deleted.
bool checkInformationCovered(const QgsFeatureRequest &featureRequest)
Checks if the information required to complete the request is cached.
This class caches features of a given QgsVectorLayer.
long featureCount() const
Returns the number of features contained in the source, or -1 if the feature count is unknown...
Abstract base class for cache indices.
void setCacheGeometry(bool cacheGeometry)
Enable or disable the caching of geometries.
void setFullCache(bool fullCache)
This enables or disables full caching.
bool featureAtId(QgsFeatureId featureId, QgsFeature &feature, bool skipCache=false)
Gets the feature at the given feature id.
void setCacheSize(int cacheSize)
Sets the maximum number of features to keep in the cache.
This class represents a coordinate reference system (CRS).
QgsWkbTypes::Type wkbType() const
Returns the geometry type for features in the cache.
QgsFeatureIterator getFeatures(const QgsRectangle &rectangle)
Query the layer for the features which intersect the specified rectangle.
Delivers features from the cache.
void featureRemoved(QgsFeatureId fid)
Gets called, whenever a feature has been removed.
int cacheSize()
Returns the maximum number of features this cache will hold.
QgsFeature getFeature(QgsFeatureId fid)
Query the layer for the feature with the given id.
QList< int > QgsAttributeList
friend class QgsCachedFeature
bool nextFeature(QgsFeature &f)
void addCacheIndex(QgsAbstractCacheIndex *cacheIndex)
Adds a QgsAbstractCacheIndex to this cache.
Represents a vector layer which manages a vector based data sets.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &featureRequest=QgsFeatureRequest())
Query this VectorLayerCache for features.
void finished()
When filling the cache, this signal gets emitted once the cache is fully initialized.
bool hasFullCache() const
Returns true if the cache is complete, ie it contains all features.
void setCacheAddedAttributes(bool cacheAddedAttributes)
If this is enabled, the subset of cached attributes will automatically be extended to also include ne...