Moved Registry::ReadFileCallback + WriteFileCallback, and osgDB::ReaderWriter::Options into their own separate Options file and into the osgDB namespace.

Introduced a new callback osgDB::FindFileCallback that overrides the default behavior of findDataFile/findLibraryFile.

Introduced support for assigning ReaderWriter::Options directory to PagedLOD.

Introduced new osgDB::FileLocationCallback for assistancing the DatabasePager to know when a file is hosted on a local or remote file system.
This commit is contained in:
Robert Osfield
2009-05-11 11:39:12 +00:00
parent 67e0abf149
commit f939ea731e
16 changed files with 226 additions and 59 deletions

View File

@@ -63,14 +63,10 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
/** Add a request to load a node file to end the the database request list.*/
virtual void requestNodeFile(const std::string& fileName,osg::Group* group,
float priority, const osg::FrameStamp* framestamp,
osg::ref_ptr<osg::Referenced>& databaseRequest);
virtual void requestNodeFile(const std::string& fileName,osg::Group* group,
float priority, const osg::FrameStamp* framestamp,
osg::ref_ptr<osg::Referenced>& databaseRequest,
Options* loadOptions);
const osg::Referenced* options);
/** Set the priority of the database pager thread(s).*/
int setSchedulePriority(OpenThreads::Thread::ThreadPriority priority);

View File

@@ -28,6 +28,8 @@ class OSGDB_EXPORT FileCache : public osg::Referenced
const std::string& getFileCachePath() const { return _fileCachePath; }
virtual bool isFileAppropriateForFileCache(const std::string& originalFileName) const;
virtual std::string createCacheFileName(const std::string& originalFileName) const;
virtual bool existsInCache(const std::string& originalFileName) const;

View File

@@ -16,6 +16,7 @@
#include <osgDB/AuthenticationMap>
#include <osgDB/ReaderWriter>
#include <osgDB/FileCache>
#include <deque>
#include <list>
@@ -86,8 +87,27 @@ class OSGDB_EXPORT WriteFileCallback : public virtual osg::Referenced
virtual ~WriteFileCallback() {}
};
class OSGDB_EXPORT FileLocationCallback : public virtual osg::Referenced
{
public:
enum Location
{
LOCAL_FILE,
REMOTE_FILE
};
virtual Location fileLocation(const std::string& filename, const Options* options) = 0;
virtual bool useFileCache() const = 0;
protected:
virtual ~FileLocationCallback() {}
};
/** Options base class used for passing options into plugins to control their operation.*/
class Options : public osg::Object
class OSGDB_EXPORT Options : public osg::Object
{
public:
@@ -233,13 +253,27 @@ class Options : public osg::Object
ReadFileCallback* getReadFileCallback() const { return _readFileCallback.get(); }
/** Set the Registry callback to use in place of the default writeFile calls.*/
/** Set the callback to use in place of the default writeFile calls.*/
void setWriteFileCallback( WriteFileCallback* cb) { _writeFileCallback = cb; }
/** Get the const writeFile callback.*/
WriteFileCallback* getWriteFileCallback() const { return _writeFileCallback.get(); }
/** Set the callback to use inform the DatabasePager whether a file is located on local or remote file system..*/
void setFileLocationCallback( FileLocationCallback* cb) { _fileLocationCallback = cb; }
/** Get the callback to use inform the DatabasePager whether a file is located on local or remote file system..*/
FileLocationCallback* getFileLocationCallback() const { return _fileLocationCallback.get(); }
/** Set the FileCache that is used to manage local storage of files downloaded from the internet.*/
void setFileCache(FileCache* fileCache) { _fileCache = fileCache; }
/** Get the FileCache that is used to manage local storage of files downloaded from the internet.*/
FileCache* getFileCache() const { return _fileCache.get(); }
protected:
virtual ~Options() {}
@@ -258,6 +292,9 @@ class Options : public osg::Object
osg::ref_ptr<FindFileCallback> _findFileCallback;
osg::ref_ptr<ReadFileCallback> _readFileCallback;
osg::ref_ptr<WriteFileCallback> _writeFileCallback;
osg::ref_ptr<FileLocationCallback> _fileLocationCallback;
osg::ref_ptr<FileCache> _fileCache;
};
}

View File

@@ -164,6 +164,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
typedef class osgDB::FindFileCallback FindFileCallback;
typedef class osgDB::ReadFileCallback ReadFileCallback;
typedef class osgDB::WriteFileCallback WriteFileCallback;
typedef class osgDB::FileLocationCallback FileLocationCallback;
/** Set the Registry callback to use in place of the default findFile calls.*/
void setFindFileCallback( FindFileCallback* cb) { _findFileCallback = cb; }
@@ -326,6 +327,13 @@ class OSGDB_EXPORT Registry : public osg::Referenced
}
}
/** Set the callback to use inform the DatabasePager whether a file is located on local or remote file system..*/
void setFileLocationCallback( FileLocationCallback* cb) { _fileLocationCallback = cb; }
/** Get the callback to use inform the DatabasePager whether a file is located on local or remote file system..*/
FileLocationCallback* getFileLocationCallback() const { return _fileLocationCallback.get(); }
/** Set whether the KdTrees should be built for geometry in the loader model. */
void setBuildKdTreesHint(Options::BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
@@ -339,6 +347,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
/** Get the KdTreeBuilder visitor that is used to build KdTree on loaded models.*/
osg::KdTreeBuilder* getKdTreeBuilder() { return _kdTreeBuilder.get(); }
/** Set the FileCache that is used to manage local storage of files downloaded from the internet.*/
void setFileCache(FileCache* fileCache) { _fileCache = fileCache; }
@@ -488,7 +497,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
construction other than via the instance() method and
therefore ensuring only one copy is ever constructed*/
Registry();
/** get the attached library with specified name.*/
DynamicLibraryList::iterator getLibraryItr(const std::string& fileName);
@@ -557,6 +566,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
osg::ref_ptr<FindFileCallback> _findFileCallback;
osg::ref_ptr<ReadFileCallback> _readFileCallback;
osg::ref_ptr<WriteFileCallback> _writeFileCallback;
osg::ref_ptr<FileLocationCallback> _fileLocationCallback;
DotOsgWrapperMap _objectWrapperMap;
DotOsgWrapperMap _imageWrapperMap;