Inside GDALAllRegister之四: 跳过driver

来源:互联网 发布:java io readline 编辑:程序博客网 时间:2024/06/14 01:15

这个函数很短小:

/** * \brief This method unload undesirable drivers. * * All drivers specified in the space delimited list in the GDAL_SKIP  * environmentvariable) will be deregistered and destroyed.  This method  * should normally be called after registration of standard drivers to allow  * the user a way of unloading undesired drivers.  The GDALAllRegister() * function already invokes AutoSkipDrivers() at the end, so if that functions * is called, it should not be necessary to call this method from application * code.  */void GDALDriverManager::AutoSkipDrivers(){    if( CPLGetConfigOption( "GDAL_SKIP", NULL ) == NULL )        return;    char **papszList = CSLTokenizeString( CPLGetConfigOption("GDAL_SKIP","") );    for( int i = 0; i < CSLCount(papszList); i++ )    {        GDALDriver *poDriver = GetDriverByName( papszList[i] );        if( poDriver == NULL )            CPLError( CE_Warning, CPLE_AppDefined,                       "Unable to find driver %s to unload from GDAL_SKIP environment variable.",                       papszList[i] );        else        {            CPLDebug( "GDAL", "AutoSkipDriver(%s)", papszList[i] );            DeregisterDriver( poDriver );            delete poDriver;        }    }    CSLDestroy( papszList );}

如果在环境变量GDAL_SKIP中指定某些driver,可以在运行时将该driver从GDALDriverManger中注销掉。这提供了一个基于配置的解决方案,比起前面通过编译时添加宏多了一个选择。考虑的还是比较周到的。


原创粉丝点击