QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 "qgis_core.h"
22#include "qgis.h"
28#include <memory>
29
30class QgsProcessingModelAlgorithm;
32
34
39class CORE_EXPORT QgsProcessingModelChildAlgorithm : public QgsProcessingModelComponent
40{
41 public:
42
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( QgsProcessing::PythonOutputType outputType, const QgsStringMap &extraParameters, int currentIndent, int indentSize,
271 const QMap<QString, QString> &friendlyChildNames, const QMap<QString, QString> &friendlyOutputNames ) const;
272
273 SIP_SKIP const QgsProcessingModelComment *comment() const override { return &mComment; }
274 QgsProcessingModelComment *comment() override { return &mComment; }
275 void setComment( const QgsProcessingModelComment &comment ) override { mComment = comment; }
276
277 private:
278
279 QString mId;
280
281 QString mAlgorithmId;
282 std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
283
284 QVariantMap mConfiguration;
285
287 QMap< QString, QgsProcessingModelChildParameterSources > mParams;
288
290 QMap< QString, QgsProcessingModelOutput > mModelOutputs;
291
292 bool mActive = true;
293
295 QList< QgsProcessingModelChildDependency > mDependencies;
296
297 QgsProcessingModelComment mComment;
298
299 friend class TestQgsProcessingModelAlgorithm;
300
301};
302
304
305#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:6496
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_FACTORY
Definition qgis_sip.h:76