Create a context object for processing algorithm execution

This commit is contained in:
Nyall Dawson 2017-04-24 10:22:38 +10:00
parent fea6bff707
commit 241d283bb8
4 changed files with 146 additions and 0 deletions

View File

@ -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

View File

@ -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 *
************************************************************************/

View File

@ -852,6 +852,7 @@ SET(QGIS_CORE_HDRS
composer/qgspaperitem.h
processing/qgsprocessingalgorithm.h
processing/qgsprocessingcontext.h
processing/qgsprocessingutils.h
raster/qgsbilinearrasterresampler.h

View File

@ -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