Branch data Line data Source code
1 : : /*************************************************************************** 2 : : qgsproxyfeaturesink.h 3 : : ---------------------- 4 : : begin : April 2020 5 : : copyright : (C) 2020 by Nyall Dawson 6 : : email : nyall dot dawson at gmail dot com 7 : : ***************************************************************************/ 8 : : 9 : : /*************************************************************************** 10 : : * * 11 : : * This program is free software; you can redistribute it and/or modify * 12 : : * it under the terms of the GNU General Public License as published by * 13 : : * the Free Software Foundation; either version 2 of the License, or * 14 : : * (at your option) any later version. * 15 : : * * 16 : : ***************************************************************************/ 17 : : 18 : : #ifndef QGSPROXYFEATURESINK_H 19 : : #define QGSPROXYFEATURESINK_H 20 : : 21 : : #include "qgis_core.h" 22 : : #include "qgis.h" 23 : : #include "qgsfeaturesink.h" 24 : : 25 : : 26 : : /** 27 : : * \class QgsProxyFeatureSink 28 : : * \ingroup core 29 : : * \brief A simple feature sink which proxies feature addition on to another feature sink. 30 : : * 31 : : * This class is designed to allow factory methods which always return new QgsFeatureSink 32 : : * objects. Since it is not always possible to create an entirely new QgsFeatureSink 33 : : * (e.g. if the feature sink is a layer's data provider), a new QgsProxyFeatureSink 34 : : * can instead be returned which forwards features on to the destination sink. The 35 : : * proxy sink can be safely deleted without affecting the destination sink. 36 : : * 37 : : * \since QGIS 3.0 38 : : */ 39 : 0 : class CORE_EXPORT QgsProxyFeatureSink : public QgsFeatureSink 40 : : { 41 : : public: 42 : : 43 : : /** 44 : : * Constructs a new QgsProxyFeatureSink which forwards features onto a destination \a sink. 45 : : */ 46 : : QgsProxyFeatureSink( QgsFeatureSink *sink ); 47 : 0 : bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override { return mSink->addFeature( feature, flags ); } 48 : 0 : bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override { return mSink->addFeatures( features, flags ); } 49 : 0 : bool addFeatures( QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override { return mSink->addFeatures( iterator, flags ); } 50 : 0 : QString lastError() const override { return mSink->lastError(); } 51 : : 52 : : /** 53 : : * Returns the destination QgsFeatureSink which the proxy will forward features to. 54 : : */ 55 : 0 : QgsFeatureSink *destinationSink() { return mSink; } 56 : : 57 : : private: 58 : : 59 : : QgsFeatureSink *mSink = nullptr; 60 : : }; 61 : : 62 : : 63 : : #endif // QGSPROXYFEATURESINK_H 64 : : 65 : : 66 : : 67 : :