QGIS API Documentation 4.3.0-Master (96c7fa699b4)
Loading...
Searching...
No Matches
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.h"
22#include "qgis_core.h"
24
25#include <QMap>
26
32
40{
41 public:
43 QString displayName;
44
46 QIcon icon;
47};
48
49
59class CORE_EXPORT QgsProcessingRegistry : public QObject
60{
61 Q_OBJECT
62
63 public:
67 QgsProcessingRegistry( QObject *parent SIP_TRANSFERTHIS = nullptr );
68
69 ~QgsProcessingRegistry() override;
70
73
77 QList<QgsProcessingProvider *> providers() const { return mProviders.values(); }
78
88 bool addProvider( QgsProcessingProvider *provider SIP_TRANSFER );
89
95 bool removeProvider( QgsProcessingProvider *provider );
96
102 bool removeProvider( const QString &providerId );
103
104 // clang-format off
108 QgsProcessingProvider *providerById( const QString &id ) const SIP_HOLDGIL;
109 // clang-format on
110
115 QList< const QgsProcessingAlgorithm *> algorithms() const;
116
137 bool isCompatibleDefinition( const QgsProcessingParameterDefinition* targetDefinition, const QgsProcessingParameterDefinition* candidateDefinition );
138
162 bool isCompatibleOutput(const QgsProcessingParameterDefinition* targetDefinition, const QgsProcessingOutputDefinition* candidateOutput);
163
172 QgsProcessingAlgorithmInformation algorithmInformation( const QString &id ) const;
173
180 const QgsProcessingAlgorithm *algorithmById( const QString &id ) const;
181
182 /*
183 * IMPORTANT: While it seems like /Factory/ would be the correct annotation here, that's not
184 * the case.
185 * As per Phil Thomson's advice on https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
186 *
187 * "
188 * /Factory/ is used when the instance returned is guaranteed to be new to Python.
189 * In this case it isn't because it has already been seen when being returned by QgsProcessingAlgorithm::createInstance()
190 * (However for a different sub-class implemented in C++ then it would be the first time it was seen
191 * by Python so the /Factory/ on create() would be correct.)
192 *
193 * You might try using /TransferBack/ on create() instead - that might be the best compromise.
194 * "
195 */
196
210 QgsProcessingAlgorithm *createAlgorithmById( const QString &id, const QVariantMap &configuration = QVariantMap() ) const SIP_TRANSFERBACK;
211
223 void addAlgorithmAlias( const QString &aliasId, const QString &actualId );
224
234 bool addParameterType( QgsProcessingParameterType *type SIP_TRANSFER );
235
245 void removeParameterType( QgsProcessingParameterType *type );
246
252 QgsProcessingParameterType *parameterType( const QString &id ) const;
253
259 QList<QgsProcessingParameterType *> parameterTypes() const;
260
267 QgsProcessingDefaultStyleRegistry* defaultStyleRegistry() const;
268
282 void setLayerPostProcessor( std::unique_ptr< QgsProcessingLayerPostProcessor > processor ) SIP_SKIP;
283
290 QgsProcessingLayerPostProcessor* layerPostProcessor();
291
304 void setResultsHandler( std::unique_ptr< QgsProcessingResultsHandler > handler ) SIP_SKIP;
305
316 bool handleAlgorithmResults( const QgsProcessingAlgorithm* algorithm, QgsProcessingContext& context, const QVariantMap& parameters, QgsProcessingFeedback* feedback = nullptr );
317
318 signals:
319
321 void providerAdded( const QString &id );
322
324 void providerRemoved( const QString &id );
325
332
340
341 private:
342
344 QMap<QString, QgsProcessingProvider *> mProviders;
345
347 QMap<QString, QgsProcessingParameterType *> mParameterTypes;
348
349 QMap< QString, QString > mAlgorithmAliases;
350
351 mutable QMap< QString, QgsProcessingAlgorithmInformation > mCachedInformation;
352
353 QgsProcessingDefaultStyleRegistry* mDefaultStyleRegistry = nullptr;
354
355 std::unique_ptr< QgsProcessingLayerPostProcessor > mLayerPostProcessor;
356 std::unique_ptr< QgsProcessingResultsHandler > mResultsHandler;
357
358#ifdef SIP_RUN
360#endif
361
362 friend class TestQgsProcessing;
363};
364
365#endif // QGSPROCESSINGREGISTRY_H
366
367
Interface base class for factories for algorithm configuration widgets.
Contains basic properties for a Processing algorithm.
QString displayName
Algorithm display name.
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
A registry for default styles to apply to layers generated by Processing.
Base class for providing feedback from a processing algorithm.
A post-processor for result layers created by Processing algorithms.
Base class for the definition of processing outputs.
Base class for the definition of processing parameters.
Makes metadata of processing parameters available.
Abstract base class for processing providers.
QgsProcessingRegistry & operator=(const QgsProcessingRegistry &other)=delete
void parameterTypeAdded(QgsProcessingParameterType *type)
Emitted when a new parameter type has been added to the registry.
void parameterTypeRemoved(QgsProcessingParameterType *type)
Emitted when a parameter type has been removed from the registry and is about to be deleted.
QgsProcessingRegistry(QObject *parent=nullptr)
Constructor for QgsProcessingRegistry.
QList< QgsProcessingProvider * > providers() const
Gets list of available providers.
void providerAdded(const QString &id)
Emitted when a provider has been added to the registry.
QgsProcessingRegistry(const QgsProcessingRegistry &other)=delete
void providerRemoved(const QString &id)
Emitted when a provider is removed from the registry.
Handles results output by Processing algorithms.
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
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_TRANSFERBACK
Definition qgis_sip.h:47
#define SIP_HOLDGIL
Definition qgis_sip.h:183