Changeset 8322
- Timestamp:
- 05/14/08 19:03:57
- Files:
-
- OpenSceneGraph/trunk/include/osgDB/ReaderWriter (modified) (6 diffs)
- OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp (modified) (2 diffs)
- OpenSceneGraph/trunk/src/osgPlugins/curl/ReaderWriterCURL.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OpenSceneGraph/trunk/include/osgDB/ReaderWriter
r8278 r8322 91 91 Options(): 92 92 osg::Object(true), 93 _objectCacheHint(CACHE_ARCHIVES) {} 93 _objectCacheHint(CACHE_ARCHIVES), 94 _asynchronousFileReadHint(false) {} 95 94 96 Options(const std::string& str): 95 97 osg::Object(true), 96 98 _str(str), 97 _objectCacheHint(CACHE_ARCHIVES) {} 99 _objectCacheHint(CACHE_ARCHIVES), 100 _asynchronousFileReadHint(false) {} 98 101 99 102 Options(const Options& options,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): … … 101 104 _str(options._str), 102 105 _databasePaths(options._databasePaths), 103 _objectCacheHint(options._objectCacheHint) {} 106 _objectCacheHint(options._objectCacheHint), 107 _asynchronousFileReadHint(options._asynchronousFileReadHint) {} 104 108 105 109 META_Object(osgDB,Options); … … 120 124 const FilePathList& getDatabasePathList() const { return _databasePaths; } 121 125 126 122 127 /** Set whether the Registry::ObjectCache should be used by default.*/ 123 128 void setObjectCacheHint(CacheHintOptions useObjectCache) { _objectCacheHint = useObjectCache; } … … 125 130 /** Get whether the Registry::ObjectCache should be used by default.*/ 126 131 CacheHintOptions getObjectCacheHint() const { return _objectCacheHint; } 132 133 134 /** Set Asynchrnous file read hint. 135 * This hint is used by plugins like the libcurl http reader plugin to inform them that 136 * they should make an internal file read requests to their background threads to load files, 137 * with the plugin returning immediately with a ReadResult::FILE_REQUESTED status. It is 138 * assumed that calls will continue to be made to the plugin until the background threads 139 * have read or failed to read the request file, at which point the return status which change 140 * to FILE_LOADED and the objects will be returned. 141 * Note, this facility is particular useful when using DatabasePager in conjunction with 142 * internet based databases where file load latency is relatively high.*/ 143 void setAsynchronousFileReadHint(bool flag) { _asynchronousFileReadHint = flag; } 144 145 /** Get Asynchrnous file read hint. */ 146 bool getAsynchronousFileReadHint() const { return _asynchronousFileReadHint; } 147 127 148 128 149 /** Sets a plugindata value PluginData with a string */ … … 149 170 FilePathList _databasePaths; 150 171 CacheHintOptions _objectCacheHint; 172 bool _asynchronousFileReadHint; 151 173 152 174 typedef std::map<std::string,void*> PluginDataMap; … … 161 183 enum ReadStatus 162 184 { 163 FILE_NOT_HANDLED, //!< file is not appropriate for this file reader, due to some incompatibility, but *not* a read error 164 FILE_NOT_FOUND, //!< file could not be found or could not be read 165 FILE_LOADED, //!< file successfully found, loaded, and converted into osg 166 FILE_LOADED_FROM_CACHE, //!< file found in cache and returned 167 ERROR_IN_READING_FILE //!< file found, loaded, but an error was encountered during processing 185 FILE_NOT_HANDLED, //!< File is not appropriate for this file reader, due to some incompatibility, but *not* a read error. 186 FILE_NOT_FOUND, //!< File could not be found or could not be read. 187 FILE_LOADED, //!< File successfully found, loaded, and converted into osg. 188 FILE_LOADED_FROM_CACHE, //!< File found in cache and returned. 189 ERROR_IN_READING_FILE, //!< File found, loaded, but an error was encountered during processing. 190 FILE_REQUESTED, //!< Asyncronous file read has been requested, but returning immediatiely, keep polling plugin till file read has been completed. 168 191 }; 169 192 OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp
r8007 r8322 1 1 #include <osgDB/DatabasePager> 2 2 #include <osgDB/ReadFile> 3 #include <osgDB/FileNameUtils> 3 4 4 5 #include <osg/Geode> … … 420 421 databaseRequest->_priorityLastRequest = priority; 421 422 databaseRequest->_groupForAddingLoadedSubgraph = group; 422 databaseRequest->_loadOptions = loadOptions; 423 424 if ((Registry::instance()->getOptions()==loadOptions) && 425 (loadOptions ? !loadOptions->getAsynchronousFileReadHint() : true) && 426 osgDB::containsServerAddress(fileName)) 427 { 428 // we need to enable asynchronous file reading. 429 databaseRequest->_loadOptions = loadOptions ? 430 dynamic_cast<osgDB::ReaderWriter::Options*>(loadOptions->clone(osg::CopyOp::SHALLOW_COPY)) : 431 new osgDB::ReaderWriter::Options; 432 433 databaseRequest->_loadOptions->setAsynchronousFileReadHint(true); 434 } 435 else 436 { 437 databaseRequest->_loadOptions = loadOptions; 438 } 423 439 424 440 _fileRequestList.push_back(databaseRequest); OpenSceneGraph/trunk/src/osgPlugins/curl/ReaderWriterCURL.cpp
r8321 r8322 317 317 } 318 318 319 bool asyncFileRead = options ? options->getAsynchronousFileReadHint() : false; 320 321 osg::notify(osg::INFO)<<"AsynchronousFileReadHint= "<<asyncFileRead<<std::endl; 322 323 // if (asyncFileRead) return ReadResult::FILE_REQUESTED; 319 324 320 325 std::stringstream buffer;
