QGIS/python/core/qgsvectorlayercache.sip.in

305 lines
9.6 KiB
Plaintext
Raw Normal View History

2017-05-22 09:01:45 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsvectorlayercache.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsVectorLayerCache : QObject
{
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
This class caches features of a given QgsVectorLayer.
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
The cached features can be indexed by QgsAbstractCacheIndex.
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
Proper indexing for a given use-case may speed up performance substantially.
2017-05-22 09:01:45 +02:00
%End
%TypeHeaderCode
#include "qgsvectorlayercache.h"
%End
2017-05-22 09:01:45 +02:00
public:
public:
2017-05-22 09:01:45 +02:00
QgsVectorLayerCache( QgsVectorLayer *layer, int cacheSize, QObject *parent /TransferThis/ = 0 );
~QgsVectorLayerCache();
void setCacheSize( int cacheSize );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the maximum number of features to keep in the cache. Some features will be removed from
the cache if the number is smaller than the previous size of the cache.
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:param cacheSize: indicates the maximum number of features to keep in the cache
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
int cacheSize();
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the maximum number of features this cache will hold.
In case full caching is enabled, this number can change, as new features get added.
:return: int
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void setCacheGeometry( bool cacheGeometry );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Enable or disable the caching of geometries
:param cacheGeometry: Enable or disable the caching of geometries
2017-05-22 09:01:45 +02:00
.. seealso:: :py:func:`cacheGeometry`
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
bool cacheGeometry() const;
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns true if the cache will fetch and cache feature geometries.
2017-05-22 09:01:45 +02:00
.. versionadded:: 3.0
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`setCacheGeometry`
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void setCacheSubsetOfAttributes( const QgsAttributeList &attributes );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Set the subset of attributes to be cached
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:param attributes: The attributes to be cached
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void setCacheAddedAttributes( bool cacheAddedAttributes );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
If this is enabled, the subset of cached attributes will automatically be extended
to also include newly added attributes.
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:param cacheAddedAttributes: Automatically cache new attributes
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void setFullCache( bool fullCache );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
This enables or disables full caching.
If enabled, all features will be held in the cache. The cache size will incrementally
be increased to offer space for all features.
When enabled, all features will be read into cache. As this feature will most likely
be used for slow data sources, be aware, that the call to this method might take a long time.
:param fullCache: True: enable full caching, False: disable full caching
2017-05-22 09:01:45 +02:00
.. note::
when a cache is invalidated() (e.g. by adding an attribute to a layer) this setting
2018-01-12 20:51:17 -04:00
is reset. A full cache rebuild must be performed by calling setFullCache( true ) again.
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`hasFullCache`
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
bool hasFullCache() const;
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns true if the cache is complete, ie it contains all features. This may happen as
a result of a call to setFullCache() or by through a feature request which resulted in
all available features being cached.
.. seealso:: :py:func:`setFullCache`
2017-12-15 10:36:55 -04:00
2017-05-22 09:01:45 +02:00
.. versionadded:: 3.0
%End
2016-09-05 17:01:48 +02:00
void addCacheIndex( QgsAbstractCacheIndex *cacheIndex /Transfer/ );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Adds a QgsAbstractCacheIndex to this cache. Cache indices know about features present
2017-12-19 11:43:52 -04:00
in this cache and decide, if enough information is present in the cache to respond to a :py:class:`QgsFeatureRequest`.
2017-12-15 10:36:55 -04:00
The layer cache will take ownership of the index.
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:param cacheIndex: The cache index to add.
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
QgsFeatureIterator getFeatures( const QgsFeatureRequest &featureRequest = QgsFeatureRequest() );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Query this VectorLayerCache for features.
If the VectorLayerCache (and moreover any of its indices) is able to satisfy
the request, the returned QgsFeatureIterator will iterate over cached features.
If it's not possible to fully satisfy the request from the cache, part or all of the features
will be requested from the data provider.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param featureRequest: The request specifying filter and required data.
:return: An iterator over the requested data.
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
QgsFeatureIterator getFeatures( const QString &expression );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Query the layer for features matching a given expression.
2017-05-22 09:01:45 +02:00
%End
QgsFeature getFeature( QgsFeatureId fid );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Query the layer for the feature with the given id.
If there is no such feature, the returned feature will be invalid.
2017-05-22 09:01:45 +02:00
%End
2017-05-22 09:01:45 +02:00
QgsFeatureIterator getFeatures( const QgsFeatureIds &fids );
%Docstring
2017-12-15 10:36:55 -04:00
Query the layer for the features with the given ids.
2017-05-22 09:01:45 +02:00
%End
QgsFeatureIterator getFeatures( const QgsRectangle &rectangle );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Query the layer for the features which intersect the specified rectangle.
2017-05-22 09:01:45 +02:00
%End
bool isFidCached( const QgsFeatureId fid ) const;
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Check if a certain feature id is cached.
\param fid The feature id to look for
:return: True if this id is in the cache
.. seealso:: :py:func:`cachedFeatureIds`
2017-05-22 09:01:45 +02:00
%End
QgsFeatureIds cachedFeatureIds() const;
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the set of feature IDs for features which are cached.
2017-05-22 09:01:45 +02:00
.. versionadded:: 3.0
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`isFidCached`
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
bool featureAtId( QgsFeatureId featureId, QgsFeature &feature, bool skipCache = false );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param featureId: The id of the feature to query
:param feature: The result of the operation will be written to this feature
:param skipCache: Will query the layer regardless if the feature is in the cache already
:return: true in case of success
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
bool removeCachedFeature( QgsFeatureId fid );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Removes the feature identified by fid from the cache if present.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param fid: The id of the feature to delete
:return: true if the feature was removed, false if the feature id was not found in the cache
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
QgsVectorLayer *layer();
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the layer to which this cache belongs
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
QgsCoordinateReferenceSystem sourceCrs() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the coordinate reference system for features in the cache.
%End
QgsFields fields() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the fields associated with features in the cache.
%End
QgsWkbTypes::Type wkbType() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the geometry type for features in the cache.
%End
int __len__() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the number of features contained in the source, or -1
if the feature count is unknown.
%End
%MethodCode
sipRes = sipCpp->featureCount();
%End
long featureCount() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the number of features contained in the source, or -1
if the feature count is unknown.
%End
2014-01-26 18:35:21 +01:00
protected:
2017-05-22 09:01:45 +02:00
void requestCompleted( const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Gets called, whenever the full list of feature ids for a certain request is known.
Broadcasts this information to indices, so they can update their tables.
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:param featureRequest: The feature request that was answered
:param fids: The feature ids that have been returned
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void featureRemoved( QgsFeatureId fid );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Gets called, whenever a feature has been removed.
Broadcasts this information to indices, so they can invalidate their cache if required.
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:param fid: The feature id of the removed feature.
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
bool checkInformationCovered( const QgsFeatureRequest &featureRequest );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Checks if the information required to complete the request is cached.
i.e. If all attributes required and the geometry is held in the cache.
Please note, that this does not check, if the requested features are cached.
:param featureRequest: The QgsFeatureRequest to be answered
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:return: True if the information is being cached, false if not
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
signals:
2017-05-22 09:01:45 +02:00
2014-01-26 18:35:21 +01:00
void finished();
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
When filling the cache, this signal gets emitted once the cache is fully initialized.
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void cachedLayerDeleted();
2017-05-22 09:01:45 +02:00
%Docstring
Is emitted when the cached layer is deleted. Is emitted when the cached layers layerDelete()
2017-12-15 10:36:55 -04:00
signal is being emitted, but before the local reference to it has been set to NULL. So call to
layer() will still return a valid pointer for cleanup purpose.
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void attributeValueChanged( QgsFeatureId fid, int field, const QVariant &value );
2017-05-22 09:01:45 +02:00
%Docstring
Is emitted when an attribute is changed. Is re-emitted after the layer itself emits this signal.
2017-12-15 10:36:55 -04:00
You should connect to this signal, to be sure, to not get a cached value if querying the cache.
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void featureAdded( QgsFeatureId fid );
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Is emitted, when a new feature has been added to the layer and this cache.
You should connect to this signal instead of the layers', if you want to be sure
that this cache has updated information for the new feature
2017-05-22 09:01:45 +02:00
2017-12-15 10:36:55 -04:00
:param fid: The featureid of the changed feature
2017-05-22 09:01:45 +02:00
%End
2014-01-26 18:35:21 +01:00
void invalidated();
2017-05-22 09:01:45 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
The cache has been invalidated and cleared. Note that when a cache is invalidated
the fullCache() setting will be cleared, and a full cache rebuild via setFullCache( true )
will need to be performed.
2017-05-22 09:01:45 +02:00
%End
};
2017-05-22 09:01:45 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsvectorlayercache.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/