QGIS API Documentation  3.0.2-Girona (307d082)
qgsprocessingregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingregistry.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 QGSPROCESSINGREGISTRY_H
19 #define QGSPROCESSINGREGISTRY_H
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
23 #include "qgsprocessingprovider.h"
24 #include <QMap>
25 
36 class CORE_EXPORT QgsProcessingRegistry : public QObject
37 {
38  Q_OBJECT
39 
40  public:
41 
45  QgsProcessingRegistry( QObject *parent SIP_TRANSFERTHIS = nullptr );
46 
47  ~QgsProcessingRegistry() override;
48 
50  QgsProcessingRegistry( const QgsProcessingRegistry &other ) = delete;
52  QgsProcessingRegistry &operator=( const QgsProcessingRegistry &other ) = delete;
53 
57  QList<QgsProcessingProvider *> providers() const { return mProviders.values(); }
58 
68  bool addProvider( QgsProcessingProvider *provider SIP_TRANSFER );
69 
75  bool removeProvider( QgsProcessingProvider *provider );
76 
82  bool removeProvider( const QString &providerId );
83 
87  QgsProcessingProvider *providerById( const QString &id );
88 
93  QList< const QgsProcessingAlgorithm *> algorithms() const;
94 
101  const QgsProcessingAlgorithm *algorithmById( const QString &id ) const;
102 
103  /*
104  * IMPORTANT: While it seems like /Factory/ would be the correct annotation here, that's not
105  * the case.
106  * As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
107  *
108  * "
109  * /Factory/ is used when the instance returned is guaranteed to be new to Python.
110  * In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
111  * (However for a different sub-class implemented in C++ then it would be the first time it was seen
112  * by Python so the /Factory/ on create() would be correct.)
113  *
114  * You might try using /TransferBack/ on create() instead - that might be the best compromise.
115  * "
116  */
117 
131  QgsProcessingAlgorithm *createAlgorithmById( const QString &id, const QVariantMap &configuration = QVariantMap() ) const SIP_TRANSFERBACK;
132 
133  signals:
134 
136  void providerAdded( const QString &id );
137 
139  void providerRemoved( const QString &id );
140 
141  private:
142 
144  QMap<QString, QgsProcessingProvider *> mProviders;
145 
146 #ifdef SIP_RUN
148 #endif
149 };
150 
151 #endif // QGSPROCESSINGREGISTRY_H
152 
153 
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Abstract base class for processing providers.
#define SIP_TRANSFERBACK
Definition: qgis_sip.h:41
Abstract base class for processing algorithms.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Registry for various processing components, including providers, algorithms and various parameters an...
QList< QgsProcessingProvider * > providers() const
Get list of available providers.