From 676f204cdba6599ad9735039a0544567d7d939f5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 26 Oct 2004 18:29:27 +0000 Subject: [PATCH] Updates to osgDB::Archive --- include/osgDB/Archive | 10 ----- src/osgDB/Archive.cpp | 101 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 87 insertions(+), 24 deletions(-) diff --git a/include/osgDB/Archive b/include/osgDB/Archive index 4757c6450..a6fb864ae 100644 --- a/include/osgDB/Archive +++ b/include/osgDB/Archive @@ -64,16 +64,6 @@ class OSGDB_EXPORT Archive : public ReaderWriter virtual WriteResult writeImage(const osg::Image& image,const std::string& fileName,const Options* options=NULL); virtual WriteResult writeHeightField(const osg::HeightField& heightField,const std::string& fileName,const Options* options=NULL); virtual WriteResult writeNode(const osg::Node& node,const std::string& fileName,const Options* options=NULL); - - virtual ReadResult readObject(std::istream& fin,const Options* options=NULL); - virtual ReadResult readImage(std::istream& fin,const Options* options=NULL); - virtual ReadResult readHeightField(std::istream& fin,const Options* options=NULL); - virtual ReadResult readNode(std::istream& fin,const Options* options=NULL); - - virtual WriteResult writeObject(const osg::Object& obj,std::ostream& fout,const Options* options=NULL); - virtual WriteResult writeImage(const osg::Image& image,std::ostream& fout,const Options* options=NULL); - virtual WriteResult writeHeightField(const osg::HeightField& heightField,std::ostream& fout,const Options* options=NULL); - virtual WriteResult writeNode(const osg::Node& node,std::ostream& fout,const Options* options=NULL); protected: diff --git a/src/osgDB/Archive.cpp b/src/osgDB/Archive.cpp index 3bb26564a..fa6caf36c 100644 --- a/src/osgDB/Archive.cpp +++ b/src/osgDB/Archive.cpp @@ -11,6 +11,10 @@ * OpenSceneGraph Public License for more details. */ +#include + +#include +#include #include using namespace osgDB; @@ -26,17 +30,21 @@ Archive::~Archive() void Archive::create(const std::string& filename, unsigned int indexBlockSize) { + _status = WRITE; + _output.open(filename.c_str()); } void Archive::open(const std::string& filename, Status status) { if (status==READ) { + _status = status; _input.open(filename.c_str()); } else // status==WRITE { - _input.open(filename.c_str()); + _status = status; + _output.open(filename.c_str()); } } @@ -52,22 +60,87 @@ bool Archive::fileExists(const std::string& filename) const return (_indexMap.count(filename)!=0); } -ReaderWriter::ReadResult Archive::readObject(const std::string& /*fileName*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } +ReaderWriter::ReadResult Archive::readObject(const std::string& fileName,const Options* options) +{ + if (_status!=READ) + { + osg::notify(osg::NOTICE)<<"Archive::readObject(obj, "<getReaderWriterForExtension(getLowerCaseFileExtension(fileName)); + if (!rw) + { + osg::notify(osg::NOTICE)<<"Archive::readObject(obj, "<readObject(_input, options); +} + ReaderWriter::ReadResult Archive::readImage(const std::string& /*fileName*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } ReaderWriter::ReadResult Archive::readHeightField(const std::string& /*fileName*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } ReaderWriter::ReadResult Archive::readNode(const std::string& /*fileName*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options*) {return WriteResult(WriteResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options*) {return WriteResult(WriteResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeHeightField(const osg::HeightField& /*heightField*/,const std::string& /*fileName*/,const Options*) {return WriteResult(WriteResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options*) { return WriteResult(WriteResult::FILE_NOT_HANDLED); } -ReaderWriter::ReadResult Archive::readObject(std::istream& /*fin*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } -ReaderWriter::ReadResult Archive::readImage(std::istream& /*fin*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } -ReaderWriter::ReadResult Archive::readHeightField(std::istream& /*fin*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } -ReaderWriter::ReadResult Archive::readNode(std::istream& /*fin*/,const Options*) { return ReadResult(ReadResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeObject(const osg::Object& /*obj*/,std::ostream& /*fout*/,const Options*) {return WriteResult(WriteResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeImage(const osg::Image& /*image*/,std::ostream& /*fout*/,const Options*) {return WriteResult(WriteResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeHeightField(const osg::HeightField& /*heightField*/,std::ostream& /*fout*/,const Options*) {return WriteResult(WriteResult::FILE_NOT_HANDLED); } -ReaderWriter::WriteResult Archive::writeNode(const osg::Node& /*node*/,std::ostream& /*fout*/,const Options*) { return WriteResult(WriteResult::FILE_NOT_HANDLED); } + +ReaderWriter::WriteResult Archive::writeObject(const osg::Object& obj,const std::string& fileName,const Options* options) +{ + if (_status!=WRITE) + { + osg::notify(osg::NOTICE)<<"Archive::writeObject(obj, "<getReaderWriterForExtension(getLowerCaseFileExtension(fileName)); + if (!rw) + { + osg::notify(osg::NOTICE)<<"Archive::writeObject(obj, "<writeObject(obj, _output, options); +} + +ReaderWriter::WriteResult Archive::writeImage(const osg::Image& /*image*/,const std::string& fileName,const Options* options) +{ + if (_status==READ) + { + osg::notify(osg::NOTICE)<<"Archive::writeImage(obj, "<