Added osgDB::ReaderWriter::Options class to the ReaderWriter base class, support
for settings options in osgDB::Registry, and added the paramter to all of the reaader/writer plugins. The Options structure by default has an string attached for packing basic options, however, it also can be subclassed to encapsulate any users defined option data. In the later case both the client code *and* the plugin need to be aware of subclass, the plugin will need to use dynamic_cast<> to assertain its type.
This commit is contained in:
@@ -22,13 +22,32 @@ class OSGDB_EXPORT ReaderWriter : public osg::Referenced
|
||||
virtual const char* className() = 0;
|
||||
virtual bool acceptsExtension(const std::string& /*extension*/) { return false; }
|
||||
|
||||
virtual osg::Object* readObject(const std::string& /*fileName*/) { return NULL; }
|
||||
virtual osg::Image* readImage(const std::string& /*fileName*/) { return NULL; }
|
||||
virtual osg::Node* readNode(const std::string& /*fileName*/) { return NULL; }
|
||||
class Options : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
virtual bool writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/) {return false; }
|
||||
virtual bool writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/) {return false; }
|
||||
virtual bool writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/) { return false; }
|
||||
Options() {}
|
||||
Options(const std::string& str):_str(str) {}
|
||||
|
||||
void setOptionString(const std::string& str) { _str = str; }
|
||||
const std::string& getOptionString() const { return _str; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Options() {}
|
||||
|
||||
std::string _str;
|
||||
|
||||
};
|
||||
|
||||
|
||||
virtual osg::Object* readObject(const std::string& /*fileName*/,const Options* =NULL) { return NULL; }
|
||||
virtual osg::Image* readImage(const std::string& /*fileName*/,const Options* =NULL) { return NULL; }
|
||||
virtual osg::Node* readNode(const std::string& /*fileName*/,const Options* =NULL) { return NULL; }
|
||||
|
||||
virtual bool writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options* =NULL) {return false; }
|
||||
virtual bool writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options* =NULL) {return false; }
|
||||
virtual bool writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options* =NULL) { return false; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -85,6 +85,11 @@ class OSGDB_EXPORT Registry
|
||||
void setCreateNodeFromImage(bool flag) { _createNodeFromImage = flag; }
|
||||
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(); }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<std::string,osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap;
|
||||
@@ -120,6 +125,9 @@ class OSGDB_EXPORT Registry
|
||||
|
||||
// map to alias to extensions to plugins.
|
||||
ExtensionAliasMap _extAliasMap;
|
||||
|
||||
// options to pass to reader writers.
|
||||
osg::ref_ptr<ReaderWriter::Options> _options;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user