QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsprocessingprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingprovider.h
3  ------------------------
4  begin : December 2016
5  copyright : (C) 2016 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 QGSPROCESSINGPROVIDER_H
19 #define QGSPROCESSINGPROVIDER_H
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
23 #include "qgsprocessingalgorithm.h"
24 #include <QIcon>
25 
34 class CORE_EXPORT QgsProcessingProvider : public QObject
35 {
36  Q_OBJECT
37 
38  public:
39 
44  enum Flag
45  {
46  FlagDeemphasiseSearchResults = 1 << 1,
47  };
48  Q_DECLARE_FLAGS( Flags, Flag )
49 
50 
53  QgsProcessingProvider( QObject *parent SIP_TRANSFERTHIS = nullptr );
54 
55  ~QgsProcessingProvider() override;
56 
58  QgsProcessingProvider( const QgsProcessingProvider &other ) = delete;
61 
66  virtual QIcon icon() const;
67 
72  virtual QString svgIconPath() const;
73 
79  virtual Flags flags() const;
80 
88  virtual QString id() const = 0;
89 
96  virtual QString helpId() const;
97 
104  virtual QString name() const = 0;
105 
116  virtual QString longName() const;
117 
126  virtual QString versionInfo() const;
127 
133  virtual bool canBeActivated() const { return true; }
134 
145  virtual QString warningMessage() const { return QString(); }
146 
150  virtual bool isActive() const { return true; }
151 
156  virtual QStringList supportedOutputRasterLayerExtensions() const;
157 
165  virtual QStringList supportedOutputVectorLayerExtensions() const;
166 
180  virtual QStringList supportedOutputTableExtensions() const;
181 
189  virtual bool isSupportedOutputValue( const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error SIP_OUT ) const;
190 
205  virtual QString defaultVectorFileExtension( bool hasGeometry = true ) const;
206 
218  virtual QString defaultRasterFileExtension() const;
219 
233  virtual bool supportsNonFileBasedOutput() const;
234 
244  virtual bool load() { refreshAlgorithms(); return true; }
245 
250  virtual void unload() {}
251 
255  void refreshAlgorithms();
256 
261  QList< const QgsProcessingAlgorithm * > algorithms() const;
262 
268  const QgsProcessingAlgorithm *algorithm( const QString &name ) const;
269 
270  signals:
271 
278 
279  protected:
280 
285  virtual void loadAlgorithms() = 0;
286 
290  bool addAlgorithm( QgsProcessingAlgorithm *algorithm SIP_TRANSFER );
291 
292  private:
293 
294  QMap< QString, const QgsProcessingAlgorithm * > mAlgorithms;
295 
296 #ifdef SIP_RUN
298 #endif
299 };
300 
301 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingProvider::Flags )
302 
303 #endif // QGSPROCESSINGPROVIDER_H
304 
305 
QgsProcessingProvider::load
virtual bool load()
Loads the provider.
Definition: qgsprocessingprovider.h:244
QgsProcessingProvider::id
virtual QString id() const =0
Returns the unique provider id, used for identifying the provider.
algorithm
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsProcessingProvider
Abstract base class for processing providers.
Definition: qgsprocessingprovider.h:35
QgsProcessingProvider::operator=
QgsProcessingProvider & operator=(const QgsProcessingProvider &other)=delete
Providers cannot be copied.
qgis.h
QgsProcessingProvider::QgsProcessingProvider
QgsProcessingProvider(const QgsProcessingProvider &other)=delete
Providers cannot be copied.
QgsProcessingDestinationParameter
Base class for all parameter definitions which represent file or layer destinations,...
Definition: qgsprocessingparameters.h:2774
QgsProcessingProvider::name
virtual QString name() const =0
Returns the provider name, which is used to describe the provider within the GUI.
QgsProcessingProvider::unload
virtual void unload()
Unloads the provider.
Definition: qgsprocessingprovider.h:250
QgsProcessingContext
Contains information about the context in which a processing algorithm is executed.
Definition: qgsprocessingcontext.h:44
qgsprocessingalgorithm.h
QgsProcessingProvider::canBeActivated
virtual bool canBeActivated() const
Returns true if the provider can be activated, or false if it cannot be activated (e....
Definition: qgsprocessingprovider.h:133
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Q_DECLARE_OPERATORS_FOR_FLAGS
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QgsProcessingProvider::warningMessage
virtual QString warningMessage() const
Returns an optional warning message to show users when running algorithms from this provider.
Definition: qgsprocessingprovider.h:145
QgsProcessingProvider::loadAlgorithms
virtual void loadAlgorithms()=0
Loads all algorithms belonging to this provider.
QgsProcessingProvider::Flag
Flag
Flags indicating how and when an provider operates and should be exposed to users.
Definition: qgsprocessingprovider.h:45
QgsProcessingAlgorithm
Abstract base class for processing algorithms.
Definition: qgsprocessingalgorithm.h:52
QgsProcessingProvider::isActive
virtual bool isActive() const
Returns true if the provider is active and able to run algorithms.
Definition: qgsprocessingprovider.h:150
QgsProcessingProvider::algorithmsLoaded
void algorithmsLoaded()
Emitted when the provider has loaded (or refreshed) its list of available algorithms.
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53