Added osg::ref_ptr<osgDB::Archive> osgDB::Registry::getRefFromArchiveCache() and osg::ref_ptr<osgDB::Object> osgDB::Registry::getRefFromObjectCache().
This commit is contained in:
parent
7f14e7dac9
commit
b4b88e9549
@ -438,17 +438,23 @@ class OSGDB_EXPORT Registry : public osg::Referenced
|
||||
/** Add a filename,object,timestamp triple to the Registry::ObjectCache.*/
|
||||
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0);
|
||||
|
||||
/** Get an object from the object cache*/
|
||||
/** Get an Object from the object cache*/
|
||||
osg::Object* getFromObjectCache(const std::string& fileName);
|
||||
|
||||
/** Get an ref_ptr<Object> from the object cache*/
|
||||
osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName);
|
||||
|
||||
/** Add archive to archive cache so that future calls reference this archive.*/
|
||||
void addToArchiveCache(const std::string& fileName, osgDB::Archive* archive);
|
||||
|
||||
/** Remove archive from cache.*/
|
||||
/** Remove Archive from cache.*/
|
||||
void removeFromArchiveCache(const std::string& fileName);
|
||||
|
||||
/** Get an archive from the archive cache*/
|
||||
/** Get an Archive from the archive cache.*/
|
||||
osgDB::Archive* getFromArchiveCache(const std::string& fileName);
|
||||
|
||||
/** Get an ref_ptr<Archive> from the archive cache.*/
|
||||
osg::ref_ptr<osgDB::Archive> getRefFromArchiveCache(const std::string& fileName);
|
||||
|
||||
/** Remove all archives from the archive cache.*/
|
||||
void clearArchiveCache();
|
||||
|
@ -1228,8 +1228,8 @@ ReaderWriter::ReadResult Registry::readImplementation(const ReadFunctor& readFun
|
||||
|
||||
ReaderWriter::ReadResult Registry::openArchiveImplementation(const std::string& fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options* options)
|
||||
{
|
||||
osgDB::Archive* archive = getFromArchiveCache(fileName);
|
||||
if (archive) return archive;
|
||||
osg::ref_ptr<osgDB::Archive> archive = getRefFromArchiveCache(fileName);
|
||||
if (archive.valid()) return archive.get();
|
||||
|
||||
ReaderWriter::ReadResult result = readImplementation(ReadArchiveFunctor(fileName, status, indexBlockSizeHint, options),Options::CACHE_ARCHIVES);
|
||||
|
||||
@ -1526,6 +1526,7 @@ void Registry::addEntryToObjectCache(const std::string& filename, osg::Object* o
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
_objectCache[filename]=ObjectTimeStampPair(object,timestamp);
|
||||
}
|
||||
|
||||
osg::Object* Registry::getFromObjectCache(const std::string& fileName)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
@ -1534,6 +1535,14 @@ osg::Object* Registry::getFromObjectCache(const std::string& fileName)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Object> Registry::getRefFromObjectCache(const std::string& fileName)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
ObjectCache::iterator itr = _objectCache.find(fileName);
|
||||
if (itr!=_objectCache.end()) return itr->second.first;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void Registry::updateTimeStampOfObjectsInCacheWithExternalReferences(const osg::FrameStamp& frameStamp)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||
@ -1616,6 +1625,14 @@ osgDB::Archive* Registry::getFromArchiveCache(const std::string& fileName)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osgDB::Archive> Registry::getRefFromArchiveCache(const std::string& fileName)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_archiveCacheMutex);
|
||||
ArchiveCache::iterator itr = _archiveCache.find(fileName);
|
||||
if (itr!=_archiveCache.end()) return itr->second;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void Registry::clearArchiveCache()
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_archiveCacheMutex);
|
||||
|
Loading…
Reference in New Issue
Block a user