Skip to content

Commit

Permalink
Create a context object for processing algorithm execution
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent fea6bff commit 241d283
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -276,6 +276,7 @@
%Include layertree/qgslayertreeutils.sip

%Include processing/qgsprocessingalgorithm.sip
%Include processing/qgsprocessingcontext.sip
%Include processing/qgsprocessingfeedback.sip
%Include processing/qgsprocessingprovider.sip
%Include processing/qgsprocessingregistry.sip
Expand Down
68 changes: 68 additions & 0 deletions python/core/processing/qgsprocessingcontext.sip
@@ -0,0 +1,68 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessingcontext.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsProcessingContext
{
%Docstring
Contains information about the context in which a processing algorithm is executed.

Contextual information includes settings such as the associated project, and
expression context.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsprocessingcontext.h"
%End
public:

QgsProcessingContext();

QgsProject *project() const;
%Docstring
Returns the project in which the algorithm is being executed.
\see setProject()
:rtype: QgsProject
%End

void setProject( QgsProject *project );
%Docstring
Sets the ``project`` in which the algorithm will be executed.
\see project()
%End

QgsExpressionContext expressionContext() const;
%Docstring
Returns the expression context.
:rtype: QgsExpressionContext
%End

void setExpressionContext( const QgsExpressionContext &context );
%Docstring
Sets the expression ``context``.
%End

};





/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessingcontext.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -852,6 +852,7 @@ SET(QGIS_CORE_HDRS
composer/qgspaperitem.h

processing/qgsprocessingalgorithm.h
processing/qgsprocessingcontext.h
processing/qgsprocessingutils.h

raster/qgsbilinearrasterresampler.h
Expand Down
76 changes: 76 additions & 0 deletions src/core/processing/qgsprocessingcontext.h
@@ -0,0 +1,76 @@
/***************************************************************************
qgsprocessingcontext.h
----------------------
begin : April 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSPROCESSINGCONTEXT_H
#define QGSPROCESSINGCONTEXT_H

#include "qgis_core.h"
#include "qgis.h"
#include "qgsproject.h"
#include "qgsexpressioncontext.h"

/**
* \class QgsProcessingContext
* \ingroup core
* Contains information about the context in which a processing algorithm is executed.
*
* Contextual information includes settings such as the associated project, and
* expression context.
* \since QGIS 3.0
*/

class CORE_EXPORT QgsProcessingContext
{
public:

QgsProcessingContext() = default;

/**
* Returns the project in which the algorithm is being executed.
* \see setProject()
*/
QgsProject *project() const { return mProject; }

/**
* Sets the \a project in which the algorithm will be executed.
* \see project()
*/
void setProject( QgsProject *project ) { mProject = project; }

/**
* Returns the expression context.
*/
QgsExpressionContext expressionContext() const { return mExpressionContext; }

/**
* Sets the expression \a context.
*/
void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }

private:

QPointer< QgsProject > mProject;

QgsExpressionContext mExpressionContext;

};

#endif // QGSPROCESSINGPARAMETERS_H




0 comments on commit 241d283

Please sign in to comment.