Quantum GIS API Documentation
1.7.4
|
A registry / canonical manager of data providers. More...
#include <qgsproviderregistry.h>
Public Types | |
typedef std::map< QString, QgsProviderMetadata * > | Providers |
open the given vector data source | |
Public Member Functions | |
virtual | ~QgsProviderRegistry () |
Virtual dectructor. | |
QString | library (QString const &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 (QDir const &path) |
Set library directory where to search for plugins. | |
QgsDataProvider * | getProvider (const QString &providerKey, const QString &dataSource) |
Create an instance of the provider. | |
QStringList | providerList () const |
Return list of available providers by their keys. | |
const QgsProviderMetadata * | providerMetadata (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 | 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 | |
Static Public Member Functions | |
static QgsProviderRegistry * | instance (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 | 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 |
A registry / canonical manager of data providers.
This is a Singleton class that manages data provider access.
Definition at line 39 of file qgsproviderregistry.h.
typedef std::map<QString, QgsProviderMetadata*> QgsProviderRegistry::Providers |
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().
name | could be a file, URI |
provider | is the key for the dataprovider used to open name |
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 127 of file qgsproviderregistry.h.
QgsProviderRegistry::~QgsProviderRegistry | ( | ) | [virtual] |
Virtual dectructor.
Definition at line 225 of file qgsproviderregistry.cpp.
QgsProviderRegistry::QgsProviderRegistry | ( | QString | pluginPath | ) | [private] |
ctor private since instance() creates it
Definition at line 60 of file qgsproviderregistry.cpp.
References cast_to_fptr, QgsMessageOutput::createMessageOutput(), fileVectorFilters(), mDatabaseDrivers, mDirectoryDrivers, QgsMessageOutput::MessageText, mLibraryDirectory, mProtocolDrivers, mProviders, mVectorFileFilters, QgsDebugMsg, QgsMessageOutput::setMessage(), QgsMessageOutput::setTitle(), and QgsMessageOutput::showMessage().
Referenced by instance().
QString QgsProviderRegistry::databaseDrivers | ( | ) | const [virtual] |
return a string containing the available database drivers
Definition at line 433 of file qgsproviderregistry.cpp.
References mDatabaseDrivers.
QString QgsProviderRegistry::directoryDrivers | ( | ) | const [virtual] |
return a string containing the available directory drivers
Definition at line 438 of file qgsproviderregistry.cpp.
References mDirectoryDrivers.
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.
It'd be nice to eventually be raster/vector neutral.
Definition at line 428 of file qgsproviderregistry.cpp.
References mVectorFileFilters.
Referenced by QgsProjectBadLayerGuiHandler::handleBadLayers(), and QgsProviderRegistry().
QgsDataProvider * QgsProviderRegistry::getProvider | ( | const QString & | providerKey, |
const QString & | dataSource | ||
) |
Create an instance of the provider.
Copied from QgsVectorLayer::setDataProvider TODO: Make it work in the generic environment.
providerKey | identificator of the provider |
dataSource | string containing data source for the provider |
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 332 of file qgsproviderregistry.cpp.
References cast_to_fptr, QgsDataProvider::isValid(), library(), QgsDataProvider::name(), QgsDebugMsg, and QgsLogger::warning().
Referenced by QgsVectorLayer::setDataProvider().
QgsProviderRegistry * QgsProviderRegistry::instance | ( | QString | pluginPath = QString::null | ) | [static] |
means of accessing canonical single instance
Definition at line 47 of file qgsproviderregistry.cpp.
References _instance, and QgsProviderRegistry().
Referenced by QgsApplication::exitQgis(), QgsProjectBadLayerGuiHandler::handleBadLayers(), QgsApplication::initQgis(), QgsRasterLayer::loadProviderLibrary(), and QgsVectorLayer::setDataProvider().
QString QgsProviderRegistry::library | ( | QString const & | providerKey | ) | const |
Return path for the library of the provider.
Definition at line 254 of file qgsproviderregistry.cpp.
References findMetadata_(), QgsProviderMetadata::library(), and mProviders.
Referenced by getProvider(), and QgsRasterLayer::loadProviderLibrary().
QDir const & QgsProviderRegistry::libraryDirectory | ( | ) | const |
return library directory where plugins are found
Definition at line 313 of file qgsproviderregistry.cpp.
References mLibraryDirectory.
QString QgsProviderRegistry::pluginList | ( | bool | asHtml = false | ) | const |
Return list of provider plugins found.
Definition at line 267 of file qgsproviderregistry.cpp.
References QgsProviderMetadata::description(), and mProviders.
QString QgsProviderRegistry::protocolDrivers | ( | ) | const [virtual] |
return a string containing the available protocol drivers
Definition at line 443 of file qgsproviderregistry.cpp.
References mProtocolDrivers.
QStringList QgsProviderRegistry::providerList | ( | ) | const |
Return list of available providers by their keys.
Definition at line 449 of file qgsproviderregistry.cpp.
References mProviders.
const QgsProviderMetadata * QgsProviderRegistry::providerMetadata | ( | const QString & | providerKey | ) | const |
Return metadata of the provider or NULL if not found.
Definition at line 460 of file qgsproviderregistry.cpp.
References findMetadata_(), and mProviders.
void QgsProviderRegistry::setLibraryDirectory | ( | QDir const & | path | ) |
Set library directory where to search for plugins.
Definition at line 307 of file qgsproviderregistry.cpp.
References mLibraryDirectory.
QgsProviderRegistry * QgsProviderRegistry::_instance = 0 [static, private] |
pointer to canonical Singleton object
Definition at line 135 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 157 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 163 of file qgsproviderregistry.h.
Referenced by directoryDrivers(), and QgsProviderRegistry().
QDir QgsProviderRegistry::mLibraryDirectory [private] |
directory in which provider plugins are installed
Definition at line 141 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 169 of file qgsproviderregistry.h.
Referenced by protocolDrivers(), and QgsProviderRegistry().
Providers QgsProviderRegistry::mProviders [private] |
associative container of provider metadata handles
Definition at line 138 of file qgsproviderregistry.h.
Referenced by library(), pluginList(), providerList(), providerMetadata(), 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 151 of file qgsproviderregistry.h.
Referenced by fileVectorFilters(), and QgsProviderRegistry().