QGIS API Documentation  3.6.0-Noosa (5873452)
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"
24 #include "qgsprocessingfeedback.h"
25 #include "qgsprocessingalgorithm.h"
26 
28 
35 class CORE_EXPORT QgsProcessingAlgRunnerTask : public QgsTask
36 {
37  Q_OBJECT
38 
39  public:
40 
46  const QVariantMap &parameters,
47  QgsProcessingContext &context,
48  QgsProcessingFeedback *feedback = nullptr );
49 
50  void cancel() override;
51 
52  signals:
53 
59  void executed( bool successful, const QVariantMap &results );
60 
61  protected:
62 
63  bool run() override;
64  void finished( bool result ) override;
65 
66  private:
67 
68  QVariantMap mParameters;
69  QVariantMap mResults;
70  QgsProcessingContext &mContext;
71  QgsProcessingFeedback *mFeedback = nullptr;
72  std::unique_ptr< QgsProcessingFeedback > mOwnedFeedback;
73  std::unique_ptr< QgsProcessingAlgorithm > mAlgorithm;
74 
75 };
76 
77 #endif // QGSPROCESSINGALGRUNNERTASK_H
78 
79 
Base class for providing feedback from a processing algorithm.
Abstract base class for processing algorithms.
Abstract base class for long running background tasks.
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
virtual void cancel()
Notifies the task that it should terminate.
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&#39;s operation.
QgsTask task which runs a QgsProcessingAlgorithm in a background task.
Contains information about the context in which a processing algorithm is executed.