Refactored the Registry::ReadFileCallback, WriteFileCallback and ReaderWriter::Options to they are now defined in their own header and in the osgDB namespace.

Introduced a new FindFileCallback to Registry to compliement the existing ReadFileCallback and WriteFileCallback.

Added support for assign Find, Read and WriteFileCallbacks to osdDB::Options to enable plugins/applications to override the callbacks just for that
read/write call and any nested file operations
This commit is contained in:
Robert Osfield
2009-05-09 08:49:27 +00:00
parent a4ff2c4af7
commit b7b065abe3
43 changed files with 1180 additions and 825 deletions

View File

@@ -68,7 +68,7 @@ class OSGDB_EXPORT Archive : public ReaderWriter
OSGDB_EXPORT Archive* openArchive(const std::string& filename, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint=4096);
/** Open an archive for reading or writing.*/
OSGDB_EXPORT Archive* openArchive(const std::string& filename, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint,ReaderWriter::Options* options);
OSGDB_EXPORT Archive* openArchive(const std::string& filename, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint,Options* options);
}
#endif // OSGDB_ARCHIVE

View File

@@ -28,7 +28,7 @@
#include <osgDB/SharedStateManager>
#include <osgDB/ReaderWriter>
#include <osgDB/Export>
#include <osgDB/Options>
#include <map>
#include <list>
@@ -70,7 +70,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
virtual void requestNodeFile(const std::string& fileName,osg::Group* group,
float priority, const osg::FrameStamp* framestamp,
osg::ref_ptr<osg::Referenced>& databaseRequest,
ReaderWriter::Options* loadOptions);
Options* loadOptions);
/** Set the priority of the database pager thread(s).*/
int setSchedulePriority(OpenThreads::Thread::ThreadPriority priority);
@@ -375,7 +375,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
osg::observer_ptr<osg::Group> _groupForAddingLoadedSubgraph;
osg::ref_ptr<osg::Node> _loadedModel;
DataToCompileMap _dataToCompileMap;
osg::ref_ptr<ReaderWriter::Options> _loadOptions;
osg::ref_ptr<Options> _loadOptions;
RequestQueue* _requestQueue;
bool isRequestCurrent (int frameNumber) const

View File

@@ -23,23 +23,23 @@ namespace osgDB {
class OSGDB_EXPORT FileCache : public osg::Referenced
{
public:
FileCache(const std::string& path);
const std::string& getFileCachePath() const { return _fileCachePath; }
virtual std::string createCacheFileName(const std::string& originalFileName) const;
virtual bool existsInCache(const std::string& originalFileName) const;
virtual ReaderWriter::ReadResult readNode(const std::string& originalFileName, const osgDB::ReaderWriter::Options* options, bool buildKdTreeIfRequired=true) const;
virtual ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& originalFileName, const osgDB::ReaderWriter::Options* options) const;
virtual ReaderWriter::ReadResult readNode(const std::string& originalFileName, const osgDB::Options* options, bool buildKdTreeIfRequired=true) const;
virtual ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& originalFileName, const osgDB::Options* options) const;
protected:
virtual ~FileCache();
std::string _fileCachePath;
};

View File

