Added checks against Options to osga plugin to ensure archives are only cached

when requested, cleaned up the Registry::openArchiveImplementation function.
This commit is contained in:
Robert Osfield
2007-05-10 08:20:33 +00:00
parent 1d5f76c55d
commit c7b9a07758
2 changed files with 20 additions and 22 deletions

View File

@@ -1537,25 +1537,19 @@ ReaderWriter::ReadResult Registry::readImplementation(const ReadFunctor& readFun
ReaderWriter::ReadResult Registry::openArchiveImplementation(const std::string& fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const ReaderWriter::Options* options)
{
osgDB::Archive* archive = getFromArchiveCache(fileName);
if (archive) return archive;
ReaderWriter::ReadResult result = readImplementation(ReadArchiveFunctor(fileName, status, indexBlockSizeHint, options),false);
// default to using chaching archive if no options structure provided, but if options are provided use archives
// only if supplied.
if (!options || (options && (options->getObjectCacheHint() & ReaderWriter::Options::CACHE_ARCHIVES)))
if (result.validArchive() &&
(!options || (options->getObjectCacheHint() & ReaderWriter::Options::CACHE_ARCHIVES)) )
{
osgDB::Archive* archive = getFromArchiveCache(fileName);
if (archive) return archive;
ReaderWriter::ReadResult result = readImplementation(ReadArchiveFunctor(fileName, status, indexBlockSizeHint, options),false);
if (result.validArchive())
{
addToArchiveCache(fileName,result.getArchive());
}
return result;
}
else
{
return readImplementation(ReadArchiveFunctor(fileName, status, indexBlockSizeHint, _options.get()),false);
addToArchiveCache(fileName,result.getArchive());
}
return result;
}