osgEarth的Rex引擎原理分析(二)osg是如何根据文件扩展名寻找需要加载的动态链接库插件的

在(一)中有createLibraryNameForFile,它会根据文件扩展名构造需要加载的动态链接库

osgDB/Registry.cpp 

ReaderWriter::ReadResult Registry::read(const ReadFunctor& readFunctor){
    ...
    std::string libraryName = createLibraryNameForFile(readFunctor._filename);
    if (loadLibrary(libraryName)!=NOT_LOADED)
    {
        for(;itr.valid();++itr)
        {
            ReaderWriter::ReadResult rr = readFunctor.doRead(*itr);
            if (readFunctor.isValid(rr)) return rr;
            else results.push_back(rr);
        }
    }
    ...
}

createLibraryNameForFile调用createLibraryNameForExtension,最终得到要加载的动态链接库的路径和名称

osgDB/Registry.cpp

std::string Registry::createLibraryNameForExtension(const std::string& ext)
{
    std::string lowercase_ext;
    for(std::string::const_iterator sitr=ext.begin();
        sitr!=ext.end();
        ++sitr)
    {
        lowercase_ext.push_back(tolower(*sitr));
    }

    ExtensionAliasMap::iterator itr=_extAliasMap.find(lowercase_ext);
    if (itr!=_extAliasMap.end() && ext != itr->second) return createLibraryNameForExtension(itr->second);

    std::string prepend = std::string("osgPlugins-")+std::string(osgGetVersion())+std::string("/");

#if defined(__CYGWIN__)
    return prepend+"cygwin_"+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
#elif defined(__MINGW32__)
    return prepend+"mingw_"+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
#elif defined(WIN32)
    return prepend+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+".dll";
#elif macintosh
    return prepend+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES;
#else
    return prepend+"osgdb_"+lowercase_ext+OSG_LIBRARY_POSTFIX_WITH_QUOTES+ADDQUOTES(OSG_PLUGIN_EXTENSION);
#endif

}

 

待继续分析列表:

1、osg是如何根据文件扩展名寻找需要加载的动态链接库插件的((一)中问题)

2、加载动态库插件的过程是什么((一)中问题)

3、osgDB::Registry的作用是什么((一)中问题)

4、.earth文件如何解析成Config((一)中问题)

5、地图map图层的构建过程((一)中问题)

6、地图节点MapNode的构建过程((一)中问题)

你可能感兴趣的:(osg,osgearth,rex,地理信息引擎)