@@ -23,12 +23,6 @@
namespace osgDB {
enum CaseSensitivity
{
CASE_SENSITIVE,
CASE_INSENSITIVE
};
enum FileType
{
FILE_NOT_FOUND,
@@ -86,7 +80,7 @@ extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,CaseSen
/** Search for specified file in file system, checking first the database path set in the Options structure, then the DataFilePathList for possible paths,
* returning the full path of the first valid file found, return an empty string if no string is found.
*/
extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,const ReaderWriter::Options* options, CaseSensitivity caseSensitivity=CASE_SENSITIVE);
extern OSGDB_EXPORT std::string findDataFile(const std::string& filename,const Options* options, CaseSensitivity caseSensitivity=CASE_SENSITIVE);
inline void setLibraryFilePathList(const FilePathList& filepaths) { osgDB::Registry::instance()->setLibraryFilePathList(filepaths); }

View File

@@ -14,11 +14,11 @@
#ifndef OSGDB_IMAGEOPTIONS
#define OSGDB_IMAGEOPTIONS 1
#include <osgDB/ReaderWriter>
#include <osgDB/Options>
namespace osgDB {
class OSGDB_EXPORT ImageOptions : public osgDB::ReaderWriter::Options
class OSGDB_EXPORT ImageOptions : public osgDB::Options
{
public:
@@ -27,7 +27,7 @@ class OSGDB_EXPORT ImageOptions : public osgDB::ReaderWriter::Options
ImageOptions(const std::string& str);
ImageOptions(const ImageOptions& options,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
osgDB::ReaderWriter::Options(options,copyop),
osgDB::Options(options,copyop),
_sourceImageSamplingMode(options._sourceImageSamplingMode),
_sourceImageWindowMode(options._sourceImageWindowMode),
_sourceRatioWindow(options._sourceRatioWindow),

View File

@@ -23,6 +23,7 @@
#include <OpenThreads/Mutex>
#include <osgDB/ReaderWriter>
#include <osgDB/Options>
namespace osgDB
{
@@ -107,7 +108,7 @@ class OSGDB_EXPORT ImagePager : public osg::NodeVisitor::ImageRequestHandler
double _timeToMergeBy;
std::string _fileName;
osg::ref_ptr<ReaderWriter::Options> _loadOptions;
osg::ref_ptr<Options> _loadOptions;
osg::observer_ptr<osg::Object> _attachmentPoint;
int _attachmentIndex;
osg::ref_ptr<osg::Image> _loadedImage;

View File

@@ -23,6 +23,7 @@
#include <osgDB/FieldReaderIterator>
#include <osgDB/ReaderWriter>
#include <osgDB/Options>
#include <map>
#include <string>
@@ -39,8 +40,8 @@ class OSGDB_EXPORT Input : public FieldReaderIterator
Input();
virtual ~Input();
void setOptions(const ReaderWriter::Options* options) { _options = options; }
const ReaderWriter::Options* getOptions() const { return _options.get(); }
void setOptions(const Options* options) { _options = options; }
const Options* getOptions() const { return _options.get(); }
virtual osg::Object* readObjectOfType(const osg::Object& compObj);
virtual osg::Object* readObjectOfType(const basic_type_wrapper &btw);
@@ -87,7 +88,7 @@ class OSGDB_EXPORT Input : public FieldReaderIterator
typedef std::map< std::string, osg::ref_ptr<osg::Object> > UniqueIDToObjectMapping;
UniqueIDToObjectMapping _uniqueIDToObjectMap;
osg::ref_ptr<const ReaderWriter::Options> _options;
osg::ref_ptr<const Options> _options;
};

272
include/osgDB/Options Normal file
View File

@@ -0,0 +1,272 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGDB_OPTIONS
#define OSGDB_OPTIONS 1
#include <osgDB/AuthenticationMap>
#include <osgDB/ReaderWriter>
#include <deque>
#include <list>
#include <iosfwd>
namespace osgDB {
/** list of directories to search through which searching for files. */
typedef std::deque<std::string> FilePathList;
enum CaseSensitivity
{
CASE_SENSITIVE,
CASE_INSENSITIVE
};
// forward decare
class Options;
class OSGDB_EXPORT FindFileCallback : public virtual osg::Referenced
{
public:
virtual std::string findDataFile(const std::string& filename, const Options* options, CaseSensitivity caseSensitivity);
virtual std::string findLibraryFile(const std::string& filename, const Options* options, CaseSensitivity caseSensitivity);
protected:
virtual ~FindFileCallback() {}
};
class OSGDB_EXPORT ReadFileCallback : public virtual osg::Referenced
{
public:
virtual ReaderWriter::ReadResult openArchive(const std::string& filename,ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options* useObjectCache);
virtual ReaderWriter::ReadResult readObject(const std::string& filename, const Options* options);
virtual ReaderWriter::ReadResult readImage(const std::string& filename, const Options* options);
virtual ReaderWriter::ReadResult readHeightField(const std::string& filename, const Options* options);
virtual ReaderWriter::ReadResult readNode(const std::string& filename, const Options* options);
virtual ReaderWriter::ReadResult readShader(const std::string& filename, const Options* options);
protected:
virtual ~ReadFileCallback() {}
};
class OSGDB_EXPORT WriteFileCallback : public virtual osg::Referenced
{
public:
virtual ReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName,const Options* options);
virtual ReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName,const Options* options);
virtual ReaderWriter::WriteResult writeHeightField(const osg::HeightField& obj, const std::string& fileName,const Options* options);
virtual ReaderWriter::WriteResult writeNode(const osg::Node& obj, const std::string& fileName,const Options* options);
virtual ReaderWriter::WriteResult writeShader(const osg::Shader& obj, const std::string& fileName,const Options* options);
protected:
virtual ~WriteFileCallback() {}
};
/** Options base class used for passing options into plugins to control their operation.*/
class Options : public osg::Object
{
public:
/// bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) calls
enum CacheHintOptions
{ /// do not cache objects of any type
CACHE_NONE = 0,
/// cache nodes loaded via readNode(filename)
CACHE_NODES = 1<<0,
/// cache images loaded via readImage(filename)
CACHE_IMAGES = 1<<1,
/// cache heightfield loaded via readHeightField(filename)
CACHE_HEIGHTFIELDS = 1<<2,
/// cache heightfield loaded via readHeightField(filename)
CACHE_ARCHIVES = 1<<3,
/// cache objects loaded via readObject(filename)
CACHE_OBJECTS = 1<<4,
/// cache shaders loaded via readShader(filename)
CACHE_SHADERS = 1<<5,
/// cache on all read*(filename) calls
CACHE_ALL = CACHE_NODES |
CACHE_IMAGES |
CACHE_HEIGHTFIELDS |
CACHE_ARCHIVES |
CACHE_OBJECTS |
CACHE_SHADERS
};
/// range of options of whether to build kdtrees automatically on loading
enum BuildKdTreesHint
{
NO_PREFERENCE,
DO_NOT_BUILD_KDTREES,
BUILD_KDTREES
};
Options():
osg::Object(true),
_objectCacheHint(CACHE_ARCHIVES),
_buildKdTreesHint(NO_PREFERENCE) {}
Options(const std::string& str):
osg::Object(true),
_str(str),
_objectCacheHint(CACHE_ARCHIVES),
_buildKdTreesHint(NO_PREFERENCE) {}
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),
_buildKdTreesHint(options._buildKdTreesHint),
_pluginData(options._pluginData),
_pluginStringData(options._pluginStringData){}
META_Object(osgDB,Options);
/** Set the general Options string.*/
void setOptionString(const std::string& str) { _str = str; }
/** Get the general Options string.*/
const std::string& getOptionString() const { return _str; }
/** Set the database path to use a hint of where to look when loading models.*/
void setDatabasePath(const std::string& str) { _databasePaths.clear(); _databasePaths.push_back(str); }
/** Get the database path which is used a hint of where to look when loading models.*/
FilePathList& getDatabasePathList() { return _databasePaths; }
/** 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 whether the KdTrees should be built for geometry in the loader model. */
void setBuildKdTreesHint(BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
/** Get whether the KdTrees should be built for geometry in the loader model. */
BuildKdTreesHint getBuildKdTreesHint() const { return _buildKdTreesHint; }
/** Set the password map to be used by plugins when access files from secure locations.*/
void setAuthenticationMap(AuthenticationMap* authenticationMap) { _authenticationMap = authenticationMap; }
/** Get the password map to be used by plugins when access files from secure locations.*/
const AuthenticationMap* getAuthenticationMap() const { return _authenticationMap.get(); }
/** Sets a plugindata value PluginData with a string */
void setPluginData(const std::string& s, void* v) const { _pluginData[s] = v; }
/** Get a value from the PluginData */
void* getPluginData(const std::string& s) { return _pluginData[s]; }
/** Get a value from the PluginData */
const void* getPluginData(const std::string& s) const
{
PluginDataMap::const_iterator itr = _pluginData.find(s);
return (itr == _pluginData.end()) ? 0 : itr->second;
}
/** Remove a value from the PluginData */
void removePluginData(const std::string& s) const { _pluginData.erase(s); }
/** Sets a plugindata value PluginData with a string */
void setPluginStringData(const std::string& s, const std::string& v) const { _pluginStringData[s] = v; }
/** Get a string from the PluginStrData */
std::string getPluginStringData(const std::string& s) { return _pluginStringData[s]; }
/** Get a value from the PluginData */
const std::string getPluginStringData(const std::string& s) const
{
PluginStringDataMap::const_iterator itr = _pluginStringData.find(s);
return (itr == _pluginStringData.end()) ? std::string("") : itr->second;
}
/** Remove a value from the PluginData */
void removePluginStringData(const std::string& s) const { _pluginStringData.erase(s); }
/** Set the find callback to use in place of the default findFile calls.*/
void setFindFileCallback( FindFileCallback* cb) { _findFileCallback = cb; }
/** Get the const findFile callback.*/
FindFileCallback* getFindFileCallback() const { return _findFileCallback.get(); }
/** Set the read callback to use in place of the default readFile calls.*/
void setReadFileCallback( ReadFileCallback* cb) { _readFileCallback = cb; }
/** Get the const readFile callback.*/
ReadFileCallback* getReadFileCallback() const { return _readFileCallback.get(); }
/** Set the Registry 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(); }
protected:
virtual ~Options() {}
std::string _str;
FilePathList _databasePaths;
CacheHintOptions _objectCacheHint;
BuildKdTreesHint _buildKdTreesHint;
osg::ref_ptr<AuthenticationMap> _authenticationMap;
typedef std::map<std::string,void*> PluginDataMap;
mutable PluginDataMap _pluginData;
typedef std::map<std::string,std::string> PluginStringDataMap;
mutable PluginStringDataMap _pluginStringData;
osg::ref_ptr<FindFileCallback> _findFileCallback;
osg::ref_ptr<ReadFileCallback> _readFileCallback;
osg::ref_ptr<WriteFileCallback> _writeFileCallback;
};
}
#endif // OSGDB_OPTIONS

View File

@@ -36,8 +36,8 @@ class OSGDB_EXPORT Output : public osgDB::ofstream
virtual ~Output();
void setOptions(const ReaderWriter::Options* options);
const ReaderWriter::Options* getOptions() const { return _options.get(); }
void setOptions(const Options* options);
const Options* getOptions() const { return _options.get(); }
void setWriteOutDefaultValues(bool flag) { _writeOutDefaultValues = flag; }
bool getWriteOutDefaultValues() const { return _writeOutDefaultValues; }
@@ -106,7 +106,7 @@ class OSGDB_EXPORT Output : public osgDB::ofstream
virtual void init();
osg::ref_ptr<const ReaderWriter::Options> _options;
osg::ref_ptr<const Options> _options;
int _indent;
int _indentStep;

View File

@@ -33,7 +33,7 @@ namespace osgDB {
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::Object* readObjectFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::Object* readObjectFile(const std::string& filename,const Options* options);
/** Read an osg::Object from file.
* Return valid osg::Object on success,
@@ -53,7 +53,7 @@ inline osg::Object* readObjectFile(const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::Image* readImageFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::Image* readImageFile(const std::string& filename,const Options* options);
/** Read an osg::Image from file.
* Return valid osg::Image on success,
@@ -73,7 +73,7 @@ inline osg::Image* readImageFile(const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::HeightField* readHeightFieldFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::HeightField* readHeightFieldFile(const std::string& filename,const Options* options);
/** Read an osg::HeightField from file.
* Return valid osg::HeightField on success,
@@ -93,7 +93,7 @@ inline osg::HeightField* readHeightFieldFile(const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::Node* readNodeFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::Node* readNodeFile(const std::string& filename,const Options* options);
/** Read an osg::Node from file.
* Return valid osg::Node on success,
@@ -110,7 +110,7 @@ inline osg::Node* readNodeFile(const std::string& filename)
/** Read an osg::Node subgraph from files, creating a osg::Group to contain the nodes if more
* than one subgraph has been loaded.
* Use the Options object to control cache operations and file search paths in osgDB::Registry.*/
extern OSGDB_EXPORT osg::Node* readNodeFiles(std::vector<std::string>& commandLine,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::Node* readNodeFiles(std::vector<std::string>& commandLine,const Options* options);
/** Read an osg::Node subgraph from files, creating a osg::Group to contain the nodes if more
* than one subgraph has been loaded.*/
@@ -123,7 +123,7 @@ inline osg::Node* readNodeFiles(std::vector<std::string>& commandLine)
/** Read an osg::Node subgraph from files, creating a osg::Group to contain the nodes if more
* than one subgraph has been loaded.
* Use the Options object to control cache operations and file search paths in osgDB::Registry.*/
extern OSGDB_EXPORT osg::Node* readNodeFiles(osg::ArgumentParser& parser,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::Node* readNodeFiles(osg::ArgumentParser& parser,const Options* options);
/** Read an osg::Node subgraph from files, creating a osg::Group to contain the nodes if more
* than one subgraph has been loaded.*/
@@ -139,7 +139,7 @@ inline osg::Node* readNodeFiles(osg::ArgumentParser& parser)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::Shader* readShaderFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::Shader* readShaderFile(const std::string& filename,const Options* options);
/** Read an osg::Shader from file.
* Return valid osg::Shader on success,
@@ -159,7 +159,7 @@ inline osg::Shader* readShaderFile(const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
inline osg::Shader* readShaderFile(osg::Shader::Type type, const std::string& filename,const ReaderWriter::Options* options)
inline osg::Shader* readShaderFile(osg::Shader::Type type, const std::string& filename,const Options* options)
{
osg::Shader* shader = readShaderFile(filename, options);
if (shader && type != osg::Shader::UNDEFINED) shader->setType(type);
@@ -184,7 +184,7 @@ inline osg::Shader* readShaderFile(osg::Shader::Type type, const std::string& fi
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::ref_ptr<osg::Object> readRefObjectFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::ref_ptr<osg::Object> readRefObjectFile(const std::string& filename,const Options* options);
/** Read an osg::Object from file.
* Return an assigned osg::ref_ptr on success,
@@ -204,7 +204,7 @@ inline osg::ref_ptr<osg::Object> readRefObjectFile(const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::ref_ptr<osg::Image> readRefImageFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::ref_ptr<osg::Image> readRefImageFile(const std::string& filename,const Options* options);
/** Read an osg::Image from file.
* Return an assigned osg::ref_ptr on success,
@@ -224,7 +224,7 @@ inline osg::ref_ptr<osg::Image> readRefImageFile(const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::ref_ptr<osg::HeightField> readRefHeightFieldFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::ref_ptr<osg::HeightField> readRefHeightFieldFile(const std::string& filename,const Options* options);
/** Read an osg::HeightField from file.
* Return an assigned osg::ref_ptr on success,
@@ -244,7 +244,7 @@ inline osg::ref_ptr<osg::HeightField> readRefHeightFieldFile(const std::string&
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::ref_ptr<osg::Node> readRefNodeFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::ref_ptr<osg::Node> readRefNodeFile(const std::string& filename,const Options* options);
/** Read an osg::Node from file.
* Return an assigned osg::ref_ptr on success,
@@ -264,7 +264,7 @@ inline osg::ref_ptr<osg::Node> readRefNodeFile(const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to read the specified file.*/
extern OSGDB_EXPORT osg::ref_ptr<osg::Shader> readRefShaderFile(const std::string& filename,const ReaderWriter::Options* options);
extern OSGDB_EXPORT osg::ref_ptr<osg::Shader> readRefShaderFile(const std::string& filename,const Options* options);
/** Read an osg::Shader from file.
* Return an assigned osg::ref_ptr on success,

View File

@@ -31,6 +31,9 @@ class Archive;
/** list of directories to search through which searching for files. */
typedef std::deque<std::string> FilePathList;
// forward declare
class Options;
/** pure virtual base class for reading and writing of non native formats. */
class OSGDB_EXPORT ReaderWriter : public osg::Object
{
@@ -52,10 +55,10 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
/** return which protocols are supported by ReaderWriter. */
virtual const FormatDescriptionMap& supportedProtocols() const { return _supportedProtocols; }
/** return which list of file extensions supported by ReaderWriter. */
virtual const FormatDescriptionMap& supportedExtensions() const { return _supportedExtensions; }
/** return which list of file extensions supported by ReaderWriter. */
virtual const FormatDescriptionMap& supportedOptions() const { return _supportedOptions; }
@@ -93,164 +96,6 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
/** return feature as string */
static FeatureList featureAsString(Features feature);
/** Options base class used for passing options into plugins to control their operation.*/
class Options : public osg::Object
{
public:
/// bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) calls
enum CacheHintOptions
{ /// do not cache objects of any type
CACHE_NONE = 0,
/// cache nodes loaded via readNode(filename)
CACHE_NODES = 1<<0,
/// cache images loaded via readImage(filename)
CACHE_IMAGES = 1<<1,
/// cache heightfield loaded via readHeightField(filename)
CACHE_HEIGHTFIELDS = 1<<2,
/// cache heightfield loaded via readHeightField(filename)
CACHE_ARCHIVES = 1<<3,
/// cache objects loaded via readObject(filename)
CACHE_OBJECTS = 1<<4,
/// cache shaders loaded via readShader(filename)
CACHE_SHADERS = 1<<5,
/// cache on all read*(filename) calls
CACHE_ALL = CACHE_NODES |
CACHE_IMAGES |
CACHE_HEIGHTFIELDS |
CACHE_ARCHIVES |
CACHE_OBJECTS |
CACHE_SHADERS
};
/// range of options of whether to build kdtrees automatically on loading
enum BuildKdTreesHint
{
NO_PREFERENCE,
DO_NOT_BUILD_KDTREES,
BUILD_KDTREES
};
Options():
osg::Object(true),
_objectCacheHint(CACHE_ARCHIVES),
_buildKdTreesHint(NO_PREFERENCE) {}
Options(const std::string& str):
osg::Object(true),
_str(str),
_objectCacheHint(CACHE_ARCHIVES),
_buildKdTreesHint(NO_PREFERENCE) {}
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),
_buildKdTreesHint(options._buildKdTreesHint),
_pluginData(options._pluginData),
_pluginStringData(options._pluginStringData){}
META_Object(osgDB,Options);
/** Set the general Options string.*/
void setOptionString(const std::string& str) { _str = str; }
/** Get the general Options string.*/
const std::string& getOptionString() const { return _str; }
/** Set the database path to use a hint of where to look when loading models.*/
void setDatabasePath(const std::string& str) { _databasePaths.clear(); _databasePaths.push_back(str); }
/** Get the database path which is used a hint of where to look when loading models.*/
FilePathList& getDatabasePathList() { return _databasePaths; }
/** 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 whether the KdTrees should be built for geometry in the loader model. */
void setBuildKdTreesHint(BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
/** Get whether the KdTrees should be built for geometry in the loader model. */
BuildKdTreesHint getBuildKdTreesHint() const { return _buildKdTreesHint; }
/** Set the password map to be used by plugins when access files from secure locations.*/
void setAuthenticationMap(AuthenticationMap* authenticationMap) { _authenticationMap = authenticationMap; }
/** Get the password map to be used by plugins when access files from secure locations.*/
const AuthenticationMap* getAuthenticationMap() const { return _authenticationMap.get(); }
/** Sets a plugindata value PluginData with a string */
void setPluginData(const std::string& s, void* v) const { _pluginData[s] = v; }
/** Get a value from the PluginData */
void* getPluginData(const std::string& s) { return _pluginData[s]; }
/** Get a value from the PluginData */
const void* getPluginData(const std::string& s) const
{
PluginDataMap::const_iterator itr = _pluginData.find(s);
return (itr == _pluginData.end()) ? 0 : itr->second;
}
/** Remove a value from the PluginData */
void removePluginData(const std::string& s) const { _pluginData.erase(s); }
/** Sets a plugindata value PluginData with a string */
void setPluginStringData(const std::string& s, const std::string& v) const { _pluginStringData[s] = v; }
/** Get a string from the PluginStrData */
std::string getPluginStringData(const std::string& s) { return _pluginStringData[s]; }
/** Get a value from the PluginData */
const std::string getPluginStringData(const std::string& s) const
{
PluginStringDataMap::const_iterator itr = _pluginStringData.find(s);
return (itr == _pluginStringData.end()) ? std::string("") : itr->second;
}
/** Remove a value from the PluginData */
void removePluginStringData(const std::string& s) const { _pluginStringData.erase(s); }
protected:
virtual ~Options() {}
std::string _str;
FilePathList _databasePaths;
CacheHintOptions _objectCacheHint;
BuildKdTreesHint _buildKdTreesHint;
osg::ref_ptr<AuthenticationMap> _authenticationMap;
typedef std::map<std::string,void*> PluginDataMap;
mutable PluginDataMap _pluginData;
typedef std::map<std::string,std::string> PluginStringDataMap;
mutable PluginStringDataMap _pluginStringData;
};
class OSGDB_EXPORT ReadResult
@@ -353,6 +198,8 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
CREATE
};
typedef osgDB::Options Options;
/** open an archive for reading, writing, or to create an empty archive for writing to.*/
virtual ReadResult openArchive(const std::string& /*fileName*/,ArchiveStatus, unsigned int =4096, const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }

View File

@@ -22,6 +22,7 @@
#include <osgDB/DynamicLibrary>
#include <osgDB/ReaderWriter>
#include <osgDB/Options>
#include <osgDB/DotOsgWrapper>
#include <osgDB/DatabasePager>
#include <osgDB/FileCache>
@@ -159,43 +160,38 @@ class OSGDB_EXPORT Registry : public osg::Referenced
bool writeObject(const osg::Object& obj,Output& fw);
class ReadFileCallback : public virtual osg::Referenced
typedef class osgDB::FindFileCallback FindFileCallback;
typedef class osgDB::ReadFileCallback ReadFileCallback;
typedef class osgDB::WriteFileCallback WriteFileCallback;
/** Set the Registry callback to use in place of the default findFile calls.*/
void setFindFileCallback( FindFileCallback* cb) { _findFileCallback = cb; }
/** Get the findFile callback.*/
FindFileCallback* getFindFileCallback() { return _findFileCallback.get(); }
/** Get the const findFile callback.*/
const FindFileCallback* getFindFileCallback() const { return _findFileCallback.get(); }
std::string findDataFile(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity)
{
public:
virtual ReaderWriter::ReadResult openArchive(const std::string& filename,ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const ReaderWriter::Options* useObjectCache)
{
return osgDB::Registry::instance()->openArchiveImplementation(filename, status, indexBlockSizeHint, useObjectCache);
}
virtual ReaderWriter::ReadResult readObject(const std::string& filename, const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->readObjectImplementation(filename,options);
}
if (options && options->getFindFileCallback()) return options->getFindFileCallback()->findDataFile(fileName, options, caseSensitivity);
else if (_findFileCallback.valid()) return _findFileCallback->findDataFile(fileName, options, caseSensitivity);
else return findDataFileImplementation(fileName, options, caseSensitivity);
}
std::string findDataFileImplementation(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity);
std::string findLibraryFile(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity)
{
if (options && options->getFindFileCallback()) return options->getFindFileCallback()->findLibraryFile(fileName, options, caseSensitivity);
else if (_findFileCallback.valid()) return _findFileCallback->findLibraryFile(fileName, options, caseSensitivity);
else return findLibraryFileImplementation(fileName, options, caseSensitivity);
}
std::string findLibraryFileImplementation(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity);
virtual ReaderWriter::ReadResult readImage(const std::string& filename, const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->readImageImplementation(filename,options);
}
virtual ReaderWriter::ReadResult readHeightField(const std::string& filename, const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->readHeightFieldImplementation(filename,options);
}
virtual ReaderWriter::ReadResult readNode(const std::string& filename, const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->readNodeImplementation(filename,options);
}
virtual ReaderWriter::ReadResult readShader(const std::string& filename, const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->readShaderImplementation(filename,options);
}
protected:
virtual ~ReadFileCallback() {}
};
/** Set the Registry callback to use in place of the default readFile calls.*/
void setReadFileCallback( ReadFileCallback* cb) { _readFileCallback = cb; }
@@ -207,93 +203,65 @@ class OSGDB_EXPORT Registry : public osg::Referenced
const ReadFileCallback* getReadFileCallback() const { return _readFileCallback.get(); }
ReaderWriter::ReadResult openArchive(const std::string& fileName,ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const ReaderWriter::Options* options)
ReaderWriter::ReadResult openArchive(const std::string& fileName,ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options* options)
{
if (_readFileCallback.valid()) return _readFileCallback->openArchive(fileName, status, indexBlockSizeHint, options);
if (options && options->getReadFileCallback()) return options->getReadFileCallback()->openArchive(fileName, status, indexBlockSizeHint, options);
else if (_readFileCallback.valid()) return _readFileCallback->openArchive(fileName, status, indexBlockSizeHint, options);
else return openArchiveImplementation(fileName, status, indexBlockSizeHint, options);
}
ReaderWriter::ReadResult openArchiveImplementation(const std::string& fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const ReaderWriter::Options* options);
ReaderWriter::ReadResult openArchiveImplementation(const std::string& fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options* options);
ReaderWriter::ReadResult readObject(const std::string& fileName,const ReaderWriter::Options* options, bool buildKdTreeIfRequired=true)
ReaderWriter::ReadResult readObject(const std::string& fileName,const Options* options, bool buildKdTreeIfRequired=true)
{
ReaderWriter::ReadResult result = _readFileCallback.valid() ?
_readFileCallback->readObject(fileName,options) :
readObjectImplementation(fileName,options);
ReaderWriter::ReadResult result;
if (options && options->getReadFileCallback()) result = options->getReadFileCallback()->readObject(fileName,options);
else if (_readFileCallback.valid()) result = _readFileCallback->readObject(fileName,options);
else result = readObjectImplementation(fileName,options);
if (buildKdTreeIfRequired) _buildKdTreeIfRequired(result, options);
return result;
}
ReaderWriter::ReadResult readObjectImplementation(const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::ReadResult readImage(const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::ReadResult readObjectImplementation(const std::string& fileName,const Options* options);
ReaderWriter::ReadResult readImage(const std::string& fileName,const Options* options)
{
if (_readFileCallback.valid()) return _readFileCallback->readImage(fileName,options);
if (options && options->getReadFileCallback()) return options->getReadFileCallback()->readImage(fileName,options);
else if (_readFileCallback.valid()) return _readFileCallback->readImage(fileName,options);
else return readImageImplementation(fileName,options);
}
ReaderWriter::ReadResult readImageImplementation(const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::ReadResult readImageImplementation(const std::string& fileName,const Options* options);
ReaderWriter::ReadResult readHeightField(const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::ReadResult readHeightField(const std::string& fileName,const Options* options)
{
if (_readFileCallback.valid()) return _readFileCallback->readHeightField(fileName,options);
if (options && options->getReadFileCallback()) return options->getReadFileCallback()->readHeightField(fileName,options);
else if (_readFileCallback.valid()) return _readFileCallback->readHeightField(fileName,options);
else return readHeightFieldImplementation(fileName,options);
}
ReaderWriter::ReadResult readHeightFieldImplementation(const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::ReadResult readHeightFieldImplementation(const std::string& fileName,const Options* options);
ReaderWriter::ReadResult readNode(const std::string& fileName,const ReaderWriter::Options* options, bool buildKdTreeIfRequired=true)
ReaderWriter::ReadResult readNode(const std::string& fileName,const Options* options, bool buildKdTreeIfRequired=true)
{
ReaderWriter::ReadResult result = _readFileCallback.valid() ?
_readFileCallback->readNode(fileName,options) :
readNodeImplementation(fileName,options);
ReaderWriter::ReadResult result;
if (options && options->getReadFileCallback()) result = options->getReadFileCallback()->readNode(fileName,options);
else if (_readFileCallback.valid()) result = _readFileCallback->readNode(fileName,options);
else result = readNodeImplementation(fileName,options);
if (buildKdTreeIfRequired) _buildKdTreeIfRequired(result, options);
return result;
}
ReaderWriter::ReadResult readNodeImplementation(const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::ReadResult readNodeImplementation(const std::string& fileName,const Options* options);
ReaderWriter::ReadResult readShader(const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::ReadResult readShader(const std::string& fileName,const Options* options)
{
if (options && options->getReadFileCallback()) return options->getReadFileCallback()->readShader(fileName,options);
if (_readFileCallback.valid()) return _readFileCallback->readShader(fileName,options);
else return readShaderImplementation(fileName,options);
}
ReaderWriter::ReadResult readShaderImplementation(const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::ReadResult readShaderImplementation(const std::string& fileName,const Options* options);
class WriteFileCallback : public virtual osg::Referenced
{
public:
virtual ReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName,const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->writeObjectImplementation(obj,fileName,options);
}
virtual ReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName,const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->writeImageImplementation(obj,fileName,options);
}
virtual ReaderWriter::WriteResult writeHeightField(const osg::HeightField& obj, const std::string& fileName,const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->writeHeightFieldImplementation(obj,fileName,options);
}
virtual ReaderWriter::WriteResult writeNode(const osg::Node& obj, const std::string& fileName,const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->writeNodeImplementation(obj,fileName,options);
}
virtual ReaderWriter::WriteResult writeShader(const osg::Shader& obj, const std::string& fileName,const ReaderWriter::Options* options)
{
return osgDB::Registry::instance()->writeShaderImplementation(obj,fileName,options);
}
protected:
virtual ~WriteFileCallback() {}
};
/** Set the Registry callback to use in place of the default writeFile calls.*/
void setWriteFileCallback( WriteFileCallback* cb) { _writeFileCallback = cb; }
@@ -304,47 +272,52 @@ class OSGDB_EXPORT Registry : public osg::Referenced
const WriteFileCallback* getWriteFileCallback() const { return _writeFileCallback.get(); }
ReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName,const Options* options)
{
if (_writeFileCallback.valid()) return _writeFileCallback->writeObject(obj,fileName,options);
if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeObject(obj,fileName,options);
else if (_writeFileCallback.valid()) return _writeFileCallback->writeObject(obj,fileName,options);
else return writeObjectImplementation(obj,fileName,options);
}
ReaderWriter::WriteResult writeObjectImplementation(const osg::Object& obj, const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::WriteResult writeObjectImplementation(const osg::Object& obj, const std::string& fileName,const Options* options);
ReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName,const Options* options)
{
if (_writeFileCallback.valid()) return _writeFileCallback->writeImage(obj,fileName,options);
if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeImage(obj,fileName,options);
else if (_writeFileCallback.valid()) return _writeFileCallback->writeImage(obj,fileName,options);
else return writeImageImplementation(obj,fileName,options);
}
ReaderWriter::WriteResult writeImageImplementation(const osg::Image& obj, const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::WriteResult writeImageImplementation(const osg::Image& obj, const std::string& fileName,const Options* options);
ReaderWriter::WriteResult writeHeightField(const osg::HeightField& obj, const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::WriteResult writeHeightField(const osg::HeightField& obj, const std::string& fileName,const Options* options)
{
if (_writeFileCallback.valid()) return _writeFileCallback->writeHeightField(obj,fileName,options);
if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeHeightField(obj,fileName,options);
else if (_writeFileCallback.valid()) return _writeFileCallback->writeHeightField(obj,fileName,options);
else return writeHeightFieldImplementation(obj,fileName,options);
}
ReaderWriter::WriteResult writeHeightFieldImplementation(const osg::HeightField& obj, const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::WriteResult writeHeightFieldImplementation(const osg::HeightField& obj, const std::string& fileName,const Options* options);
ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& fileName,const Options* options)
{
if (_writeFileCallback.valid()) return _writeFileCallback->writeNode(node,fileName,options);
if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeNode(node,fileName,options);
else if (_writeFileCallback.valid()) return _writeFileCallback->writeNode(node,fileName,options);
else return writeNodeImplementation(node,fileName,options);
}
ReaderWriter::WriteResult writeNodeImplementation(const osg::Node& node, const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::WriteResult writeNodeImplementation(const osg::Node& node, const std::string& fileName,const Options* options);
ReaderWriter::WriteResult writeShader(const osg::Shader& obj, const std::string& fileName,const ReaderWriter::Options* options)
ReaderWriter::WriteResult writeShader(const osg::Shader& obj, const std::string& fileName,const Options* options)
{
if (_writeFileCallback.valid()) return _writeFileCallback->writeShader(obj,fileName,options);
if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeShader(obj,fileName,options);
else if (_writeFileCallback.valid()) return _writeFileCallback->writeShader(obj,fileName,options);
else return writeShaderImplementation(obj,fileName,options);
}
ReaderWriter::WriteResult writeShaderImplementation(const osg::Shader& obj, const std::string& fileName,const ReaderWriter::Options* options);
ReaderWriter::WriteResult writeShaderImplementation(const osg::Shader& obj, const std::string& fileName,const Options* options);
inline void _buildKdTreeIfRequired(ReaderWriter::ReadResult& result, const ReaderWriter::Options* options)
inline void _buildKdTreeIfRequired(ReaderWriter::ReadResult& result, const Options* options)
{
bool doKdTreeBuilder = (options && options->getBuildKdTreesHint()!=ReaderWriter::Options::NO_PREFERENCE) ?
options->getBuildKdTreesHint() == ReaderWriter::Options::BUILD_KDTREES :
_buildKdTreesHint == ReaderWriter::Options::BUILD_KDTREES;
bool doKdTreeBuilder = (options && options->getBuildKdTreesHint()!=Options::NO_PREFERENCE) ?
options->getBuildKdTreesHint() == Options::BUILD_KDTREES :
_buildKdTreesHint == Options::BUILD_KDTREES;
if (doKdTreeBuilder && _kdTreeBuilder.valid() && result.validNode())
{
@@ -355,10 +328,10 @@ class OSGDB_EXPORT Registry : public osg::Referenced
/** Set whether the KdTrees should be built for geometry in the loader model. */
void setBuildKdTreesHint(ReaderWriter::Options::BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
void setBuildKdTreesHint(Options::BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
/** Get whether the KdTrees should be built for geometry in the loader model. */
ReaderWriter::Options::BuildKdTreesHint getBuildKdTreesHint() const { return _buildKdTreesHint; }
Options::BuildKdTreesHint getBuildKdTreesHint() const { return _buildKdTreesHint; }
/** Set the KdTreeBuilder visitor that is used to build KdTree on loaded models.*/
void setKdTreeBuilder(osg::KdTreeBuilder* builder) { _kdTreeBuilder = builder; }
@@ -390,9 +363,9 @@ class OSGDB_EXPORT Registry : public osg::Referenced
bool getCreateNodeFromImage() const { return _createNodeFromImage; }
void setOptions(ReaderWriter::Options* opt) { _options = opt; }
ReaderWriter::Options* getOptions() { return _options.get(); }
const ReaderWriter::Options* getOptions() const { return _options.get(); }
void setOptions(Options* opt) { _options = opt; }
Options* getOptions() { return _options.get(); }
const Options* getOptions() const { return _options.get(); }
/** initialize both the Data and Library FilePaths, by default called by the
@@ -519,7 +492,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
/** get the attached library with specified name.*/
DynamicLibraryList::iterator getLibraryItr(const std::string& fileName);
ReaderWriter::Options::BuildKdTreesHint _buildKdTreesHint;
Options::BuildKdTreesHint _buildKdTreesHint;
osg::ref_ptr<osg::KdTreeBuilder> _kdTreeBuilder;
osg::ref_ptr<FileCache> _fileCache;
@@ -538,7 +511,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
/** Functor used in internal implementations.*/
struct ReadFunctor
{
ReadFunctor(const std::string& filename, const ReaderWriter::Options* options):
ReadFunctor(const std::string& filename, const Options* options):
_filename(filename),
_options(options) {}
@@ -548,7 +521,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
virtual bool isValid(osg::Object* object) const = 0;
std::string _filename;
const ReaderWriter::Options* _options;
const Options* _options;
};
protected:
@@ -573,7 +546,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
friend struct ReadShaderFunctor;
ReaderWriter::ReadResult read(const ReadFunctor& readFunctor);
ReaderWriter::ReadResult readImplementation(const ReadFunctor& readFunctor,ReaderWriter::Options::CacheHintOptions cacheHint);
ReaderWriter::ReadResult readImplementation(const ReadFunctor& readFunctor,Options::CacheHintOptions cacheHint);
// forward declare helper class
@@ -581,6 +554,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
friend class AvailableReaderWriterIterator;
osg::ref_ptr<FindFileCallback> _findFileCallback;
osg::ref_ptr<ReadFileCallback> _readFileCallback;
osg::ref_ptr<WriteFileCallback> _writeFileCallback;
@@ -610,7 +584,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
static std::string trim( const std::string& str );
// options to pass to reader writers.
osg::ref_ptr<ReaderWriter::Options> _options;
osg::ref_ptr<Options> _options;
FilePathList _dataFilePath;
FilePathList _libraryFilePath;

View File

@@ -32,7 +32,7 @@ namespace osgDB {
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to write the specified file.*/
extern OSGDB_EXPORT bool writeObjectFile(const osg::Object& object, const std::string& filename, const ReaderWriter::Options* options );
extern OSGDB_EXPORT bool writeObjectFile(const osg::Object& object, const std::string& filename, const Options* options );
/** Write an osg::Object to file.
* Return true on success,
@@ -52,7 +52,7 @@ inline bool writeObjectFile(const osg::Object& object, const std::string& filena
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to write the specified file.*/
extern OSGDB_EXPORT bool writeImageFile(const osg::Image& image, const std::string& filename, const ReaderWriter::Options* options );
extern OSGDB_EXPORT bool writeImageFile(const osg::Image& image, const std::string& filename, const Options* options );
/** Write an osg::Image to file.
* Return true on success,
@@ -72,7 +72,7 @@ inline bool writeImageFile(const osg::Image& image, const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to write the specified file.*/
extern OSGDB_EXPORT bool writeHeightFieldFile(const osg::HeightField& hf, const std::string& filename, const ReaderWriter::Options* options );
extern OSGDB_EXPORT bool writeHeightFieldFile(const osg::HeightField& hf, const std::string& filename, const Options* options );
/** Write an osg::HeightField to file.
* Return true on success,
@@ -92,7 +92,7 @@ inline bool writeHeightFieldFile(const osg::HeightField& hf, const std::string&
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to write the specified file.*/
extern OSGDB_EXPORT bool writeNodeFile(const osg::Node& node, const std::string& filename, const ReaderWriter::Options* options );
extern OSGDB_EXPORT bool writeNodeFile(const osg::Node& node, const std::string& filename, const Options* options );
/** Write an osg::Node to file.
* Return true on success,
@@ -112,7 +112,7 @@ inline bool writeNodeFile(const osg::Node& node, const std::string& filename)
* The osgDB::Registry is used to load the appropriate ReaderWriter plugin
* for the filename extension, and this plugin then handles the request
* to write the specified file.*/
extern OSGDB_EXPORT bool writeShaderFile(const osg::Shader& shader, const std::string& filename, const ReaderWriter::Options* options );
extern OSGDB_EXPORT bool writeShaderFile(const osg::Shader& shader, const std::string& filename, const Options* options );
/** Write an osg::Shader to file.
* Return true on success,

View File

@@ -21,8 +21,8 @@ namespace osgDB {
// forward declare
class XmlNode;
/** read an Xml file, find the file in ReaderWriter::Options DataFilePathList.*/
extern OSGDB_EXPORT XmlNode* readXmlFile(const std::string& filename,const ReaderWriter::Options* options);
/** read an Xml file, find the file in Options DataFilePathList.*/
extern OSGDB_EXPORT XmlNode* readXmlFile(const std::string& filename,const Options* options);
/** read an Xml file, find the file in osgDB::Registry's eaderWriter::Options DataFilePathList.*/
inline XmlNode* readXmlFile(const std::string& filename)

View File

@@ -172,7 +172,7 @@ class OSGVOLUME_EXPORT CompositeLayer : public Layer
void clear();
void setFileName(unsigned int i, const std::string& filename) { _layers[i].filename = filename; if (_layers[i].layer.valid()) _layers[i].layer->setFileName(filename); }
void setFileName(unsigned int i, const std::string& filename) { if (i>=_layers.size()) _layers.resize(i+1); _layers[i].filename = filename; if (_layers[i].layer.valid()) _layers[i].layer->setFileName(filename); }
const std::string& getFileName(unsigned int i) const { return _layers[i].layer.valid() ? _layers[i].layer->getFileName() : _layers[i].filename; }
void setLayer(unsigned int i, Layer* layer) { if (i>=_layers.size()) _layers.resize(i+1); _layers[i].layer = layer; }