1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/vector/qgsvectorlayercache.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsVectorLayerCache : QObject
{
%Docstring(signature="appended")
This class caches features of a given :py:class:`QgsVectorLayer`.
The cached features can be indexed by :py:class:`QgsAbstractCacheIndex`.
Proper indexing for a given use-case may speed up performance
substantially.
%End
%TypeHeaderCode
#include "qgsvectorlayercache.h"
%End
public:
public:
QgsVectorLayerCache( QgsVectorLayer *layer, int cacheSize, QObject *parent /TransferThis/ = 0 );
~QgsVectorLayerCache();
void setCacheSize( int cacheSize );
%Docstring
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.
:param cacheSize: indicates the maximum number of features to keep in
the cache
%End
int cacheSize();
%Docstring
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
%End
void setCacheGeometry( bool cacheGeometry );
%Docstring
Enable or disable the caching of geometries
:param cacheGeometry: Enable or disable the caching of geometries
.. seealso:: :py:func:`cacheGeometry`
%End
bool cacheGeometry() const;
%Docstring
Returns ``True`` if the cache will fetch and cache feature geometries.
.. seealso:: :py:func:`setCacheGeometry`
%End
void setCacheSubsetOfAttributes( const QgsAttributeList &attributes );
%Docstring
Set the list (possibly a subset) of attributes to be cached.
.. note::
By default the cache will store all layer's attributes.
:param attributes: The attributes to be cached
%End
QgsAttributeList cacheSubsetOfAttributes( ) const;
%Docstring
Returns the list (possibly a subset) of cached attributes.
.. note::
By default the cache will store all layer's attributes.
.. seealso:: :py:func:`setCacheSubsetOfAttributes`
.. versionadded:: 3.32
%End
void setCacheAddedAttributes( bool cacheAddedAttributes );
%Docstring
If this is enabled, the subset of cached attributes will automatically
be extended to also include newly added attributes.
:param cacheAddedAttributes: Automatically cache new attributes
%End
void setFullCache( bool fullCache );
%Docstring
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
.. note::
when a cache is :py:func:`~QgsVectorLayerCache.invalidated` (e.g. by adding an attribute to a layer) this setting
is reset. A full cache rebuild must be performed by calling setFullCache( ``True`` ) again.
.. seealso:: :py:func:`hasFullCache`
%End
bool hasFullCache() const;
%Docstring
Returns ``True`` if the cache is complete, ie it contains all features.
This may happen as a result of a call to
:py:func:`~QgsVectorLayerCache.setFullCache` or by through a feature
request which resulted in all available features being cached.
.. seealso:: :py:func:`setFullCache`
%End
void addCacheIndex( QgsAbstractCacheIndex *cacheIndex /Transfer/ );
%Docstring
Adds a :py:class:`QgsAbstractCacheIndex` to this cache. Cache indices
know about features present in this cache and decide, if enough
information is present in the cache to respond to a
:py:class:`QgsFeatureRequest`. The layer cache will take ownership of
the index.
:param cacheIndex: The cache index to add.
%End
QgsFeatureIterator getFeatures( const QgsFeatureRequest &featureRequest = QgsFeatureRequest() );
%Docstring
Query this VectorLayerCache for features. If the VectorLayerCache (and
moreover any of its indices) is able to satisfy the request, the
returned :py:class:`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.
:param featureRequest: The request specifying filter and required data.
:return: An iterator over the requested data.
%End
QgsFeatureIterator getFeatures( const QString &expression );
%Docstring
Query the layer for features matching a given expression.
%End
QgsFeature getFeature( QgsFeatureId fid );
%Docstring
Query the layer for the feature with the given id. If there is no such
feature, the returned feature will be invalid.
%End
QgsFeatureIterator getFeatures( const QgsFeatureIds &fids );
%Docstring
Query the layer for the features with the given ids.
%End
QgsFeatureIterator getFeatures( const QgsRectangle &rectangle );
%Docstring
Query the layer for the features which intersect the specified
rectangle.
%End
bool isFidCached( QgsFeatureId fid ) const;
%Docstring
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`
%End
QgsFeatureIds cachedFeatureIds() const;
%Docstring
Returns the set of feature IDs for features which are cached.
.. seealso:: :py:func:`isFidCached`
%End
bool featureAtId( QgsFeatureId featureId, QgsFeature &feature /Out/, bool skipCache = false );
%Docstring
Gets the feature at the given feature id. Considers the changed, added,
deleted and permanent features
:param featureId: The id of the feature to query
:param skipCache: Will query the layer regardless if the feature is in
the cache already
:return: - ``True`` in case of success
- feature: The result of the operation will be written to this
feature
%End
bool featureAtIdWithAllAttributes( QgsFeatureId featureId, QgsFeature &feature /Out/, bool skipCache = false );
%Docstring
Gets the feature at the given feature id with all attributes, if the
cached feature already contains all attributes, calling this function
has the same effect as calling
:py:func:`~QgsVectorLayerCache.featureAtId`.
Considers the changed, added, deleted and permanent features
:param featureId: The id of the feature to query
:param skipCache: Will query the layer regardless if the feature is in
the cache already
:return: - ``True`` in case of success
- feature: The result of the operation will be written to this
feature
.. seealso:: :py:func:`featureAtId`
.. versionadded:: 3.32
%End
bool completeFeatureAtId( QgsFeatureId featureId, QgsFeature &feature /Out/, bool skipCache = false );
%Docstring
Gets the feature at the given feature id with all attributes and
geometry, if the cached feature already contains all attributes and
geometry, calling this function has the same effect as calling
:py:func:`~QgsVectorLayerCache.featureAtId`.
Considers the changed, added, deleted and permanent features
:param featureId: The id of the feature to query
:param skipCache: Will query the layer regardless if the feature is in
the cache already
:return: - ``True`` in case of success
- feature: The result of the operation will be written to this
feature
.. seealso:: :py:func:`featureAtId`
.. versionadded:: 3.44
%End
bool removeCachedFeature( QgsFeatureId fid );
%Docstring
Removes the feature identified by fid from the cache if present.
: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
%End
QgsVectorLayer *layer();
%Docstring
Returns the layer to which this cache belongs
%End
QgsCoordinateReferenceSystem sourceCrs() const;
%Docstring
Returns the coordinate reference system for features in the cache.
%End
QgsFields fields() const;
%Docstring
Returns the fields associated with features in the cache.
%End
Qgis::WkbType wkbType() const;
%Docstring
Returns the geometry type for features in the cache.
%End
int __len__() const;
%Docstring
Returns the number of features contained in the source, or -1 if the
feature count is unknown.
%End
%MethodCode
sipRes = sipCpp->featureCount();
%End
//! Ensures that bool(obj) returns ``True`` (otherwise __len__() would be used)
int __bool__() const;
%MethodCode
sipRes = true;
%End
long long featureCount() const;
%Docstring
Returns the number of features contained in the source, or -1 if the
feature count is unknown.
%End
protected:
void requestCompleted( const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids );
%Docstring
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.
:param featureRequest: The feature request that was answered
:param fids: The feature ids that have been returned
%End
void featureRemoved( QgsFeatureId fid );
%Docstring
Gets called, whenever a feature has been removed. Broadcasts this
information to indices, so they can invalidate their cache if required.
:param fid: The feature id of the removed feature.
%End
bool checkInformationCovered( const QgsFeatureRequest &featureRequest );
%Docstring
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 :py:class:`QgsFeatureRequest` to be answered
:return: ``True`` if the information is being cached, ``False`` if not
%End
signals:
void finished();
%Docstring
When filling the cache, this signal gets emitted once the cache is fully
initialized.
%End
void cachedLayerDeleted();
%Docstring
Is emitted when the cached layer is deleted. Is emitted when the cached
layers :py:func:`~QgsVectorLayerCache.layerDelete` signal is being
emitted, but before the local reference to it has been set to ``None``.
So call to :py:func:`~QgsVectorLayerCache.layer` will still return a
valid pointer for cleanup purpose.
%End
void attributeValueChanged( QgsFeatureId fid, int field, const QVariant &value );
%Docstring
Emitted when an attribute is changed. Is re-emitted after the layer
itself emits this signal. You should connect to this signal, to be sure,
to not get a cached value if querying the cache.
%End
void featureAdded( QgsFeatureId fid );
%Docstring
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
:param fid: The featureid of the changed feature
%End
void invalidated();
%Docstring
The cache has been invalidated and cleared. Note that when a cache is
invalidated the :py:func:`~QgsVectorLayerCache.fullCache` setting will
be cleared, and a full cache rebuild via setFullCache( ``True`` ) will
need to be performed.
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/vector/qgsvectorlayercache.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|