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:
@@ -274,19 +274,19 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
|
||||
class DatabaseRequestHandler : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
DatabaseRequestHandler():
|
||||
Referenced(true) {}
|
||||
|
||||
virtual void requestNodeFile(const std::string& fileName,osg::Group* group, float priority, const FrameStamp* framestamp, osg::ref_ptr<osg::Referenced>& databaseRequest) = 0;
|
||||
|
||||
|
||||
virtual void requestNodeFile(const std::string& fileName,osg::Group* group, float priority, const FrameStamp* framestamp, osg::ref_ptr<osg::Referenced>& databaseRequest, const osg::Referenced* options=0) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~DatabaseRequestHandler() {}
|
||||
};
|
||||
|
||||
|
||||
/** Set the handler for database requests.*/
|
||||
void setDatabaseRequestHandler(DatabaseRequestHandler* handler) { _databaseRequestHandler = handler; }
|
||||
|
||||
|
||||
/** Get the handler for database requests.*/
|
||||
DatabaseRequestHandler* getDatabaseRequestHandler() { return _databaseRequestHandler.get(); }
|
||||
|
||||
|
||||
@@ -42,7 +42,16 @@ class OSG_EXPORT PagedLOD : public LOD
|
||||
virtual bool addChild(Node *child, float min, float max,const std::string& filename, float priorityOffset=0.0f, float priorityScale=1.0f);
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove=1);
|
||||
|
||||
|
||||
|
||||
/** Set the optional database osgDB::Options object to use when loaded children.*/
|
||||
void setDatabaseOptions(osg::Referenced* options) { _databaseOptions = options; }
|
||||
|
||||
/** Get the optional database osgDB::Options object used when loaded children.*/
|
||||
osg::Referenced* getDatabaseOptions() { return _databaseOptions.get(); }
|
||||
|
||||
/** Get the optional database osgDB::Options object used when loaded children.*/
|
||||
const osg::Referenced* getDatabaseOptions() const { return _databaseOptions.get(); }
|
||||
|
||||
|
||||
/** Set the database path to prepend to children's filenames.*/
|
||||
@@ -133,6 +142,7 @@ class OSG_EXPORT PagedLOD : public LOD
|
||||
|
||||
void expandPerRangeDataTo(unsigned int pos);
|
||||
|
||||
ref_ptr<Referenced> _databaseOptions;
|
||||
std::string _databasePath;
|
||||
|
||||
int _frameNumberOfLastTraversal;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user