Introduced preliminary support for asynchronous file read requests,
ReaderWriter::ReadResult now has a FILE_REQUEST enum. ReaderWriter::Options now has a s/getAsynchronousFileReadHint() parameter methods. libcurl based plugin now detects enabing of the AsynchronousFileReadHint, but as yet does not handle async requests - handling everything syncronously. DatabasePager now by default will enable AsynchronousFileReadHint for http based file requests
This commit is contained in:
@@ -90,17 +90,21 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
|
||||
Options():
|
||||
osg::Object(true),
|
||||
_objectCacheHint(CACHE_ARCHIVES) {}
|
||||
_objectCacheHint(CACHE_ARCHIVES),
|
||||
_asynchronousFileReadHint(false) {}
|
||||
|
||||
Options(const std::string& str):
|
||||
osg::Object(true),
|
||||
_str(str),
|
||||
_objectCacheHint(CACHE_ARCHIVES) {}
|
||||
_objectCacheHint(CACHE_ARCHIVES),
|
||||
_asynchronousFileReadHint(false) {}
|
||||
|
||||
Options(const Options& options,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||
osg::Object(options,copyop),
|
||||
_str(options._str),
|
||||
_databasePaths(options._databasePaths),
|
||||
_objectCacheHint(options._objectCacheHint) {}
|
||||
_objectCacheHint(options._objectCacheHint),
|
||||
_asynchronousFileReadHint(options._asynchronousFileReadHint) {}
|
||||
|
||||
META_Object(osgDB,Options);
|
||||
|
||||
@@ -119,12 +123,29 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
/** Get the const database path which is used a hint of where to look when loading models.*/
|
||||
const FilePathList& getDatabasePathList() const { return _databasePaths; }
|
||||
|
||||
|
||||
/** Set whether the Registry::ObjectCache should be used by default.*/
|
||||
void setObjectCacheHint(CacheHintOptions useObjectCache) { _objectCacheHint = useObjectCache; }
|
||||
|
||||
/** Get whether the Registry::ObjectCache should be used by default.*/
|
||||
CacheHintOptions getObjectCacheHint() const { return _objectCacheHint; }
|
||||
|
||||
|
||||
/** Set Asynchrnous file read hint.
|
||||
* This hint is used by plugins like the libcurl http reader plugin to inform them that
|
||||
* they should make an internal file read requests to their background threads to load files,
|
||||
* with the plugin returning immediately with a ReadResult::FILE_REQUESTED status. It is
|
||||
* assumed that calls will continue to be made to the plugin until the background threads
|
||||
* have read or failed to read the request file, at which point the return status which change
|
||||
* to FILE_LOADED and the objects will be returned.
|
||||
* Note, this facility is particular useful when using DatabasePager in conjunction with
|
||||
* internet based databases where file load latency is relatively high.*/
|
||||
void setAsynchronousFileReadHint(bool flag) { _asynchronousFileReadHint = flag; }
|
||||
|
||||
/** Get Asynchrnous file read hint. */
|
||||
bool getAsynchronousFileReadHint() const { return _asynchronousFileReadHint; }
|
||||
|
||||
|
||||
/** Sets a plugindata value PluginData with a string */
|
||||
void setPluginData(const std::string& s, void* v) const { _pluginData[s] = v; }
|
||||
|
||||
@@ -148,6 +169,7 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
std::string _str;
|
||||
FilePathList _databasePaths;
|
||||
CacheHintOptions _objectCacheHint;
|
||||
bool _asynchronousFileReadHint;
|
||||
|
||||
typedef std::map<std::string,void*> PluginDataMap;
|
||||
mutable PluginDataMap _pluginData;
|
||||
@@ -160,11 +182,12 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
|
||||
enum ReadStatus
|
||||
{
|
||||
FILE_NOT_HANDLED, //!< file is not appropriate for this file reader, due to some incompatibility, but *not* a read error
|
||||
FILE_NOT_FOUND, //!< file could not be found or could not be read
|
||||
FILE_LOADED, //!< file successfully found, loaded, and converted into osg
|
||||
FILE_LOADED_FROM_CACHE, //!< file found in cache and returned
|
||||
ERROR_IN_READING_FILE //!< file found, loaded, but an error was encountered during processing
|
||||
FILE_NOT_HANDLED, //!< File is not appropriate for this file reader, due to some incompatibility, but *not* a read error.
|
||||
FILE_NOT_FOUND, //!< File could not be found or could not be read.
|
||||
FILE_LOADED, //!< File successfully found, loaded, and converted into osg.
|
||||
FILE_LOADED_FROM_CACHE, //!< File found in cache and returned.
|
||||
ERROR_IN_READING_FILE, //!< File found, loaded, but an error was encountered during processing.
|
||||
FILE_REQUESTED, //!< Asyncronous file read has been requested, but returning immediatiely, keep polling plugin till file read has been completed.
|
||||
};
|
||||
|
||||
ReadResult(ReadStatus status=FILE_NOT_HANDLED):_status(status) {}
|
||||
|
||||
Reference in New Issue
Block a user