Skip to content

Commit 9e8a114

Browse files
committed
Allow specifying algorithm configuration when calling create
1 parent 1e13d73 commit 9e8a114

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

python/core/processing/qgsprocessingalgorithm.sip

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ class QgsProcessingAlgorithm
4747
virtual ~QgsProcessingAlgorithm();
4848

4949

50-
QgsProcessingAlgorithm *create() const /Factory/;
50+
QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const /Factory/;
5151
%Docstring
5252
Creates a copy of the algorithm, ready for execution.
5353

5454
This method returns a new, preinitialized copy of the algorithm, ready for
5555
executing.
5656

57+
The ``configuration`` argument allows passing of a map of configuration settings
58+
to the algorithm, allowing it to dynamically adjust its initialized parameters
59+
and outputs according to this configuration. This is generally used only for
60+
algorithms in a model, allowing them to adjust their behavior at run time
61+
according to some user configuration.
62+
5763
.. seealso:: initAlgorithm()
5864
:rtype: QgsProcessingAlgorithm
5965
%End

src/core/processing/qgsprocessingalgorithm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ QgsProcessingAlgorithm::~QgsProcessingAlgorithm()
3333
qDeleteAll( mOutputs );
3434
}
3535

36-
QgsProcessingAlgorithm *QgsProcessingAlgorithm::create() const
36+
QgsProcessingAlgorithm *QgsProcessingAlgorithm::create( const QVariantMap &configuration ) const
3737
{
3838
std::unique_ptr< QgsProcessingAlgorithm > creation( createInstance() );
3939
creation->setProvider( provider() );
40-
creation->initAlgorithm();
40+
creation->initAlgorithm( configuration );
4141
return creation.release();
4242
}
4343

src/core/processing/qgsprocessingalgorithm.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,15 @@ class CORE_EXPORT QgsProcessingAlgorithm
7777
* This method returns a new, preinitialized copy of the algorithm, ready for
7878
* executing.
7979
*
80+
* The \a configuration argument allows passing of a map of configuration settings
81+
* to the algorithm, allowing it to dynamically adjust its initialized parameters
82+
* and outputs according to this configuration. This is generally used only for
83+
* algorithms in a model, allowing them to adjust their behavior at run time
84+
* according to some user configuration.
85+
*
8086
* \see initAlgorithm()
8187
*/
82-
QgsProcessingAlgorithm *create() const SIP_FACTORY;
88+
QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const SIP_FACTORY;
8389

8490
/**
8591
* Returns the algorithm name, used for identifying the algorithm. This string

0 commit comments

Comments
 (0)