QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsprocessingmodelchildalgorithm.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingmodelchildalgorithm.h
3 ----------------------------------
4 begin : June 2017
5 copyright : (C) 2017 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 QGSPROCESSINGMODELCHILDALGORITHM_H
19#define QGSPROCESSINGMODELCHILDALGORITHM_H
20
21#include <memory>
22
23#include "qgis.h"
24#include "qgis_core.h"
30
31class QgsProcessingModelAlgorithm;
33
35
40class CORE_EXPORT QgsProcessingModelChildAlgorithm : public QgsProcessingModelComponent
41{
42 public:
47 QgsProcessingModelChildAlgorithm( const QString &algorithmId = QString() );
48
49 QgsProcessingModelChildAlgorithm( const QgsProcessingModelChildAlgorithm &other );
50 QgsProcessingModelChildAlgorithm &operator=( const QgsProcessingModelChildAlgorithm &other );
51
52 QgsProcessingModelChildAlgorithm *clone() const override SIP_FACTORY;
53
62 void copyNonDefinitionPropertiesFromModel( QgsProcessingModelAlgorithm *model );
63
70 QString childId() const { return mId; }
71
78 void setChildId( const QString &id ) { mId = id; }
79
86 void generateChildId( const QgsProcessingModelAlgorithm &model );
87
93 QString algorithmId() const { return mAlgorithmId; }
94
105 bool setAlgorithmId( const QString &algorithmId );
106
118 bool reattach() const;
119
130 QVariantMap configuration() const;
131
142 void setConfiguration( const QVariantMap &configuration );
143
150 const QgsProcessingAlgorithm *algorithm() const;
151
158 QMap< QString, QList< QgsProcessingModelChildParameterSource > > parameterSources() const { return mParams; }
159
166 void setParameterSources( const QMap< QString, QList< QgsProcessingModelChildParameterSource > > &sources ) { mParams = sources; }
167
177 void addParameterSources( const QString &name, const QList< QgsProcessingModelChildParameterSource > &source ) { mParams.insert( name, source ); }
178
183 bool isActive() const { return mActive; }
184
189 void setActive( bool active ) { mActive = active; }
190
196 QList< QgsProcessingModelChildDependency > dependencies() const { return mDependencies; }
197
203 void setDependencies( const QList< QgsProcessingModelChildDependency > &dependencies ) { mDependencies = dependencies; }
204
212 QMap<QString, QgsProcessingModelOutput> modelOutputs() const { return mModelOutputs; }
213
224 QgsProcessingModelOutput &modelOutput( const QString &name ) { return mModelOutputs[name]; }
225
235 void setModelOutputs( const QMap<QString, QgsProcessingModelOutput> &outputs );
236
245 bool removeModelOutput( const QString &name );
246
251 QVariant toVariant() const;
252
257 bool loadVariant( const QVariant &child );
258
270 QStringList asPythonCode(
272 const QgsStringMap &extraParameters,
273 int currentIndent,
274 int indentSize,
275 const QMap<QString, QString> &friendlyChildNames,
276 const QMap<QString, QString> &friendlyOutputNames
277 ) const;
278
279 SIP_SKIP const QgsProcessingModelComment *comment() const override { return &mComment; }
280 QgsProcessingModelComment *comment() override { return &mComment; }
281 void setComment( const QgsProcessingModelComment &comment ) override { mComment = comment; }
282
283 private:
284 QString mId;
285
286 QString mAlgorithmId;
287 std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
288
289 QVariantMap mConfiguration;
290
292 QMap< QString, QgsProcessingModelChildParameterSources > mParams;
293
295 QMap< QString, QgsProcessingModelOutput > mModelOutputs;
296
297 bool mActive = true;
298
300 QList< QgsProcessingModelChildDependency > mDependencies;
301
302 QgsProcessingModelComment mComment;
303
304 friend class TestQgsProcessingModelAlgorithm;
305};
306
308
309#endif // QGSPROCESSINGMODELCHILDALGORITHM_H
Abstract base class for processing algorithms.
PythonOutputType
Available Python output types.
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
QMap< QString, QString > QgsStringMap
Definition qgis.h:7475
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_FACTORY
Definition qgis_sip.h:83