Branch data Line data Source code
1 : : /*************************************************************************** 2 : : qgscacheindex.h 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 : : #ifndef QGSCACHEINDEX_H 17 : : #define QGSCACHEINDEX_H 18 : : 19 : : #include "qgis_core.h" 20 : : #include "qgsfeatureid.h" 21 : : 22 : : class QgsFeatureRequest; 23 : : class QgsFeatureIterator; 24 : : 25 : : /** 26 : : * \ingroup core 27 : : * \brief 28 : : * \brief Abstract base class for cache indices 29 : : */ 30 : : 31 : : class CORE_EXPORT QgsAbstractCacheIndex 32 : : { 33 : : public: 34 : : 35 : : /** 36 : : * Constructor for QgsAbstractCacheIndex. 37 : : */ 38 : 0 : QgsAbstractCacheIndex() = default; 39 : 0 : virtual ~QgsAbstractCacheIndex() = default; 40 : : 41 : : /** 42 : : * Is called whenever a feature is removed from the cache. You should update your indexes so 43 : : * they become invalid in case this feature was required to successfully answer a request. 44 : : */ 45 : : virtual void flushFeature( QgsFeatureId fid ) = 0; 46 : : 47 : : /** 48 : : * Sometimes, the whole cache changes its state and its easier to just withdraw everything. 49 : : * In this case, this method is issued. Be sure to clear all cache information in here. 50 : : */ 51 : : virtual void flush() = 0; 52 : : 53 : : /** 54 : : * \brief 55 : : * Implement this method to update the the indices, in case you need information contained by the request 56 : : * to properly index. (E.g. spatial index) 57 : : * Does nothing by default 58 : : * 59 : : * \param featureRequest The feature request that was answered 60 : : * \param fids The feature ids that have been returned 61 : : */ 62 : : virtual void requestCompleted( const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids ); 63 : : 64 : : /** 65 : : * Is called when a feature request is issued on a cached layer. 66 : : * 67 : : * If this cache index is able to completely answer the feature request, it will return TRUE 68 : : * and set the iterator to a valid iterator over the cached features. If it is not able 69 : : * it will return FALSE. 70 : : * 71 : : * \param featureIterator A reference to a QgsFeatureIterator. A valid featureIterator will 72 : : * be assigned in case this index is able to answer the request and the return 73 : : * value is TRUE. 74 : : * \param featureRequest The feature request, for which this index is queried. 75 : : * 76 : : * \returns TRUE, if this index holds the information to answer the request. 77 : : * 78 : : */ 79 : : virtual bool getCacheIterator( QgsFeatureIterator &featureIterator, const QgsFeatureRequest &featureRequest ) = 0; 80 : : }; 81 : : 82 : : #endif // QGSCACHEINDEX_H