当前位置: 首页>>代码示例>>C++>>正文


C++ Importer::getFileAffinity方法代码示例

本文整理汇总了C++中Importer::getFileAffinity方法的典型用法代码示例。如果您正苦于以下问题:C++ Importer::getFileAffinity方法的具体用法?C++ Importer::getFileAffinity怎么用?C++ Importer::getFileAffinity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Importer的用法示例。


在下文中一共展示了Importer::getFileAffinity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findImporter

Importer* AutoImporter::findImporter(const string& filename)
{
    map<string, pair<string, unsigned char> >::iterator fileIter = mFilenames.find(filename);
    if (fileIter != mFilenames.end())
    {
        map<string, PlugIn*>::iterator plugInIter = mPlugIns.find(fileIter->second.first);
        if (plugInIter != mPlugIns.end())
        {
            mpPlugIn = plugInIter->second;
            return dynamic_cast<Importer*>(mpPlugIn);
        }
    }

    mpPlugIn = NULL;

    if (filename.empty() == true)
    {
        return NULL;
    }

    // Create the list of importers to search
    vector<PlugInDescriptor*> importers = mpPlugInManager->getPlugInDescriptors(PlugInManagerServices::ImporterType());

    //remove self from list of importers
    vector<PlugInDescriptor*>::iterator newEnd =
        remove_if(importers.begin(), importers.end(), FindDescriptor(getName()));
    importers.erase(newEnd, importers.end());

    // Check importers first based on file extension
    list<PlugInDescriptor*> remainingImporters;
    PlugIn* pPlugIn = NULL;
    unsigned char maxFileAffinity = Importer::CAN_NOT_LOAD;

    for (vector<PlugInDescriptor*>::iterator iter = importers.begin(); iter != importers.end(); ++iter)
    {
        PlugInDescriptor* pDescriptor = *iter;
        if (pDescriptor == NULL)
        {
            continue;
        }

        if (checkExtension(pDescriptor, filename))
        {
            PlugIn* pCurrentPlugIn = NULL;
            const string& plugInName = pDescriptor->getName();

            map<string, PlugIn*>::iterator plugInIter = mPlugIns.find(plugInName);
            if (plugInIter != mPlugIns.end())
            {
                pCurrentPlugIn = plugInIter->second;
            }
            else
            {
                PlugInResource pImporterRes(plugInName);
                pCurrentPlugIn = pImporterRes.release();
                if (pCurrentPlugIn != NULL)
                {
                    mPlugIns[plugInName] = pCurrentPlugIn;
                }
            }

            Importer* pImporter = dynamic_cast<Importer*>(pCurrentPlugIn);
            if (pImporter != NULL)
            {
                unsigned char fileAffinity = pImporter->getFileAffinity(filename);
                if (fileAffinity > maxFileAffinity)
                {
                    maxFileAffinity = fileAffinity;
                    pPlugIn = pCurrentPlugIn;
                }
            }
        }
        else
        {
            remainingImporters.push_back(pDescriptor);
        }
    }

    if ((pPlugIn != NULL) && (maxFileAffinity >= Importer::CAN_LOAD))
    {
        mpPlugIn = pPlugIn;
        mFilenames[filename] = make_pair(mpPlugIn->getName(), maxFileAffinity);
        return dynamic_cast<Importer*>(mpPlugIn);
    }

    // Check the remaining importers
    for (list<PlugInDescriptor*>::iterator iter = remainingImporters.begin(); iter != remainingImporters.end(); ++iter)
    {
        PlugInDescriptor* pDescriptor = *iter;
        if (pDescriptor == NULL)
        {
            continue;
        }

        PlugIn* pCurrentPlugIn = NULL;
        const string& plugInName = pDescriptor->getName();

        map<string, PlugIn*>::iterator plugInIter = mPlugIns.find(plugInName);
        if (plugInIter != mPlugIns.end())
        {
//.........这里部分代码省略.........
开发者ID:jonatho7,项目名称:opticks,代码行数:101,代码来源:AutoImporter.cpp


注:本文中的Importer::getFileAffinity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。