QGIS API Documentation 4.3.0-Master (96c7fa699b4)
Loading...
Searching...
No Matches
QgsProcessingRegistry Class Reference

Registry for various processing components, including providers, algorithms and various parameters and outputs. More...

#include <qgsprocessingregistry.h>

Inheritance diagram for QgsProcessingRegistry:

Signals

void parameterTypeAdded (QgsProcessingParameterType *type)
 Emitted when a new parameter type has been added to the registry.
void parameterTypeRemoved (QgsProcessingParameterType *type)
 Emitted when a parameter type has been removed from the registry and is about to be deleted.
void providerAdded (const QString &id)
 Emitted when a provider has been added to the registry.
void providerRemoved (const QString &id)
 Emitted when a provider is removed from the registry.

Public Member Functions

 QgsProcessingRegistry (const QgsProcessingRegistry &other)=delete
 QgsProcessingRegistry (QObject *parent=nullptr)
 Constructor for QgsProcessingRegistry.
 ~QgsProcessingRegistry () override
void addAlgorithmAlias (const QString &aliasId, const QString &actualId)
 Adds a new alias to an existing algorithm.
bool addParameterType (QgsProcessingParameterType *type)
 Register a new parameter type for processing.
bool addProvider (QgsProcessingProvider *provider)
 Add a processing provider to the registry.
const QgsProcessingAlgorithm * algorithmById (const QString &id) const
 Finds an algorithm by its ID.
QgsProcessingAlgorithmInformation algorithmInformation (const QString &id) const
 Returns basic algorithm information for the algorithm with matching ID.
QList< const QgsProcessingAlgorithm * > algorithms () const
 Returns a list of all available algorithms from registered providers.
QgsProcessingAlgorithm * createAlgorithmById (const QString &id, const QVariantMap &configuration=QVariantMap()) const
 Creates a new instance of an algorithm by its ID.
QgsProcessingDefaultStyleRegistry * defaultStyleRegistry () const
 Returns the default style registry, responsible for styling layers generated by Processing tools.
bool handleAlgorithmResults (const QgsProcessingAlgorithm *algorithm, QgsProcessingContext &context, const QVariantMap &parameters, QgsProcessingFeedback *feedback=nullptr)
 Handles the results from running an algorithm.
bool isCompatibleDefinition (const QgsProcessingParameterDefinition *targetDefinition, const QgsProcessingParameterDefinition *candidateDefinition)
 Returns true if the targetDefinition accepts candidateDefinition as compatible Processing parameter types for parameter type of targetDefinition.
bool isCompatibleOutput (const QgsProcessingParameterDefinition *targetDefinition, const QgsProcessingOutputDefinition *candidateOutput)
 Returns true if the targetDefinition accepts candidateOutput as compatible Processing output types for parameter type of targetDefinition.
QgsProcessingLayerPostProcessor * layerPostProcessor ()
 Returns the post-processor to use for all map layers generated by Processing algorithms.
QgsProcessingRegistry & operator= (const QgsProcessingRegistry &other)=delete
QgsProcessingParameterType * parameterType (const QString &id) const
 Returns the parameter type registered for id.
QList< QgsProcessingParameterType * > parameterTypes () const
 Returns a list with all known parameter types.
QgsProcessingProvider * providerById (const QString &id) const
 Returns a matching provider by provider ID.
QList< QgsProcessingProvider * > providers () const
 Gets list of available providers.
void removeParameterType (QgsProcessingParameterType *type)
 Unregister a custom parameter type from processing.
bool removeProvider (const QString &providerId)
 Removes a provider implementation from the registry (the provider object is deleted).
bool removeProvider (QgsProcessingProvider *provider)
 Removes a provider implementation from the registry (the provider object is deleted).
void setLayerPostProcessor (std::unique_ptr< QgsProcessingLayerPostProcessor > processor)
 Sets the post-processor to use for all map layers generated by Processing algorithms.
