QGIS API Documentation  3.21.0-Master (5b68dc587e)
qgsprocessingoutputs.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingoutputs.h
3  -------------------------
4  begin : May 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 QGSPROCESSINGOUTPUTS_H
19 #define QGSPROCESSINGOUTPUTS_H
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
24 
25 //
26 // Output definitions
27 //
28 
42 {
43 
44 #ifdef SIP_RUN
46  if ( sipCpp->type() == QgsProcessingOutputVectorLayer::typeName() )
47  sipType = sipType_QgsProcessingOutputVectorLayer;
48  else if ( sipCpp->type() == QgsProcessingOutputRasterLayer::typeName() )
49  sipType = sipType_QgsProcessingOutputRasterLayer;
50  else if ( sipCpp->type() == QgsProcessingOutputMapLayer::typeName() )
51  sipType = sipType_QgsProcessingOutputMapLayer;
52  else if ( sipCpp->type() == QgsProcessingOutputMultipleLayers::typeName() )
53  sipType = sipType_QgsProcessingOutputMultipleLayers;
54  else if ( sipCpp->type() == QgsProcessingOutputHtml::typeName() )
55  sipType = sipType_QgsProcessingOutputHtml;
56  else if ( sipCpp->type() == QgsProcessingOutputNumber::typeName() )
57  sipType = sipType_QgsProcessingOutputNumber;
58  else if ( sipCpp->type() == QgsProcessingOutputString::typeName() )
59  sipType = sipType_QgsProcessingOutputString;
60  else if ( sipCpp->type() == QgsProcessingOutputBoolean::typeName() )
61  sipType = sipType_QgsProcessingOutputBoolean;
62  else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
63  sipType = sipType_QgsProcessingOutputFolder;
64  else if ( sipCpp->type() == QgsProcessingOutputFile::typeName() )
65  sipType = sipType_QgsProcessingOutputFile;
66  else if ( sipCpp->type() == QgsProcessingOutputConditionalBranch::typeName() )
67  sipType = sipType_QgsProcessingOutputConditionalBranch;
68  else
69  sipType = nullptr;
70  SIP_END
71 #endif
72 
73  public:
74 
78  QgsProcessingOutputDefinition( const QString &name, const QString &description = QString() );
79 
80  virtual ~QgsProcessingOutputDefinition() = default;
81 
85  virtual QString type() const = 0;
86 
92  QString name() const { return mName; }
93 
99  void setName( const QString &name ) { mName = name; }
100 
106  QString description() const { return mDescription; }
107 
113  void setDescription( const QString &description ) { mDescription = description; }
114 
121  void setAutoCreated( bool autoCreated ) { mAutoCreated = autoCreated; }
122 
128  bool autoCreated() const { return mAutoCreated; }
129 
130  protected:
131 
133  QString mName;
134 
136  QString mDescription;
137 
138  bool mAutoCreated = false;
139 
140 };
141 
143 typedef QList< const QgsProcessingOutputDefinition * > QgsProcessingOutputDefinitions;
144 
156 {
157  public:
158 
162  QgsProcessingOutputMapLayer( const QString &name, const QString &description = QString() );
163 
167  static QString typeName() { return QStringLiteral( "outputLayer" ); }
168 
169  QString type() const override;
170 
171 };
172 
180 {
181  public:
182 
186  QgsProcessingOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessing::SourceType type = QgsProcessing::TypeVectorAnyGeometry );
187 
191  static QString typeName() { return QStringLiteral( "outputVector" ); }
192  QString type() const override { return typeName(); }
193 
198  QgsProcessing::SourceType dataType() const;
199 
204  void setDataType( QgsProcessing::SourceType type );
205 
206  private:
207 
209 };
210 
218 {
219  public:
220 
224  QgsProcessingOutputRasterLayer( const QString &name, const QString &description = QString() );
225 
229  static QString typeName() { return QStringLiteral( "outputRaster" ); }
230  QString type() const override { return typeName(); }
231 
232 
233 };
234 
249 {
250  public:
251 
255  QgsProcessingOutputMultipleLayers( const QString &name, const QString &description = QString() );
256 
260  static QString typeName() { return QStringLiteral( "outputMultilayer" ); }
261  QString type() const override;
262 
263 };
264 
272 {
273  public:
274 
278  QgsProcessingOutputHtml( const QString &name, const QString &description = QString() );
279 
283  static QString typeName() { return QStringLiteral( "outputHtml" ); }
284  QString type() const override { return typeName(); }
285 
286 };
287 
295 {
296  public:
297 
301  QgsProcessingOutputNumber( const QString &name, const QString &description = QString() );
302 
306  static QString typeName() { return QStringLiteral( "outputNumber" ); }
307  QString type() const override { return typeName(); }
308 };
309 
317 {
318  public:
319 
323  QgsProcessingOutputString( const QString &name, const QString &description = QString() );
324 
328  static QString typeName() { return QStringLiteral( "outputString" ); }
329  QString type() const override { return typeName(); }
330 
331 };
332 
340 {
341  public:
342 
346  QgsProcessingOutputBoolean( const QString &name, const QString &description = QString() );
347 
351  static QString typeName() { return QStringLiteral( "outputBoolean" ); }
352  QString type() const override { return typeName(); }
353 };
354 
362 {
363  public:
364 
369  QgsProcessingOutputFolder( const QString &name, const QString &description = QString() );
370 
374  static QString typeName() { return QStringLiteral( "outputFolder" ); }
375  QString type() const override { return typeName(); }
376 
377 };
378 
386 {
387  public:
388 
392  QgsProcessingOutputFile( const QString &name, const QString &description = QString() );
393 
397  static QString typeName() { return QStringLiteral( "outputFile" ); }
398  QString type() const override { return typeName(); }
399 
400 };
401 
410 {
411  public:
412 
416  QgsProcessingOutputConditionalBranch( const QString &name, const QString &description = QString() );
417 
421  static QString typeName() { return QStringLiteral( "outputBranch" ); }
422  QString type() const override { return typeName(); }
423 
424 };
425 
426 
427 #endif // QGSPROCESSINGOUTPUTS_H
428 
429 
A boolean output for processing algorithms.
QString type() const override
Unique output type name.
static QString typeName()
Returns the type name for the output class.
A conditional branch output for processing algorithms, which represents a possible model logic flow w...
static QString typeName()
Returns the type name for the output class.
QString type() const override
Unique output type name.
Base class for the definition of processing outputs.
void setDescription(const QString &description)
Sets the description for the output.
QString name() const
Returns the name of the output.
void setName(const QString &name)
Sets the name of the output.
void setAutoCreated(bool autoCreated)
Sets whether an output was automatically created when adding a parameter.
virtual ~QgsProcessingOutputDefinition()=default
virtual QString type() const =0
Unique output type name.
bool autoCreated() const
Returns true if the output was automatically created when adding a parameter.
QString mDescription
Output description.
QString description() const
Returns the description for the output.
A file output for processing algorithms.
QString type() const override
Unique output type name.
static QString typeName()
Returns the type name for the output class.
A folder output for processing algorithms.
QString type() const override
Unique output type name.
static QString typeName()
Returns the type name for the output class.
A HTML file output for processing algorithms.
QString type() const override
Unique output type name.
static QString typeName()
Returns the type name for the output class.
A map layer output for processing algorithms, where layers may be either vector or raster.
static QString typeName()
Returns the type name for the output class.
A multi-layer output for processing algorithms which create map layers, when the number and nature of...
static QString typeName()
Returns the type name for the output class.
A numeric output for processing algorithms.
QString type() const override
Unique output type name.
static QString typeName()
Returns the type name for the output class.
A raster layer output for processing algorithms.
static QString typeName()
Returns the type name for the output class.
QString type() const override
Unique output type name.
A string output for processing algorithms.
QString type() const override
Unique output type name.
static QString typeName()
Returns the type name for the output class.
A vector layer output for processing algorithms.
QString type() const override
Unique output type name.
static QString typeName()
Returns the type name for the output class.
SourceType
Data source types enum.
Definition: qgsprocessing.h:46
@ TypeVectorAnyGeometry
Any vector layer with geometry.
Definition: qgsprocessing.h:48
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_END
Definition: qgis_sip.h:194
QList< const QgsProcessingOutputDefinition * > QgsProcessingOutputDefinitions
List of processing parameters.
const QString & typeName