Skip to content

Commit

Permalink
Simple c++ base class for processing algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 3, 2017
1 parent e462bfb commit 52cc002
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -273,6 +273,7 @@
%Include layertree/qgslayertreeregistrybridge.sip
%Include layertree/qgslayertreeutils.sip

%Include processing/qgsprocessingalgorithm.sip
%Include processing/qgsprocessingfeedback.sip
%Include processing/qgsprocessingprovider.sip
%Include processing/qgsprocessingregistry.sip
Expand Down
13 changes: 13 additions & 0 deletions python/core/processing/qgsprocessingalgorithm.sip
@@ -0,0 +1,13 @@
class QgsProcessingAlgorithm
{
%TypeHeaderCode
#include <qgsprocessingalgorithm.h>
%End

public:

QgsProcessingAlgorithm();
virtual ~QgsProcessingAlgorithm();

};

6 changes: 4 additions & 2 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -34,7 +34,8 @@

from qgis.core import (QgsApplication,
QgsProcessingFeedback,
QgsSettings)
QgsSettings,
QgsProcessingAlgorithm)

from builtins import str
from builtins import object
Expand All @@ -49,9 +50,10 @@
from processing.algs.help import shortHelp


class GeoAlgorithm(object):
class GeoAlgorithm(QgsProcessingAlgorithm):

def __init__(self):
super().__init__()
self._icon = QgsApplication.getThemeIcon("/processingAlgorithm.svg")
# Parameters needed by the algorithm
self.parameters = list()
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -84,6 +84,7 @@ SET(QGIS_CORE_SRCS
annotations/qgssvgannotation.cpp
annotations/qgstextannotation.cpp

processing/qgsprocessingalgorithm.cpp
processing/qgsprocessingprovider.cpp
processing/qgsprocessingregistry.cpp

Expand Down Expand Up @@ -835,6 +836,7 @@ SET(QGIS_CORE_HDRS
composer/qgssingleboxscalebarstyle.h
composer/qgsticksscalebarstyle.h

processing/qgsprocessingalgorithm.h
processing/qgsprocessingprovider.h

raster/qgsbilinearrasterresampler.h
Expand Down
18 changes: 18 additions & 0 deletions src/core/processing/qgsprocessingalgorithm.cpp
@@ -0,0 +1,18 @@
/***************************************************************************
qgsprocessingalgorithm.cpp
--------------------------
begin : December 2016
copyright : (C) 2016 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. *
* *
***************************************************************************/

#include "qgsprocessingalgorithm.h"
47 changes: 47 additions & 0 deletions src/core/processing/qgsprocessingalgorithm.h
@@ -0,0 +1,47 @@
/***************************************************************************
qgsprocessingalgorithm.h
------------------------
begin : December 2016
copyright : (C) 2016 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 QGSPROCESSINGALGORITHM_H
#define QGSPROCESSINGALGORITHM_H

#include "qgis_core.h"
#include <QString>
#include <QVariant>
#include <QIcon>

/**
* \class QgsProcessingAlgorithm
* \ingroup core
* Abstract base class for processing algorithms.
* \note added in QGIS 3.0
*/
class CORE_EXPORT QgsProcessingAlgorithm
{
public:

/**
* Constructor for QgsProcessingAlgorithm.
*/
QgsProcessingAlgorithm() = default;

virtual ~QgsProcessingAlgorithm() = default;

};

#endif // QGSPROCESSINGALGORITHM_H


0 comments on commit 52cc002

Please sign in to comment.