QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
QgsProviderRegistry Class Reference

A registry / canonical manager of data providers. More...

#include <qgsproviderregistry.h>

Collaboration diagram for QgsProviderRegistry:
Collaboration graph
[legend]

Public Types

typedef std::map< QString,
QgsProviderMetadata * > 
Providers
 open the given vector data source

Public Member Functions

virtual ~QgsProviderRegistry ()
 Virtual dectructor.
QString library (const QString &providerKey) const
 Return path for the library of the provider.
QString pluginList (bool asHtml=false) const
 Return list of provider plugins found.
const QDir & libraryDirectory () const
 return library directory where plugins are found
void setLibraryDirectory (const QDir &path)
 Set library directory where to search for plugins.
QgsDataProviderprovider (const QString &providerKey, const QString &dataSource)
 Create an instance of the provider.
QWidget * selectWidget (const QString &providerKey, QWidget *parent=0, Qt::WFlags fl=0)
void * function (const QString &providerKey, const QString &functionName)
 Get pointer to provider function.
QLibrary * providerLibrary (const QString &providerKey) const
QStringList providerList () const
 Return list of available providers by their keys.
const QgsProviderMetadataproviderMetadata (const QString &providerKey) const
 Return metadata of the provider or NULL if not found.
virtual QString fileVectorFilters () const
 return vector file filter string
virtual QString fileRasterFilters () const
 return raster file filter string
virtual QString databaseDrivers () const
 return a string containing the available database drivers
virtual QString directoryDrivers () const
 return a string containing the available directory drivers
virtual QString protocolDrivers () const
 return a string containing the available protocol drivers
void registerGuis (QWidget *widget)

Static Public Member Functions

static QgsProviderRegistryinstance (QString pluginPath=QString::null)
 means of accessing canonical single instance

Private Member Functions

 QgsProviderRegistry (QString pluginPath)
 ctor private since instance() creates it

Private Attributes

Providers mProviders
 associative container of provider metadata handles
QDir mLibraryDirectory
 directory in which provider plugins are installed
QString mVectorFileFilters
 file filter string for vector files
QString mRasterFileFilters
 file filter string for raster files
QString mDatabaseDrivers
 Available database drivers string for vector databases.
QString mDirectoryDrivers
 Available directory drivers string for vector databases.
QString mProtocolDrivers
 Available protocol drivers string for vector databases.

Static Private Attributes

static QgsProviderRegistry_instance = 0
 pointer to canonical Singleton object

Detailed Description

A registry / canonical manager of data providers.

This is a Singleton class that manages data provider access.

Definition at line 40 of file qgsproviderregistry.h.

Member Typedef Documentation

open the given vector data source

Similar to open(QString const &), except that the user specifies a data provider with which to open the data source instead of using the default data provider that QgsDataManager would figure out to use. This should be useful when (and if) there will exist more than one data provider that can handle a given data source. (E.g., use GDAL to open an SDTS file, or a different data provider that uses sdts++.)

Called by QgsDataManager::open().

Parameters
namecould be a file, URI
provideris the key for the dataprovider used to open name
Returns
NULL if unable to open vector data source

Temporarily always returns false until finished implementing.

Eventually would be nice if could make QgsDataManager smart enough to figure out whether the given name mapped to a vector, raster, or database source.type for data provider metadata associative container

Definition at line 155 of file qgsproviderregistry.h.

Constructor & Destructor Documentation

QgsProviderRegistry::~QgsProviderRegistry ( )
virtual

Virtual dectructor.

Definition at line 207 of file qgsproviderregistry.cpp.

QgsProviderRegistry::QgsProviderRegistry ( QString  pluginPath)
private

Member Function Documentation

QString QgsProviderRegistry::databaseDrivers ( ) const
virtual

return a string containing the available database drivers

Note
this method was added in QGIS 1.1

Definition at line 436 of file qgsproviderregistry.cpp.

References mDatabaseDrivers.

QString QgsProviderRegistry::directoryDrivers ( ) const
virtual

return a string containing the available directory drivers

Note
this method was added in QGIS 1.1

Definition at line 441 of file qgsproviderregistry.cpp.

References mDirectoryDrivers.

QString QgsProviderRegistry::fileRasterFilters ( ) const
virtual

return raster file filter string

Returns a string suitable for a QFileDialog of raster file formats supported by all data providers.

This walks through all data providers appending calls to their buildSupportedRasterFileFilter to a string, which is then returned.

Note
this method was added in QGIS 2.0
This replaces QgsRasterLayer::buildSupportedRasterFileFilter()

Definition at line 431 of file qgsproviderregistry.cpp.

References mRasterFileFilters.

Referenced by QgsProviderRegistry().

QString QgsProviderRegistry::fileVectorFilters ( ) const
virtual

return vector file filter string

Returns a string suitable for a QFileDialog of vector file formats supported by all data providers.

This walks through all data providers appending calls to their fileVectorFilters to a string, which is then returned.

Note

It'd be nice to eventually be raster/vector neutral.

Definition at line 426 of file qgsproviderregistry.cpp.

References mVectorFileFilters.

Referenced by QgsProjectBadLayerGuiHandler::handleBadLayers(), and QgsProviderRegistry().

void * QgsProviderRegistry::function ( const QString &  providerKey,
const QString &  functionName 
)

Get pointer to provider function.

Parameters
providerKeyidentificator of the provider
functionNamename of function
Returns
pointer to function or NULL on error

Definition at line 377 of file qgsproviderregistry.cpp.

References library(), and QgsDebugMsg.

Referenced by QgsRasterDataProvider::create(), QgsRasterLayer::isValidRasterFileName(), and QgsRasterDataProvider::pyramidResamplingMethods().