void setResultsHandler (std::unique_ptr< QgsProcessingResultsHandler > handler)
 Sets the results handler to use for results generated by Processing algorithms.

Friends

class TestQgsProcessing

Detailed Description

Registry for various processing components, including providers, algorithms and various parameters and outputs.

QgsProcessingRegistry is not usually directly created, but rather accessed through QgsApplication::processingRegistry().

Definition at line 59 of file qgsprocessingregistry.h.

Constructor & Destructor Documentation

◆ QgsProcessingRegistry() [1/2]

QgsProcessingRegistry::QgsProcessingRegistry ( QObject * parent = nullptr)

Constructor for QgsProcessingRegistry.

Definition at line 43 of file qgsprocessingregistry.cpp.

◆ ~QgsProcessingRegistry()

QgsProcessingRegistry::~QgsProcessingRegistry ( )
override

Definition at line 109 of file qgsprocessingregistry.cpp.

◆ QgsProcessingRegistry() [2/2]

QgsProcessingRegistry::QgsProcessingRegistry ( const QgsProcessingRegistry & other)
delete

Member Function Documentation

◆ addAlgorithmAlias()

void QgsProcessingRegistry::addAlgorithmAlias ( const QString & aliasId,
const QString & actualId )

Adds a new alias to an existing algorithm.

This allows algorithms to be referred to by a different provider ID and algorithm name to their actual underlying provider and algorithm name. It provides a mechanism to allow algorithms to be moved between providers without breaking existing scripts or plugins.

The aliasId argument specifies the "fake" algorithm id (eg "fake_provider:fake_alg") by which the algorithm can be referred to, and the actualId argument specifies the real algorithm ID for the algorithm.

Since
QGIS 3.10

Definition at line 276 of file qgsprocessingregistry.cpp.

◆ addParameterType()

bool QgsProcessingRegistry::addParameterType ( QgsProcessingParameterType * type)

Register a new parameter type for processing.

Ownership is transferred to the registry. Will emit parameterTypeAdded.

See also
removeParameterType
Since
QGIS 3.2

Definition at line 281 of file qgsprocessingregistry.cpp.

◆ addProvider()

bool QgsProcessingRegistry::addProvider ( QgsProcessingProvider * provider)

Add a processing provider to the registry.

Ownership of the provider is transferred to the registry, and the provider's parent will be set to the registry. Returns false if the provider could not be added (eg if a provider with a duplicate ID already exists in the registry). Adding a provider to the registry automatically triggers the providers QgsProcessingProvider::load() method to populate the provider with algorithms.

See also
removeProvider()

Definition at line 125 of file qgsprocessingregistry.cpp.

◆ algorithmById()

const QgsProcessingAlgorithm * QgsProcessingRegistry::algorithmById ( const QString & id) const

Finds an algorithm by its ID.

If no matching algorithm is found, nullptr is returned.

See also
algorithms()
createAlgorithmById()

Definition at line 220 of file qgsprocessingregistry.cpp.

◆ algorithmInformation()

QgsProcessingAlgorithmInformation QgsProcessingRegistry::algorithmInformation ( const QString & id) const

Returns basic algorithm information for the algorithm with matching ID.

This method uses an internal cache to ensure that information is quickly returned and is suitable for calling many times.

Since
QGIS 3.32

Definition at line 204 of file qgsprocessingregistry.cpp.

◆ algorithms()

QList< const QgsProcessingAlgorithm * > QgsProcessingRegistry::algorithms ( ) const

Returns a list of all available algorithms from registered providers.

See also
algorithmById()

Definition at line 193 of file qgsprocessingregistry.cpp.

◆ createAlgorithmById()

QgsProcessingAlgorithm * QgsProcessingRegistry::createAlgorithmById ( const QString & id,
const QVariantMap & configuration = QVariantMap() ) const

Creates a new instance of an algorithm by its ID.

If no matching algorithm is found, nullptr is returned. Callers take responsibility for deleting the returned object.

