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

  • 相关阅读:
    Fiddler抓包测试App接口
    APP测试工具之TraceView卡顿检测
    APP弱网测试
    MAT内存问题分析定位
    Android DDMS检测内存泄露
    分库分表之终极设计方案
    反向代理和正向代理
    详解HTTP协议
    Django实现websocket完成实时通讯,聊天室,在线客服等
    分布式全文检索引擎之ElasticSearch
  • 原文地址:https://www.cnblogs.com/james1207/p/3257987.html
Copyright © 2020-2023  润新知