1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
15#define OSGDB_ARCHIVE 1
17#include <osgDB/ReaderWriter>
18#include <osgDB/Registry>
19#include <osgDB/FileUtils>
27/** Base class for implementing database Archives. See src/osgPlugins/osga for an example of a concrete implementation. */
28class OSGDB_EXPORT Archive : public ReaderWriter
34 virtual const char* libraryName() const { return "osgDB"; }
36 virtual const char* className() const { return "Archive"; }
38 virtual bool acceptsExtension(const std::string& /*extension*/) const { return true; }
40 /** close the archive.*/
41 virtual void close() = 0;
43 /** Get the file name which represents the archived file.*/
44 virtual std::string getArchiveFileName() const = 0;
46 /** Get the file name which represents the master file recorded in the Archive.*/
47 virtual std::string getMasterFileName() const = 0;
49 /** return true if file exists in archive.*/
50 virtual bool fileExists(const std::string& filename) const = 0;
52 /** return type of file. */
53 virtual FileType getFileType(const std::string& filename) const = 0;
55 typedef osgDB::DirectoryContents FileNameList;
57 /** Get the full list of file names available in the archive.*/
58 virtual bool getFileNames(FileNameList& fileNames) const = 0;
60 /** return the contents of a directory.
61 * returns an empty array on any error.*/
62 virtual DirectoryContents getDirectoryContents(const std::string& dirName) const;
65 virtual ReadResult readObject(const std::string& /*fileName*/,const Options* =NULL) const = 0;
66 virtual ReadResult readImage(const std::string& /*fileName*/,const Options* =NULL) const = 0;
67 virtual ReadResult readHeightField(const std::string& /*fileName*/,const Options* =NULL) const = 0;
68 virtual ReadResult readNode(const std::string& /*fileName*/,const Options* =NULL) const = 0;
69 virtual ReadResult readShader(const std::string& /*fileName*/,const Options* =NULL) const = 0;
71 virtual WriteResult writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
72 virtual WriteResult writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
73 virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
74 virtual WriteResult writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
75 virtual WriteResult writeShader(const osg::Shader& /*shader*/,const std::string& /*fileName*/,const Options* =NULL) const = 0;
79/** Open an archive for reading or writing.*/
80OSGDB_EXPORT Archive* openArchive(const std::string& filename, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint=4096);
82/** Open an archive for reading or writing.*/
83OSGDB_EXPORT Archive* openArchive(const std::string& filename, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint,Options* options);
86#endif // OSGDB_ARCHIVE