The configuration argument allows passing of a map of configuration settings to the algorithm, allowing it to dynamically adjust its initialized parameters and outputs according to this configuration. This is generally used only for algorithms in a model, allowing them to adjust their behavior at run time according to some user configuration.

See also
algorithms()
algorithmById()

Definition at line 266 of file qgsprocessingregistry.cpp.

◆ defaultStyleRegistry()

QgsProcessingDefaultStyleRegistry * QgsProcessingRegistry::defaultStyleRegistry ( ) const

Returns the default style registry, responsible for styling layers generated by Processing tools.

Since
QGIS 4.4

Definition at line 334 of file qgsprocessingregistry.cpp.

◆ handleAlgorithmResults()

bool QgsProcessingRegistry::handleAlgorithmResults ( const QgsProcessingAlgorithm * algorithm,
QgsProcessingContext & context,
const QVariantMap & parameters,
QgsProcessingFeedback * feedback = nullptr )

Handles the results from running an algorithm.

Returns true if all results could be successfully loaded. Internally calls the QgsProcessingResultsHandler set by setResultsHandler().

Warning
This is not considered stable API, and is exposed to Python for internal use only.
Since
QGIS 4.4

Definition at line 354 of file qgsprocessingregistry.cpp.

◆ isCompatibleDefinition()

bool QgsProcessingRegistry::isCompatibleDefinition ( const QgsProcessingParameterDefinition * targetDefinition,
const QgsProcessingParameterDefinition * candidateDefinition )

Returns true if the targetDefinition accepts candidateDefinition as compatible Processing parameter types for parameter type of targetDefinition.

Example

vectorLayerParam = QgsProcessingParameterVectorLayer( "dummyname" )
boolParam = QgsProcessingParameterBoolean( "dummyname" )
# Parameter source and parameter target are compatible
QgsApplication.processingRegistry().isCompatibleDefinition( vectorLayerParam, vectorLayerParam ) # -> return True
QgsApplication.processingRegistry().isCompatibleDefinition( boolParam, vectorLayerParam ) # -> return True
# Parameter source and parameter target are incompatible
QgsApplication.processingRegistry().isCompatibleDefinition( vectorLayerParam, boolParam ) # -> return False
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
A boolean parameter for processing algorithms.
A vector layer (with or without geometry) parameter for processing algorithms.
Since
QGIS 4.4

Definition at line 317 of file qgsprocessingregistry.cpp.

◆ isCompatibleOutput()

bool QgsProcessingRegistry::isCompatibleOutput ( const QgsProcessingParameterDefinition * targetDefinition,
const QgsProcessingOutputDefinition * candidateOutput )

Returns true if the targetDefinition accepts candidateOutput as compatible Processing output types for parameter type of targetDefinition.

  • ### Example
vectorLayerParam = QgsProcessingParameterVectorLayer( "dummyname" )
boolOutput = QgsProcessingOutputBoolean( "dummyname" )
stringOutput = QgsProcessingOutputString( "dummyname" )
vectorLayerOutput = QgsProcessingOutputVectorLayer( "dummyname" )
# Output source and parameter target are compatible
QgsApplication.processingRegistry().isCompatibleOutput( vectorLayerParam, stringOutput ) # -> return True
QgsApplication.processingRegistry().isCompatibleOutput( vectorLayerParam, vectorLayerOutput ) # -> return True
# Output source and parameter target are incompatible
QgsApplication.processingRegistry().isCompatibleOutput( vectorLayerParam, boolOutput ) # -> return False
A boolean output for processing algorithms.
A string output for processing algorithms.
A vector layer output for processing algorithms.
Since
QGIS 4.4

Definition at line 325 of file qgsprocessingregistry.cpp.

◆ layerPostProcessor()

QgsProcessingLayerPostProcessor * QgsProcessingRegistry::layerPostProcessor ( )

Returns the post-processor to use for all map layers generated by Processing algorithms.

See also
setLayerPostProcessor()
Since
QGIS 4.4

Definition at line 344 of file qgsprocessingregistry.cpp.

◆ operator=()

