Skip to content

Commit 241d283

Browse files
committedApr 26, 2017
Create a context object for processing algorithm execution
1 parent fea6bff commit 241d283

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed
 

‎python/core/core.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@
276276
%Include layertree/qgslayertreeutils.sip
277277

278278
%Include processing/qgsprocessingalgorithm.sip
279+
%Include processing/qgsprocessingcontext.sip
279280
%Include processing/qgsprocessingfeedback.sip
280281
%Include processing/qgsprocessingprovider.sip
281282
%Include processing/qgsprocessingregistry.sip
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/processing/qgsprocessingcontext.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
class QgsProcessingContext
15+
{
16+
%Docstring
17+
Contains information about the context in which a processing algorithm is executed.
18+
19+
Contextual information includes settings such as the associated project, and
20+
expression context.
21+
.. versionadded:: 3.0
22+
%End
23+
24+
%TypeHeaderCode
25+
#include "qgsprocessingcontext.h"
26+
%End
27+
public:
28+
29+
QgsProcessingContext();
30+
31+
QgsProject *project() const;
32+
%Docstring
33+
Returns the project in which the algorithm is being executed.
34+
\see setProject()
35+
:rtype: QgsProject
36+
%End
37+
38+
void setProject( QgsProject *project );
39+
%Docstring
40+
Sets the ``project`` in which the algorithm will be executed.
41+
\see project()
42+
%End
43+
44+
QgsExpressionContext expressionContext() const;
45+
%Docstring
46+
Returns the expression context.
47+
:rtype: QgsExpressionContext
48+
%End
49+
50+
void setExpressionContext( const QgsExpressionContext &context );
51+
%Docstring
52+
Sets the expression ``context``.
53+
%End
54+
55+
};
56+
57+
58+
59+
60+
61+
/************************************************************************
62+
* This file has been generated automatically from *
63+
* *
64+
* src/core/processing/qgsprocessingcontext.h *
65+
* *
66+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
67+
************************************************************************/
68+

‎src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ SET(QGIS_CORE_HDRS
852852
composer/qgspaperitem.h
853853

854854
processing/qgsprocessingalgorithm.h
855+
processing/qgsprocessingcontext.h
855856
processing/qgsprocessingutils.h
856857

857858
raster/qgsbilinearrasterresampler.h
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/***************************************************************************
2+
qgsprocessingcontext.h
3+
----------------------
4+
begin : April 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 QGSPROCESSINGCONTEXT_H
19+
#define QGSPROCESSINGCONTEXT_H
20+
21+
#include "qgis_core.h"
22+
#include "qgis.h"
23+
#include "qgsproject.h"
24+
#include "qgsexpressioncontext.h"
25+
26+
/**
27+
* \class QgsProcessingContext
28+
* \ingroup core
29+
* Contains information about the context in which a processing algorithm is executed.
30+
*
31+
* Contextual information includes settings such as the associated project, and
32+
* expression context.
33+
* \since QGIS 3.0
34+
*/
35+
36+
class CORE_EXPORT QgsProcessingContext
37+
{
38+
public:
39+
40+
QgsProcessingContext() = default;
41+
42+
/**
43+
* Returns the project in which the algorithm is being executed.
44+
* \see setProject()
45+
*/
46+
QgsProject *project() const { return mProject; }
47+
48+
/**
49+
* Sets the \a project in which the algorithm will be executed.
50+
* \see project()
51+
*/
52+
void setProject( QgsProject *project ) { mProject = project; }
53+
54+
/**
55+
* Returns the expression context.
56+
*/
57+
QgsExpressionContext expressionContext() const { return mExpressionContext; }
58+
59+
/**
60+
* Sets the expression \a context.
61+
*/
62+
void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }
63+
64+
private:
65+
66+
QPointer< QgsProject > mProject;
67+
68+
QgsExpressionContext mExpressionContext;
69+
70+
};
71+
72+
#endif // QGSPROCESSINGPARAMETERS_H
73+
74+
75+
76+

0 commit comments

Comments
 (0)
Please sign in to comment.