QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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"
23
25
26//
27// Output definitions
28//
29
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() == QgsProcessingOutputPointCloudLayer::typeName() )
51 sipType = sipType_QgsProcessingOutputPointCloudLayer;
52 else if ( sipCpp->type() == QgsProcessingOutputVectorTileLayer::typeName() )
53 sipType = sipType_QgsProcessingOutputVectorTileLayer;
54 else if ( sipCpp->type() == QgsProcessingOutputMapLayer::typeName() )
55 sipType = sipType_QgsProcessingOutputMapLayer;
56 else if ( sipCpp->type() == QgsProcessingOutputMultipleLayers::typeName() )
57 sipType = sipType_QgsProcessingOutputMultipleLayers;
58 else if ( sipCpp->type() == QgsProcessingOutputHtml::typeName() )
59 sipType = sipType_QgsProcessingOutputHtml;
60 else if ( sipCpp->type() == QgsProcessingOutputNumber::typeName() )
61 sipType = sipType_QgsProcessingOutputNumber;
62 else if ( sipCpp->type() == QgsProcessingOutputString::typeName() )
63 sipType = sipType_QgsProcessingOutputString;
64 else if ( sipCpp->type() == QgsProcessingOutputBoolean::typeName() )
65 sipType = sipType_QgsProcessingOutputBoolean;
66 else if ( sipCpp->type() == QgsProcessingOutputFolder::typeName() )
67 sipType = sipType_QgsProcessingOutputFolder;
68 else if ( sipCpp->type() == QgsProcessingOutputFile::typeName() )
69 sipType = sipType_QgsProcessingOutputFile;
70 else if ( sipCpp->type() == QgsProcessingOutputConditionalBranch::typeName() )
71 sipType = sipType_QgsProcessingOutputConditionalBranch;
72 else if ( sipCpp->type() == QgsProcessingOutputVariant::typeName() )
73 sipType = sipType_QgsProcessingOutputVariant;
74 else
75 sipType = nullptr;
77#endif
78
79 public:
80
84 QgsProcessingOutputDefinition( const QString &name, const QString &description = QString() );
85
86 virtual ~QgsProcessingOutputDefinition() = default;
87
91 virtual QString type() const = 0;
92
98 QString name() const { return mName; }
99
105 void setName( const QString &name ) { mName = name; }
106
112 QString description() const { return mDescription; }
113
119 void setDescription( const QString &description ) { mDescription = description; }
120
127 void setAutoCreated( bool autoCreated ) { mAutoCreated = autoCreated; }
128
134 bool autoCreated() const { return mAutoCreated; }
135
148 virtual QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const;
149
164 virtual QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const;
165
166 protected:
167
169 QString mName;
170
173
174 bool mAutoCreated = false;
175};
176
178typedef QList< const QgsProcessingOutputDefinition * > QgsProcessingOutputDefinitions;
179
190{
191 public:
192
196 QgsProcessingOutputMapLayer( const QString &name, const QString &description = QString() );
197
201 static QString typeName() { return QStringLiteral( "outputLayer" ); }
202
203 QString type() const override;
204
205};
206
213{
214 public:
215
219 QgsProcessingOutputVectorLayer( const QString &name, const QString &description = QString(), Qgis::ProcessingSourceType type = Qgis::ProcessingSourceType::VectorAnyGeometry );
220
224 static QString typeName() { return QStringLiteral( "outputVector" ); }
225 QString type() const override { return typeName(); }
226
231 Qgis::ProcessingSourceType dataType() const;
232
237 void setDataType( Qgis::ProcessingSourceType type );
238
239 private:
240
242};
243
250{
251 public:
252
256 QgsProcessingOutputRasterLayer( const QString &name, const QString &description = QString() );
257
261 static QString typeName() { return QStringLiteral( "outputRaster" ); }
262 QString type() const override { return typeName(); }
263};
264
272{
273 public:
274
278 QgsProcessingOutputPointCloudLayer( const QString &name, const QString &description = QString() );
279
283 static QString typeName() { return QStringLiteral( "outputPointCloud" ); }
284 QString type() const override { return typeName(); }
285};
286
300{
301 public:
302
306 QgsProcessingOutputMultipleLayers( const QString &name, const QString &description = QString() );
307
311 static QString typeName() { return QStringLiteral( "outputMultilayer" ); }
312 QString type() const override;
313 QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
314
315};
316
323{
324 public:
325
329 QgsProcessingOutputHtml( const QString &name, const QString &description = QString() );
330
334 static QString typeName() { return QStringLiteral( "outputHtml" ); }
335 QString type() const override { return typeName(); }
336 QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
337};
338
339
347{
348 public:
349
353 QgsProcessingOutputVariant( const QString &name, const QString &description = QString() );
354
358 static QString typeName() { return QStringLiteral( "outputVariant" ); }
359 QString type() const override;
360 QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
361
362};
363
370{
371 public:
372
376 QgsProcessingOutputNumber( const QString &name, const QString &description = QString() );
377
381 static QString typeName() { return QStringLiteral( "outputNumber" ); }
382 QString type() const override { return typeName(); }
383 QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
384
385};
386
393{
394 public:
395
399 QgsProcessingOutputString( const QString &name, const QString &description = QString() );
400
404 static QString typeName() { return QStringLiteral( "outputString" ); }
405 QString type() const override { return typeName(); }
406};
407
415{
416 public:
417
421 QgsProcessingOutputBoolean( const QString &name, const QString &description = QString() );
422
426 static QString typeName() { return QStringLiteral( "outputBoolean" ); }
427 QString type() const override { return typeName(); }
428 QString valueAsString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
429};
430
437{
438 public:
439
444 QgsProcessingOutputFolder( const QString &name, const QString &description = QString() );
445
449 static QString typeName() { return QStringLiteral( "outputFolder" ); }
450 QString type() const override { return typeName(); }
451 QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
452
453};
454
461{
462 public:
463
467 QgsProcessingOutputFile( const QString &name, const QString &description = QString() );
468
472 static QString typeName() { return QStringLiteral( "outputFile" ); }
473 QString type() const override { return typeName(); }
474 QString valueAsFormattedString( const QVariant &value, QgsProcessingContext &context, bool &ok SIP_OUT ) const override;
475
476};
477
486{
487 public:
488
492 QgsProcessingOutputConditionalBranch( const QString &name, const QString &description = QString() );
493
497 static QString typeName() { return QStringLiteral( "outputBranch" ); }
498 QString type() const override { return typeName(); }
499};
500
508{
509 public:
510
514 QgsProcessingOutputVectorTileLayer( const QString &name, const QString &description = QString() );
515
519 static QString typeName() { return QStringLiteral( "outputVectorTile" ); }
520 QString type() const override { return typeName(); }
521};
522
523#endif // QGSPROCESSINGOUTPUTS_H
ProcessingSourceType
Processing data source types.
Definition: qgis.h:2858
@ VectorAnyGeometry
Any vector layer with geometry.
Contains information about the context in which a processing algorithm is executed.
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 pointcloud layer 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 variant output for processing algorithms, capable of storing any QVariant value.
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.
A vector tile layer output for processing algorithms.
static QString typeName()
Returns the type name for the output class.
QString type() const override
Unique output type name.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:191
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_END
Definition: qgis_sip.h:208
QList< const QgsProcessingOutputDefinition * > QgsProcessingOutputDefinitions
List of processing parameters.
const QString & typeName