QGIS API Documentation  3.27.0-Master (e113457133)
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 
30 class QgsProcessingModelAlgorithm;
32 
34 
40 class CORE_EXPORT QgsProcessingModelChildAlgorithm : public QgsProcessingModelComponent
41 {
42  public:
43 
48  QgsProcessingModelChildAlgorithm( const QString &algorithmId = QString() );
49 
50  QgsProcessingModelChildAlgorithm( const QgsProcessingModelChildAlgorithm &other );
51  QgsProcessingModelChildAlgorithm &operator=( const QgsProcessingModelChildAlgorithm &other );
52 
53  QgsProcessingModelChildAlgorithm *clone() const override SIP_FACTORY;
54 
63  void copyNonDefinitionPropertiesFromModel( QgsProcessingModelAlgorithm *model );
64 
71  QString childId() const { return mId; }
72 
79  void setChildId( const QString &id ) { mId = id; }
80 
87  void generateChildId( const QgsProcessingModelAlgorithm &model );
88 
94  QString algorithmId() const { return mAlgorithmId; }
95 
106  bool setAlgorithmId( const QString &algorithmId );
107 
119  bool reattach() const;
120 
131  QVariantMap configuration() const;
132 
143  void setConfiguration( const QVariantMap &configuration );
144 
151  const QgsProcessingAlgorithm *algorithm() const;
152 
159  QMap< QString, QList< QgsProcessingModelChildParameterSource > > parameterSources() const { return mParams; }
160 
167  void setParameterSources( const QMap< QString, QList< QgsProcessingModelChildParameterSource > > &sources ) { mParams = sources; }
168 
178  void addParameterSources( const QString &name, const QList< QgsProcessingModelChildParameterSource > &source ) { mParams.insert( name, source ); }
179 
184  bool isActive() const { return mActive; }
185 
190  void setActive( bool active ) { mActive = active; }
191 
197  QList< QgsProcessingModelChildDependency > dependencies() const { return mDependencies; }
198 
204  void setDependencies( const QList< QgsProcessingModelChildDependency > &dependencies ) { mDependencies = dependencies; }
205 
213  QMap<QString, QgsProcessingModelOutput> modelOutputs() const { return mModelOutputs; }
214 
225  QgsProcessingModelOutput &modelOutput( const QString &name ) { return mModelOutputs[ name ]; }
226 
236  void setModelOutputs( const QMap<QString, QgsProcessingModelOutput> &outputs );
237 
246  bool removeModelOutput( const QString &name );
247 
252  QVariant toVariant() const;
253 
258  bool loadVariant( const QVariant &child );
259 
271  QStringList asPythonCode( QgsProcessing::PythonOutputType outputType, const QgsStringMap &extraParameters, int currentIndent, int indentSize,
272  const QMap<QString, QString> &friendlyChildNames, const QMap<QString, QString> &friendlyOutputNames ) const;
273 
274  SIP_SKIP const QgsProcessingModelComment *comment() const override { return &mComment; }
275  QgsProcessingModelComment *comment() override { return &mComment; }
276  void setComment( const QgsProcessingModelComment &comment ) override { mComment = comment; }
277 
278  private:
279 
280  QString mId;
281 
282  QString mAlgorithmId;
283  std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
284 
285  QVariantMap mConfiguration;
286 
288  QMap< QString, QgsProcessingModelChildParameterSources > mParams;
289 
291  QMap< QString, QgsProcessingModelOutput > mModelOutputs;
292 
293  bool mActive = true;
294 
296  QList< QgsProcessingModelChildDependency > mDependencies;
297 
298  QgsProcessingModelComment mComment;
299 
300  friend class TestQgsProcessingModelAlgorithm;
301 
302 };
303 
305 
306 #endif // QGSPROCESSINGMODELCHILDALGORITHM_H
Abstract base class for processing algorithms.
PythonOutputType
Available Python output types.
Definition: qgsprocessing.h:63
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:2776
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76