本文整理汇总了C++中CacheBin::setMetadata方法的典型用法代码示例。如果您正苦于以下问题:C++ CacheBin::setMetadata方法的具体用法?C++ CacheBin::setMetadata怎么用?C++ CacheBin::setMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheBin
的用法示例。
在下文中一共展示了CacheBin::setMetadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
CacheBin*
TerrainLayer::getCacheBin(const Profile* profile)
{
if ( !_openCalled )
{
OE_WARN << LC << "Illegal- called getCacheBin() before layer is open.. did you call open()?\n";
return 0L;
}
CacheSettings* cacheSettings = getCacheSettings();
if (!cacheSettings)
return 0L;
if (cacheSettings->cachePolicy()->isCacheDisabled())
return 0L;
CacheBin* bin = cacheSettings->getCacheBin();
if (!bin)
return 0L;
// does the metadata need initializing?
std::string metaKey = getMetadataKey(profile);
Threading::ScopedMutexLock lock(_mutex);
CacheBinMetadataMap::iterator i = _cacheBinMetadata.find(metaKey);
if (i == _cacheBinMetadata.end())
{
//std::string cacheId = _runtimeOptions->cacheId().get();
// read the metadata record from the cache bin:
ReadResult rr = bin->readString(metaKey, _readOptions.get());
osg::ref_ptr<CacheBinMetadata> meta;
bool metadataOK = false;
if (rr.succeeded())
{
// Try to parse the metadata record:
Config conf;
conf.fromJSON(rr.getString());
meta = new CacheBinMetadata(conf);
if (meta->isOK())
{
metadataOK = true;
// verify that the cache if compatible with the open tile source:
if ( getTileSource() && getProfile() )
{
//todo: check the profile too
if ( meta->_sourceDriver.get() != getTileSource()->getOptions().getDriver() )
{
OE_WARN << LC
<< "Layer \"" << getName() << "\" is requesting a \""
<< getTileSource()->getOptions().getDriver() << "\" cache, but a \""
<< meta->_sourceDriver.get() << "\" cache exists at the specified location. "
<< "The cache will ignored for this layer.\n";
cacheSettings->cachePolicy() = CachePolicy::NO_CACHE;
return 0L;
}
}
// if not, see if we're in cache-only mode and still need a profile:
else if (cacheSettings->cachePolicy()->isCacheOnly() && !_profile.valid())
{
// in cacheonly mode, create a profile from the first cache bin accessed
// (they SHOULD all be the same...)
setProfile( Profile::create(meta->_sourceProfile.get()) );
_tileSize = meta->_sourceTileSize.get();
}
bin->setMetadata(meta.get());
}
else
{
OE_WARN << LC << "Metadata appears to be corrupt.\n";
}
}
if (!metadataOK)
{
// cache metadata does not exist, so try to create it.
if ( getProfile() )
{
meta = new CacheBinMetadata();
// no existing metadata; create some.
meta->_cacheBinId = _runtimeCacheId;
meta->_sourceName = this->getName();
meta->_sourceTileSize = getTileSize();
meta->_sourceProfile = getProfile()->toProfileOptions();
meta->_cacheProfile = profile->toProfileOptions();
meta->_cacheCreateTime = DateTime().asTimeStamp();
meta->_dataExtents = getDataExtents();
if (getTileSource())
{
meta->_sourceDriver = getTileSource()->getOptions().getDriver();
//.........这里部分代码省略.........