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


C++ CacheBin::getID方法代码示例

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


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

示例1: getStatus


//.........这里部分代码省略.........
            hashConf.remove("cache_policy");
            hashConf.remove("visible");
            hashConf.remove("l2_cache_size");

            OE_DEBUG << "hashConfFinal = " << hashConf.toJSON(true) << std::endl;

            unsigned hash = osgEarth::hashString(hashConf.toJSON());
            _runtimeCacheId = Stringify() << std::hex << std::setw(8) << std::setfill('0') << hash;
        }

        // Now that we know the cache ID, establish the cache settings for this Layer.
        // Start by cloning whatever CacheSettings were inherited in the read options
        // (typically from the Map).
        CacheSettings* oldSettings = CacheSettings::get(_readOptions.get());
        _cacheSettings = oldSettings ? new CacheSettings(*oldSettings) : new CacheSettings();

        // Integrate a cache policy from this Layer's options:
        _cacheSettings->integrateCachePolicy(options().cachePolicy());

        // If you created the layer with a pre-created tile source, it will already by set.
        if (!_tileSource.valid())
        {
            osg::ref_ptr<TileSource> ts;

            // as long as we're not in cache-only mode, try to create the TileSource.
            if (_cacheSettings->cachePolicy()->isCacheOnly())
            {
                OE_INFO << LC << "Opening in cache-only mode\n";
            }
            else if (isTileSourceExpected())
            {
                // Initialize the tile source once and only once.
                ts = createAndOpenTileSource();
            }

            // If we loaded a tile source, give it some information about caching
            // if appropriate.
            if (ts.valid())
            {
                if (_cacheSettings->isCacheEnabled())
                {
                    // read the cache policy hint from the tile source unless user expressly set 
                    // a policy in the initialization options. In other words, the hint takes
                    // ultimate priority (even over the Registry override) unless expressly
                    // overridden in the layer options!
                    refreshTileSourceCachePolicyHint( ts.get() );

                    // Unless the user has already configured an expiration policy, use the "last modified"
                    // timestamp of the TileSource to set a minimum valid cache entry timestamp.
                    const CachePolicy& cp = options().cachePolicy().get();

                    if ( !cp.minTime().isSet() && !cp.maxAge().isSet() && ts->getLastModifiedTime() > 0)
                    {
                        // The "effective" policy overrides the runtime policy, but it does not get serialized.
                        _cacheSettings->cachePolicy()->mergeAndOverride( cp );
                        _cacheSettings->cachePolicy()->minTime() = ts->getLastModifiedTime();
                        OE_INFO << LC << "driver says min valid timestamp = " << DateTime(*cp.minTime()).asRFC1123() << "\n";
                    }
                }

                // All is well - set the tile source.
                if ( !_tileSource.valid() )
                {
                    _tileSource = ts.release();
                }
            }
        }
        else
        {
            // User supplied the tile source, so attempt to get its profile:
            setProfile(_tileSource->getProfile() );
            if (!_profile.valid())
            {
                setStatus( Status::Error(getName(), "Cannot establish profile") );
            }
        }

        // Finally, open and activate a caching bin for this layer.
        if (_cacheSettings->isCacheEnabled())
        {
            CacheBin* bin = _cacheSettings->getCache()->addBin(_runtimeCacheId);
            if (bin)
            {
                _cacheSettings->setCacheBin(bin);
                OE_INFO << LC << "Cache bin is [" << bin->getID() << "]\n";
            }
        }

        // Store the updated settings in the read options so we can propagate 
        // them as necessary.
        _cacheSettings->store(_readOptions.get());
        OE_INFO << LC << _cacheSettings->toString() << "\n";

        // Done!
        _openCalled = true;
                        
    }

    return getStatus();
}
开发者ID:caishanli,项目名称:osgearth,代码行数:101,代码来源:TerrainLayer.cpp


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