[gdal-dev] How to re-register a driver

Even Rouault even.rouault at mines-paris.org
Fri Mar 8 23:12:48 PST 2013


Le samedi 09 mars 2013 02:20:55, Allen Kempe a écrit :
> In my application, I would like to be able to programatically specify
> which driver to use when opening a GDALDataset when more than one driver
> can process the file. To do this, I have deregistered the drivers that I
> don't want to use. The GetGDALDriverManager-::DeregisterDriver()
> function does the trick.
> 
> The problem I have is being able to reregister the drivers that I
> deregistered above. First of all, in order to register a driver, you
> need a handle to it. It would seem that GetDriverByName should do the
> trick but it returns NULL if the driver was previously deregistered.
> Looking at the GDALDriverrManager code, it is easy to see why this is as
> GDALDriver manager only searches the currently enabled drivers to get
> its handle.
> 
> I then thought that calling GDALDriverManager::AutoloadDrivers() would
> reinitialise the driver list but it does not return the driver that has
> been deregistered.  It would seem that GDALRegisterDriver would work but
> it requires a handle to the driver which as I stated above, cannot be
> obtained once a driver has been deregistered.
> 
> So, how does one get a handle to a deregistered driver or alternatively,
> how can GDALDriverManager::AutoloadDrivers be made to reconstruct the
> driver list with all the currently configured drivers?
> 
> It seems that GDALDriverManager::RegisterDriver is a useless function
> since there is no way to get a handle to a previously deregistered driver.

Keep the handle of the driver that your deregister in some map, list, etc... 
and reuse it wen you want to reregister the driver.

Or call again GDALAllRegister() that wil register again all drivers.

Or call GDALRegister_XXXX().


More information about the gdal-dev mailing list