QgsProcessingRegistry & QgsProcessingRegistry::operator= ( const QgsProcessingRegistry & other)
delete

◆ parameterType()

QgsProcessingParameterType * QgsProcessingRegistry::parameterType ( const QString & id) const

Returns the parameter type registered for id.

Since
QGIS 3.2

Definition at line 307 of file qgsprocessingregistry.cpp.

◆ parameterTypeAdded

void QgsProcessingRegistry::parameterTypeAdded ( QgsProcessingParameterType * type)
signal

Emitted when a new parameter type has been added to the registry.

Since
QGIS 3.2

◆ parameterTypeRemoved

void QgsProcessingRegistry::parameterTypeRemoved ( QgsProcessingParameterType * type)
signal

Emitted when a parameter type has been removed from the registry and is about to be deleted.

Since
QGIS 3.2

◆ parameterTypes()

QList< QgsProcessingParameterType * > QgsProcessingRegistry::parameterTypes ( ) const

Returns a list with all known parameter types.

Since
QGIS 3.2

Definition at line 312 of file qgsprocessingregistry.cpp.

◆ providerAdded

void QgsProcessingRegistry::providerAdded ( const QString & id)
signal

Emitted when a provider has been added to the registry.

◆ providerById()

QgsProcessingProvider * QgsProcessingRegistry::providerById ( const QString & id) const

Returns a matching provider by provider ID.

Definition at line 180 of file qgsprocessingregistry.cpp.

◆ providerRemoved

void QgsProcessingRegistry::providerRemoved ( const QString & id)
signal

Emitted when a provider is removed from the registry.

◆ providers()

QList< QgsProcessingProvider * > QgsProcessingRegistry::providers ( ) const
inline

Gets list of available providers.

Definition at line 77 of file qgsprocessingregistry.h.

◆ removeParameterType()

void QgsProcessingRegistry::removeParameterType ( QgsProcessingParameterType * type)

Unregister a custom parameter type from processing.

The type will be deleted. Will emit parameterTypeRemoved.

See also
addParameterType
Since
QGIS 3.2

Definition at line 300 of file qgsprocessingregistry.cpp.

◆ removeProvider() [1/2]

bool QgsProcessingRegistry::removeProvider ( const QString & providerId)

Removes a provider implementation from the registry (the provider object is deleted).

Returns false if the provider could not be removed (eg provider does not exist in the registry).

See also
addProvider()

Definition at line 174 of file qgsprocessingregistry.cpp.

◆ removeProvider() [2/2]

bool QgsProcessingRegistry::removeProvider ( QgsProcessingProvider * provider)

Removes a provider implementation from the registry (the provider object is deleted).

Returns false if the provider could not be removed (eg provider does not exist in the registry).

See also
addProvider()

Definition at line 154 of file qgsprocessingregistry.cpp.

◆ setLayerPostProcessor()

void QgsProcessingRegistry::setLayerPostProcessor ( std::unique_ptr< QgsProcessingLayerPostProcessor > processor)

Sets the post-processor to use for all map layers generated by Processing algorithms.

Ownership of processor is transferred to the registry.

Note
A basic post-processor is created by default, which applies default styling to generated layers.
Not available in Python bindings
See also
layerPostProcessor()
Since
QGIS 4.4

Definition at line 339 of file qgsprocessingregistry.cpp.

◆ setResultsHandler()

void QgsProcessingRegistry::setResultsHandler ( std::unique_ptr< QgsProcessingResultsHandler > handler)

Sets the results handler to use for results generated by Processing algorithms.

Ownership of handler is transferred to the registry.

Note
A basic handler is created by default, which applies core/headless logic only.
Not available in Python bindings
See also
layerPostProcessor()
Since
QGIS 4.4

Definition at line 349 of file qgsprocessingregistry.cpp.

◆ TestQgsProcessing

friend class TestQgsProcessing
friend

Definition at line 362 of file qgsprocessingregistry.h.


The documentation for this class was generated from the following files: