OGRSFDriverRegistrar Class Reference

#include <ogrsf_frmts.h>

List of all members.

Public Member Functions

void RegisterDriver (OGRSFDriver *poDriver)
 Add a driver to the list of registered drivers.
int GetDriverCount (void)
 Fetch the number of registered drivers.
OGRSFDriverGetDriver (int iDriver)
 Fetch the indicated driver.
OGRSFDriverGetDriverByName (const char *)
 Fetch the indicated driver.
int GetOpenDSCount ()
 Return the number of opened datasources.
OGRDataSourceGetOpenDS (int)
 Return the iDS th datasource opened.
void AutoLoadDrivers ()
 Auto-load GDAL drivers from shared libraries.

Static Public Member Functions

static OGRSFDriverRegistrarGetRegistrar ()
 Return the driver manager, creating one if none exist.
static OGRDataSourceOpen (const char *pszName, int bUpdate=FALSE, OGRSFDriver **ppoDriver=NULL)
 Open a file / data source with one of the registered drivers.


Detailed Description

Singleton manager for OGRSFDriver instances that will be used to try and open datasources. Normally the registrar is populated with standard drivers using the OGRRegisterAll() function and does not need to be directly accessed. The driver registrar and all registered drivers may be cleaned up on shutdown using OGRCleanupAll().

Member Function Documentation

void OGRSFDriverRegistrar::AutoLoadDrivers (  ) 

Auto-load GDAL drivers from shared libraries.

This function will automatically load drivers from shared libraries. It searches the "driver path" for .so (or .dll) files that start with the prefix "ogr_X.so". It then tries to load them and then tries to call a function within them called RegisterOGRX() where the 'X' is the same as the remainder of the shared library basename, or failing that to call GDALRegisterMe().

There are a few rules for the driver path. If the GDAL_DRIVER_PATH environment variable it set, it is taken to be a list of directories to search separated by colons on unix, or semi-colons on Windows.

If that is not set the following defaults are used:

  • Linux/Unix: <prefix>/lib/gdalplugins is searched or /usr/local/lib/gdalplugins if the install prefix is not known.
  • MacOSX: <prefix>/PlugIns is searched, or /usr/local/lib/gdalplugins if the install prefix is not known. Also, the framework directory /Library/Application Support/GDAL/PlugIns is searched.
  • Win32: <prefix>/lib/gdalplugins if the prefix is known (normally it is not), otherwise the gdalplugins subdirectory of the directory containing the currently running executable is used.

References CPLFormFilename(), CPLGetBasename(), CPLGetDirname(), CPLGetExecPath(), CPLGetExtension(), and CPLGetSymbol().

Referenced by OGRRegisterAll().

OGRSFDriver * OGRSFDriverRegistrar::GetDriver ( int  iDriver  ) 

Fetch the indicated driver.

This method is the same as the C function OGRGetDriver().

Parameters:
iDriver the driver index, from 0 to GetDriverCount()-1.
Returns:
the driver, or NULL if iDriver is out of range.

Referenced by OGRGetDriver().

OGRSFDriver * OGRSFDriverRegistrar::GetDriverByName ( const char *  pszName  ) 

Fetch the indicated driver.

This method is the same as the C function OGRGetDriverByName

Parameters:
pszName the driver name
Returns:
the driver, or NULL if no driver with that name is found

Referenced by OGRGetDriverByName().

int OGRSFDriverRegistrar::GetDriverCount ( void   ) 

Fetch the number of registered drivers.

This method is the same as the C function OGRGetDriverCount().

Returns:
the drivers count.

Referenced by OGRGetDriverCount().

OGRDataSource * OGRSFDriverRegistrar::GetOpenDS ( int  iDS  ) 

Return the iDS th datasource opened.

This method is the same as the C function OGRGetOpenDS().

Parameters:
iDS the index of the dataset to return (between 0 and GetOpenDSCount() - 1)

Referenced by OGRGetOpenDS().

int OGRSFDriverRegistrar::GetOpenDSCount (  )  [inline]

Return the number of opened datasources.

This method is the same as the C function OGRGetOpenDSCount()

Returns:
the number of opened datasources.

Referenced by OGRGetOpenDSCount().

OGRSFDriverRegistrar * OGRSFDriverRegistrar::GetRegistrar (  )  [static]

Return the driver manager, creating one if none exist.

Fetch registrar.

Returns:
the driver manager.
This static method should be used to fetch the singleton registrar. It will create a registrar if there is not already one in existance.

Returns:
the current driver registrar.

Referenced by OGRDataSource::ExecuteSQL(), OGRGetDriverByName(), OGRGetOpenDS(), OGRGetOpenDSCount(), OGRRegisterAll(), OGRRegisterDriver(), OGRReleaseDataSource(), Open(), and OGRDataSource::Release().

OGRDataSource * OGRSFDriverRegistrar::Open ( const char *  pszName,
int  bUpdate = FALSE,
OGRSFDriver **  ppoDriver = NULL 
) [static]

Open a file / data source with one of the registered drivers.

This method loops through all the drivers registered with the driver manager trying each until one succeeds with the given data source. This method is static. Applications don't normally need to use any other OGRSFDriverRegistrar methods directly, nor do they normally need to have a pointer to an OGRSFDriverRegistrar instance.

If this method fails, CPLGetLastErrorMsg() can be used to check if there is an error message explaining why.

This method is the same as the C function OGROpen().

Parameters:
pszName the name of the file, or data source to open.
bUpdate FALSE for read-only access (the default) or TRUE for read-write access.
ppoDriver if non-NULL, this argument will be updated with a pointer to the driver which was used to open the data source.
Returns:
NULL on error or if the pass name is not supported by this driver, otherwise a pointer to an OGRDataSource. This OGRDataSource should be closed by deleting the object when it is no longer needed.
Example:

    OGRDataSource	*poDS;

    poDS = OGRSFDriverRegistrar::Open( "polygon.shp" );
    if( poDS == NULL )
    {
        return;
    }

    ... use the data source ...

    OGRDataSource::DestroyDataSource(poDS);
  

References OGRDataSource::GetDriver(), OGRSFDriver::GetName(), GetRegistrar(), OGRDataSource::m_poDriver, nDrivers, OGRSFDriver::Open(), papoDrivers, and OGRDataSource::Reference().

Referenced by OGROpen().

void OGRSFDriverRegistrar::RegisterDriver ( OGRSFDriver poDriver  ) 

Add a driver to the list of registered drivers.

If the passed driver is already registered (based on pointer comparison) then the driver isn't registered. New drivers are added at the end of the list of registered drivers.

This method is the same as the C function OGRRegisterDriver().

Parameters:
poDriver the driver to add.

References OGRSFDriver::GetName().

Referenced by OGRRegisterDriver().


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

Generated for GDAL by doxygen 1.5.7.1.