89 const auto constMProviders = mProviders;
110 QgsLogger::warning( QStringLiteral(
"Duplicate provider %1 registered" ).arg( provider->
id() ) );
115 if ( !provider->
load() )
122 provider->setParent(
this );
123 mProviders[ provider->
id()] = provider;
125 mCachedInformation.clear();
128 mCachedInformation.clear();
140 const QString
id = provider->
id();
142 if ( !mProviders.contains(
id ) )
147 delete mProviders.take(
id );
149 mCachedInformation.clear();
163 auto it = mProviders.constFind(
id );
164 if ( it != mProviders.constEnd() )
168 if (
id.compare( QLatin1String(
"grass7" ), Qt::CaseInsensitive ) == 0 )
176 QList< const QgsProcessingAlgorithm * > algs;
177 QMap<QString, QgsProcessingProvider *>::const_iterator it = mProviders.constBegin();
178 for ( ; it != mProviders.constEnd(); ++it )
180 algs.append( it.value()->algorithms() );
187 const auto it = mCachedInformation.constFind(
id );
188 if ( it != mCachedInformation.constEnd() )
197 mCachedInformation.insert(
id, info );
203 if ( constId.isEmpty() )
207 const QString
id = mAlgorithmAliases.value( constId, constId );
210 static thread_local QRegularExpression reSplitProviderId( QStringLiteral(
"^(.*?):(.*)$" ) );
211 const QRegularExpressionMatch match = reSplitProviderId.match(
id );
212 if ( match.hasMatch() )
223 if ( match.captured( 1 ) == QLatin1String(
"qgis" ) )
225 const QString algorithmName =
id.mid( 5 );
235 QMap<QString, QgsProcessingProvider *>::const_iterator it = mProviders.constBegin();
236 for ( ; it != mProviders.constEnd(); ++it )
238 const QList< const QgsProcessingAlgorithm * >
algorithms = it.value()->algorithms();
240 if ( alg->id() == id )
253 std::unique_ptr< QgsProcessingAlgorithm > creation( alg->
create( configuration ) );
254 return creation.release();
259 mAlgorithmAliases.insert( aliasId, actualId );
264 if ( !mParameterTypes.contains( type->
id() ) )
266 mParameterTypes.insert( type->
id(), type );
272 QgsLogger::warning( QStringLiteral(
"Duplicate parameter type %1 (\"%2\") registered" ).arg( type->
id(), type->
name() ) );
274 if ( mParameterTypes.value( type->
id() ) != type )
283 mParameterTypes.remove( type->
id() );
290 return mParameterTypes.value(
id );
295 return mParameterTypes.values();
static void warning(const QString &msg)
Goes to qWarning.
Abstract base class for processing algorithms.
virtual QIcon icon() const
Returns an icon for the algorithm.
virtual QString displayName() const =0
Returns the translated algorithm name, which should be used for any user-visible display of the algor...
QgsProcessingAlgorithm * create(const QVariantMap &configuration=QVariantMap()) const
Creates a copy of the algorithm, ready for execution.
An annotation layer parameter for processing algorithms.
An area parameter for processing algorithms.
A authentication configuration parameter for processing algorithms.
A raster band parameter for Processing algorithms.
A boolean parameter for processing algorithms.
A color parameter for Processing algorithms.
A coordinate operation parameter for Processing algorithms.
A crs parameter for processing algorithms.
A database schema name parameter for processing algorithms.
A database table name parameter for processing algorithms.
A datetime parameter for processing algorithms.
A distance parameter for processing algorithms.
A duration parameter for processing algorithms.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
An expression parameter for processing algorithms.
A rectangular map extent parameter for processing algorithms.
A feature sink parameter for Processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
A vector layer or feature source field parameter for processing algorithms.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
An input file or folder parameter for processing algorithms.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
A geometry parameter for processing algorithms.
A print layout item parameter for Processing algorithms.
A print layout parameter for Processing algorithms.
A generic map layer parameter for processing algorithms.
A map theme parameter for Processing algorithms.
A table (matrix) parameter for processing algorithms.
A mesh layer parameter for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
A numeric parameter for processing algorithms.
A point cloud layer attribute parameter for Processing algorithms.
A pointcloud layer destination parameter, for specifying the destination path for a point cloud layer...
A point cloud layer parameter for processing algorithms.
A point parameter for processing algorithms.
A provider connection name parameter for processing algorithms.
A numeric range parameter for processing algorithms.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
A raster layer parameter for processing algorithms.
A scale parameter for processing algorithms.
A string parameter for processing algorithms.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
A vector layer parameter for processing algorithms.
A vector tile layer destination parameter, for specifying the destination path for a vector tile laye...
A volume parameter for processing algorithms.
Makes metadata of processing parameters available.
virtual QString name() const =0
A human readable and translatable short name for this parameter type.
virtual QString id() const =0
A static id for this type which will be used for storing this parameter type.
Abstract base class for processing providers.
void algorithmsLoaded()
Emitted when the provider has loaded (or refreshed) its list of available algorithms.
virtual void unload()
Unloads the provider.
virtual QString id() const =0
Returns the unique provider id, used for identifying the provider.
virtual bool load()
Loads the provider.
void removeParameterType(QgsProcessingParameterType *type)
Unregister a custom parameter type from processing.
void parameterTypeAdded(QgsProcessingParameterType *type)
Emitted when a new parameter type has been added to the registry.
~QgsProcessingRegistry() override
QgsProcessingAlgorithm * createAlgorithmById(const QString &id, const QVariantMap &configuration=QVariantMap()) const
Creates a new instance of an algorithm by its ID.
void parameterTypeRemoved(QgsProcessingParameterType *type)
Emitted when a parameter type has been removed from the registry and is about to be deleted.
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.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
bool removeProvider(QgsProcessingProvider *provider)
Removes a provider implementation from the registry (the provider object is deleted).
bool addParameterType(QgsProcessingParameterType *type)
Register a new parameter type for processing.
QgsProcessingRegistry(QObject *parent=nullptr)
Constructor for QgsProcessingRegistry.
const QgsProcessingAlgorithm * algorithmById(const QString &id) const
Finds an algorithm by its ID.
QgsProcessingProvider * providerById(const QString &id) const
Returns a matching provider by provider ID.
void providerAdded(const QString &id)
Emitted when a provider has been added to the registry.
QList< QgsProcessingParameterType * > parameterTypes() const
Returns a list with all known parameter types.
bool addProvider(QgsProcessingProvider *provider)
Add a processing provider to the registry.
void providerRemoved(const QString &id)
Emitted when a provider is removed from the registry.
void addAlgorithmAlias(const QString &aliasId, const QString &actualId)
Adds a new alias to an existing algorithm.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call