QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsprocessingalgrunnertask.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingalgrunnertask.h
3 ------------------------
4 begin : May 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 QGSPROCESSINGALGRUNNERTASK_H
19#define QGSPROCESSINGALGRUNNERTASK_H
20
21#include "qgis_core.h"
22#include "qgis.h"
23#include "qgstaskmanager.h"
26
28
34class CORE_EXPORT QgsProcessingAlgRunnerTask : public QgsTask
35{
36 Q_OBJECT
37
38 public:
39
47 const QVariantMap &parameters,
48 QgsProcessingContext &context,
49 QgsProcessingFeedback *feedback = nullptr,
51
52 void cancel() override;
53
59 bool algorithmCanceled() { return isCanceled(); }
60
61 signals:
62
68 void executed( bool successful, const QVariantMap &results );
69
70 protected:
71
72 bool run() override;
73 void finished( bool result ) override;
74
75 private:
76
77 QVariantMap mParameters;
78 QVariantMap mResults;
79 QgsProcessingContext &mContext;
80 QgsProcessingFeedback *mFeedback = nullptr;
81 std::unique_ptr< QgsProcessingFeedback > mOwnedFeedback;
82 std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
83
84};
85
86#endif // QGSPROCESSINGALGRUNNERTASK_H
87
88
QgsTask task which runs a QgsProcessingAlgorithm in a background task.
bool algorithmCanceled()
Returns true if the algorithm was canceled.
void executed(bool successful, const QVariantMap &results)
Emitted when the algorithm has finished execution.
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
Abstract base class for long running background tasks.
virtual void finished(bool result)
If the task is managed by a QgsTaskManager, this will be called after the task has finished (whether ...
virtual bool run()=0
Performs the task's operation.
QFlags< Flag > Flags
virtual void cancel()
Notifies the task that it should terminate.
@ CanCancel
Task can be canceled.
bool isCanceled() const
Will return true if task should terminate ASAP.
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