18#ifndef QGSPROCESSINGMODELCHILDALGORITHM_H
19#define QGSPROCESSINGMODELCHILDALGORITHM_H
31class QgsProcessingModelAlgorithm;
40class CORE_EXPORT QgsProcessingModelChildAlgorithm :
public QgsProcessingModelComponent
47 QgsProcessingModelChildAlgorithm(
const QString &algorithmId = QString() );
49 QgsProcessingModelChildAlgorithm(
const QgsProcessingModelChildAlgorithm &other );
50 QgsProcessingModelChildAlgorithm &operator=(
const QgsProcessingModelChildAlgorithm &other );
52 QgsProcessingModelChildAlgorithm *clone() const override
SIP_FACTORY;
62 void copyNonDefinitionPropertiesFromModel( QgsProcessingModelAlgorithm *model );
70 QString childId()
const {
return mId; }
78 void setChildId(
const QString &
id ) { mId = id; }
86 void generateChildId(
const QgsProcessingModelAlgorithm &model );
93 QString algorithmId()
const {
return mAlgorithmId; }
105 bool setAlgorithmId(
const QString &algorithmId );
118 bool reattach()
const;
130 QVariantMap configuration()
const;
142 void setConfiguration(
const QVariantMap &configuration );
150 const QgsProcessingAlgorithm *
algorithm()
const;
158 QMap< QString, QList< QgsProcessingModelChildParameterSource > > parameterSources()
const {
return mParams; }
166 void setParameterSources(
const QMap< QString, QList< QgsProcessingModelChildParameterSource > > &sources ) { mParams = sources; }
177 void addParameterSources(
const QString &name,
const QList< QgsProcessingModelChildParameterSource > &source ) { mParams.insert( name, source ); }
183 bool isActive()
const {
return mActive; }
189 void setActive(
bool active ) { mActive = active; }
196 QList< QgsProcessingModelChildDependency > dependencies()
const {
return mDependencies; }
203 void setDependencies(
const QList< QgsProcessingModelChildDependency > &dependencies ) { mDependencies = dependencies; }
212 QMap<QString, QgsProcessingModelOutput> modelOutputs()
const {
return mModelOutputs; }
224 QgsProcessingModelOutput &modelOutput(
const QString &name ) {
return mModelOutputs[name]; }
235 void setModelOutputs(
const QMap<QString, QgsProcessingModelOutput> &outputs );
245 bool removeModelOutput(
const QString &name );
251 QVariant toVariant()
const;
257 bool loadVariant(
const QVariant &child );
270 QStringList asPythonCode(
275 const QMap<QString, QString> &friendlyChildNames,
276 const QMap<QString, QString> &friendlyOutputNames
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; }
286 QString mAlgorithmId;
287 std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
289 QVariantMap mConfiguration;
292 QMap< QString, QgsProcessingModelChildParameterSources > mParams;
295 QMap< QString, QgsProcessingModelOutput > mModelOutputs;
300 QList< QgsProcessingModelChildDependency > mDependencies;
302 QgsProcessingModelComment mComment;
304 friend class TestQgsProcessingModelAlgorithm;
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