QgsProviderRegistry * QgsProviderRegistry::instance ( QString  pluginPath = QString::null)
static
QString QgsProviderRegistry::library ( const QString &  providerKey) const

Return path for the library of the provider.

Definition at line 236 of file qgsproviderregistry.cpp.

References findMetadata_(), QgsProviderMetadata::library(), and mProviders.

Referenced by function(), provider(), providerLibrary(), and QgsNewVectorLayerDialog::runAndCreateLayer().

QDir const & QgsProviderRegistry::libraryDirectory ( ) const

return library directory where plugins are found

Definition at line 289 of file qgsproviderregistry.cpp.

References mLibraryDirectory.

QString QgsProviderRegistry::pluginList ( bool  asHtml = false) const

Return list of provider plugins found.

Definition at line 249 of file qgsproviderregistry.cpp.

References mProviders, and tr.

QString QgsProviderRegistry::protocolDrivers ( ) const
virtual

return a string containing the available protocol drivers

Note
this method was added in QGIS 1.1

Definition at line 446 of file qgsproviderregistry.cpp.

References mProtocolDrivers.

QgsDataProvider * QgsProviderRegistry::provider ( const QString &  providerKey,
const QString &  dataSource 
)

Create an instance of the provider.

Copied from QgsVectorLayer::setDataProvider TODO: Make it work in the generic environment.

Parameters
providerKeyidentificator of the provider
dataSourcestring containing data source for the provider
Returns
instance of provider or NULL on error

TODO: Is this class really the best place to put a data provider loader? It seems more sensible to provide the code in one place rather than in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc.

Definition at line 308 of file qgsproviderregistry.cpp.

References cast_to_fptr, library(), QgsMessageLog::logMessage(), QgsDataProvider::name(), QgsDebugMsg, tr, and QgsLogger::warning().

Referenced by QgsRasterFileWriter::buildPyramids(), QgsVectorLayerImport::QgsVectorLayerImport(), registerGuis(), QgsRasterChecker::runTest(), QgsRasterLayer::setDataProvider(), and QgsVectorLayer::setDataProvider().

QLibrary * QgsProviderRegistry::providerLibrary ( const QString &  providerKey) const
QStringList QgsProviderRegistry::providerList ( ) const

Return list of available providers by their keys.

Definition at line 451 of file qgsproviderregistry.cpp.

References mProviders.

Referenced by QgsBrowserModel::addRootItems(), QgsDirectoryItem::QgsDirectoryItem(), and registerGuis().

const QgsProviderMetadata * QgsProviderRegistry::providerMetadata ( const QString &  providerKey) const

Return metadata of the provider or NULL if not found.

Definition at line 461 of file qgsproviderregistry.cpp.

References findMetadata_(), and mProviders.

void QgsProviderRegistry::registerGuis ( QWidget *  widget)

Definition at line 411 of file qgsproviderregistry.cpp.

References cast_to_fptr, provider(), and providerList().

QWidget * QgsProviderRegistry::selectWidget ( const QString &  providerKey,
QWidget *  parent = 0,
Qt::WFlags  fl = 0 
)

Definition at line 365 of file qgsproviderregistry.cpp.

References cast_to_fptr.

void QgsProviderRegistry::setLibraryDirectory ( const QDir &  path)

Set library directory where to search for plugins.

Definition at line 283 of file qgsproviderregistry.cpp.

References mLibraryDirectory.

Member Data Documentation

QgsProviderRegistry * QgsProviderRegistry::_instance = 0
staticprivate

pointer to canonical Singleton object

Definition at line 163 of file qgsproviderregistry.h.

Referenced by instance().

QString QgsProviderRegistry::mDatabaseDrivers
private

Available database drivers string for vector databases.

This is a string of form: DriverNameToShow,DriverName;DriverNameToShow,DriverName;...

Definition at line 188 of file qgsproviderregistry.h.

Referenced by databaseDrivers(), and QgsProviderRegistry().

QString QgsProviderRegistry::mDirectoryDrivers
private

Available directory drivers string for vector databases.

This is a string of form: DriverNameToShow,DriverName;DriverNameToShow,DriverName;...

Definition at line 194 of file qgsproviderregistry.h.

Referenced by directoryDrivers(), and QgsProviderRegistry().

QDir QgsProviderRegistry::mLibraryDirectory
private

directory in which provider plugins are installed

Definition at line 169 of file qgsproviderregistry.h.

Referenced by libraryDirectory(), QgsProviderRegistry(), and setLibraryDirectory().

QString QgsProviderRegistry::mProtocolDrivers
private

Available protocol drivers string for vector databases.

This is a string of form: DriverNameToShow,DriverName;DriverNameToShow,DriverName;...

Definition at line 200 of file qgsproviderregistry.h.

Referenced by protocolDrivers(), and QgsProviderRegistry().

Providers QgsProviderRegistry::mProviders
private

associative container of provider metadata handles

Definition at line 166 of file qgsproviderregistry.h.

Referenced by library(), pluginList(), providerList(), providerMetadata(), and QgsProviderRegistry().

QString QgsProviderRegistry::mRasterFileFilters
private

file filter string for raster files

Definition at line 182 of file qgsproviderregistry.h.

Referenced by fileRasterFilters(), and QgsProviderRegistry().

QString QgsProviderRegistry::mVectorFileFilters
private

file filter string for vector files

Built once when registry is constructed by appending strings returned from iteratively calling vectorFileFilter() for each visited data provider. The alternative would have been to do this each time fileVectorFilters was invoked; instead we only have to build it the one time.

Definition at line 179 of file qgsproviderregistry.h.

Referenced by fileVectorFilters(), and QgsProviderRegistry().


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