2004-10-24 22:24:15 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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_ARCHIVE
|
|
|
|
#define OSGDB_ARCHIVE 1
|
|
|
|
|
|
|
|
#include <osgDB/ReaderWriter>
|
2004-11-08 05:17:31 +08:00
|
|
|
#include <osgDB/Registry>
|
2004-10-24 22:24:15 +08:00
|
|
|
|
2004-10-26 03:16:38 +08:00
|
|
|
#include <fstream>
|
2004-10-27 22:09:24 +08:00
|
|
|
#include <list>
|
2004-10-24 22:24:15 +08:00
|
|
|
|
|
|
|
namespace osgDB {
|
|
|
|
|
|
|
|
|
2004-11-11 21:22:55 +08:00
|
|
|
/** Base class for implementing database Archives. See src/osgPlugins/osga for an example of a concrete implementation. */
|
2004-10-24 22:24:15 +08:00
|
|
|
class OSGDB_EXPORT Archive : public ReaderWriter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Archive();
|
|
|
|
virtual ~Archive();
|
2004-10-26 03:16:38 +08:00
|
|
|
|
|
|
|
virtual const char* libraryName() const { return "osgDB"; }
|
|
|
|
|
|
|
|
virtual const char* className() const { return "Archive"; }
|
|
|
|
|
2004-10-24 22:24:15 +08:00
|
|
|
virtual bool acceptsExtension(const std::string& /*extension*/) { return true; }
|
2004-10-26 03:16:38 +08:00
|
|
|
|
2004-10-24 22:24:15 +08:00
|
|
|
/** close the archive.*/
|
2004-11-11 21:22:55 +08:00
|
|
|
virtual void close() = 0;
|
2004-10-24 22:24:15 +08:00
|
|
|
|
|
|
|
/** return true if file exists in archive.*/
|
2004-11-11 21:22:55 +08:00
|
|
|
virtual bool fileExists(const std::string& filename) const = 0;
|
2004-10-24 22:24:15 +08:00
|
|
|
|
2004-11-10 21:03:52 +08:00
|
|
|
/** Get the file name which represents the master file recorded in the Archive.*/
|
2004-11-11 21:22:55 +08:00
|
|
|
virtual std::string getMasterFileName() const = 0;
|
2004-11-10 21:03:52 +08:00
|
|
|
|
|
|
|
typedef std::vector<std::string> FileNameList;
|
|
|
|
|
|
|
|
/** Get the full list of file names available in the archive.*/
|
2004-11-11 21:22:55 +08:00
|
|
|
virtual bool getFileNames(FileNameList& fileNameList) const = 0;
|
2004-10-28 22:27:41 +08:00
|
|
|
|
2004-11-23 23:29:52 +08:00
|
|
|
virtual ReadResult readObject(const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
|
|
|
virtual ReadResult readImage(const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
|
|
|
virtual ReadResult readHeightField(const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
|
|
|
virtual ReadResult readNode(const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
|
|
|
|
|
|
|
virtual WriteResult writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
|
|
|
virtual WriteResult writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
|
|
|
virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
|
|
|
virtual WriteResult writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
|
2004-11-11 21:22:55 +08:00
|
|
|
|
2004-10-24 22:24:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2004-11-08 05:17:31 +08:00
|
|
|
/** Open an archive for reading or writing.*/
|
2004-11-12 06:26:07 +08:00
|
|
|
OSGDB_EXPORT Archive* openArchive(const std::string& filename, Archive::ArchiveStatus status, unsigned int indexBlockSizeHint=4096);
|
2004-11-08 05:17:31 +08:00
|
|
|
|
|
|
|
/** Open an archive for reading or writing.*/
|
2004-11-22 22:10:12 +08:00
|
|
|
OSGDB_EXPORT Archive* openArchive(const std::string& filename, Archive::ArchiveStatus status, unsigned int indexBlockSizeHint,ReaderWriter::Options* options);
|
2004-10-24 22:24:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OSGDB_ARCHIVE
|