Added support for osgDB::ReaderWriter::ReadResult::FILE_LOADED_FROM_CACHE
This commit is contained in:
@@ -63,12 +63,13 @@ class OSGDB_EXPORT ReaderWriter : public osg::Referenced
|
||||
FILE_NOT_HANDLED,
|
||||
FILE_NOT_FOUND,
|
||||
FILE_LOADED,
|
||||
FILE_LOADED_FROM_CACHE,
|
||||
ERROR_IN_READING_FILE
|
||||
};
|
||||
|
||||
ReadResult(ReadStatus status=FILE_NOT_HANDLED):_status(status) {}
|
||||
ReadResult(const std::string& m):_status(ERROR_IN_READING_FILE),_message(m) {}
|
||||
ReadResult(osg::Object* obj):_status(FILE_LOADED),_object(obj) {}
|
||||
ReadResult(osg::Object* obj, ReadStatus status=FILE_LOADED):_status(status),_object(obj) {}
|
||||
|
||||
ReadResult(const ReadResult& rr):_status(rr._status),_message(rr._message),_object(rr._object) {}
|
||||
ReadResult& operator = (const ReadResult& rr) { if (this==&rr) return *this; _status=rr._status; _message=rr._message;_object=rr._object; return *this; }
|
||||
@@ -91,7 +92,8 @@ class OSGDB_EXPORT ReaderWriter : public osg::Referenced
|
||||
const std::string& message() const { return _message; }
|
||||
|
||||
ReadStatus status() const { return _status; }
|
||||
bool success() const { return _status==FILE_LOADED; }
|
||||
bool success() const { return _status==FILE_LOADED || _status==FILE_LOADED_FROM_CACHE ; }
|
||||
bool loadedFromCache() const { return _status==FILE_LOADED_FROM_CACHE; }
|
||||
bool error() const { return _status==ERROR_IN_READING_FILE; }
|
||||
bool notHandled() const { return _status==FILE_NOT_HANDLED; }
|
||||
bool notFound() const { return _status==FILE_NOT_FOUND; }
|
||||
|
||||
@@ -1256,7 +1256,7 @@ ReaderWriter::ReadResult Registry::readObjectImplementation(const std::string& c
|
||||
{
|
||||
notify(INFO)<<"returning cached instanced of "<<file<<std::endl;
|
||||
osg::Object* object = oitr->second.first.get();
|
||||
if (object) return object;
|
||||
if (object) return ReaderWriter::ReadResult(object, ReaderWriter::ReadResult::FILE_LOADED_FROM_CACHE);
|
||||
else return ReaderWriter::ReadResult("Error file does not contain an osg::Object");
|
||||
}
|
||||
|
||||
@@ -1402,7 +1402,7 @@ ReaderWriter::ReadResult Registry::readImageImplementation(const std::string& fi
|
||||
{
|
||||
notify(INFO)<< "returning cached instanced of "<<file<<std::endl;
|
||||
osg::Image* image = dynamic_cast<osg::Image*>(oitr->second.first.get());
|
||||
if (image) return image;
|
||||
if (image) return ReaderWriter::ReadResult(image, ReaderWriter::ReadResult::FILE_LOADED_FROM_CACHE);
|
||||
else return ReaderWriter::ReadResult("Error file not of type osg::Image");
|
||||
}
|
||||
|
||||
@@ -1551,8 +1551,8 @@ ReaderWriter::ReadResult Registry::readHeightFieldImplementation(const std::stri
|
||||
if (oitr!=_objectCache.end())
|
||||
{
|
||||
notify(INFO)<< "returning cached instanced of "<<file<<std::endl;
|
||||
osg::HeightField* HeightField = dynamic_cast<osg::HeightField*>(oitr->second.first.get());
|
||||
if (HeightField) return HeightField;
|
||||
osg::HeightField* heightField = dynamic_cast<osg::HeightField*>(oitr->second.first.get());
|
||||
if (heightField) return ReaderWriter::ReadResult(heightField, ReaderWriter::ReadResult::FILE_LOADED_FROM_CACHE);
|
||||
else return ReaderWriter::ReadResult("Error file not of type osg::HeightField");
|
||||
}
|
||||
|
||||
@@ -1714,7 +1714,7 @@ ReaderWriter::ReadResult Registry::readNodeImplementation(const std::string& fil
|
||||
{
|
||||
notify(INFO)<< "returning cached instanced of "<<file<<std::endl;
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(oitr->second.first.get());
|
||||
if (node) return node;
|
||||
if (node) return ReaderWriter::ReadResult(node, ReaderWriter::ReadResult::FILE_LOADED_FROM_CACHE);
|
||||
else return ReaderWriter::ReadResult("Error file not of type osg::Node");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user