zoukankan      html  css  js  c++  java
  • Inside GDALAllRegister之四: 跳过driver

    这个函数很短小:

    /**
     * rief 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中注销掉。这提供了一个基于配置的解决方案,比起前面通过编译时添加宏多了一个选择。考虑的还是比较周到的。

  • 相关阅读:
    urllib2使用总结
    Scrapy简介
    python3使用多代理访问网站
    ISO9000 质量管理和质量保证系列国际标准
    怎样花两年时间去面试一个人
    Robot Framework 快速入门_中文版
    PMP项目经理认证
    Scrapy安装介绍
    批处理写的俄罗斯方块
    TL9000 电信业质量体系管理标准
  • 原文地址:https://www.cnblogs.com/james1207/p/3257987.html
Copyright © 2011-2022 走看看