2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2008-10-21 00:24:57 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* 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
|
2008-10-21 00:24:57 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2008-10-21 00:24:57 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-10-21 00:24:57 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OSGDB_FILECACHE
|
|
|
|
#define OSGDB_FILECACHE 1
|
|
|
|
|
|
|
|
#include <osg/Node>
|
|
|
|
|
|
|
|
#include <osgDB/ReaderWriter>
|
2009-05-29 16:24:11 +08:00
|
|
|
#include <osgDB/DatabaseRevisions>
|
|
|
|
|
|
|
|
#include <set>
|
2008-10-21 00:24:57 +08:00
|
|
|
|
|
|
|
namespace osgDB {
|
|
|
|
|
|
|
|
class OSGDB_EXPORT FileCache : public osg::Referenced
|
|
|
|
{
|
2012-03-22 01:36:20 +08:00
|
|
|
public:
|
2009-05-09 16:49:27 +08:00
|
|
|
|
2008-10-21 00:24:57 +08:00
|
|
|
FileCache(const std::string& path);
|
|
|
|
|
|
|
|
const std::string& getFileCachePath() const { return _fileCachePath; }
|
|
|
|
|
2009-05-11 19:39:12 +08:00
|
|
|
virtual bool isFileAppropriateForFileCache(const std::string& originalFileName) const;
|
|
|
|
|
2008-10-21 00:24:57 +08:00
|
|
|
virtual std::string createCacheFileName(const std::string& originalFileName) const;
|
2009-05-09 16:49:27 +08:00
|
|
|
|
2008-10-21 00:24:57 +08:00
|
|
|
virtual bool existsInCache(const std::string& originalFileName) const;
|
2009-05-09 16:49:27 +08:00
|
|
|
|
2009-05-14 03:44:27 +08:00
|
|
|
virtual ReaderWriter::ReadResult readImage(const std::string& originalFileName, const osgDB::Options* options) const;
|
|
|
|
virtual ReaderWriter::WriteResult writeImage(const osg::Image& image, const std::string& originalFileName, const osgDB::Options* options) const;
|
|
|
|
|
|
|
|
virtual ReaderWriter::ReadResult readObject(const std::string& originalFileName, const osgDB::Options* options) const;
|
|
|
|
virtual ReaderWriter::WriteResult writeObject(const osg::Object& object, const std::string& originalFileName, const osgDB::Options* options) const;
|
|
|
|
|
|
|
|
virtual ReaderWriter::ReadResult readHeightField(const std::string& originalFileName, const osgDB::Options* options) const;
|
|
|
|
virtual ReaderWriter::WriteResult writeHeightField(const osg::HeightField& hf, const std::string& originalFileName, const osgDB::Options* options) const;
|
2009-05-09 16:49:27 +08:00
|
|
|
|
2009-05-14 03:44:27 +08:00
|
|
|
virtual ReaderWriter::ReadResult readNode(const std::string& originalFileName, const osgDB::Options* options, bool buildKdTreeIfRequired=true) const;
|
2009-05-09 16:49:27 +08:00
|
|
|
virtual ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& originalFileName, const osgDB::Options* options) const;
|
2008-10-21 00:24:57 +08:00
|
|
|
|
2009-05-14 03:44:27 +08:00
|
|
|
virtual ReaderWriter::ReadResult readShader(const std::string& originalFileName, const osgDB::Options* options) const;
|
|
|
|
virtual ReaderWriter::WriteResult writeShader(const osg::Shader& shader, const std::string& originalFileName, const osgDB::Options* options) const;
|
|
|
|
|
2009-06-03 00:54:34 +08:00
|
|
|
bool loadDatabaseRevisionsForFile(const std::string& originanlFileName);
|
2009-05-29 16:24:11 +08:00
|
|
|
|
|
|
|
typedef std::list< osg::ref_ptr<DatabaseRevisions> > DatabaseRevisionsList;
|
|
|
|
DatabaseRevisionsList& getDatabaseRevisionsList() { return _databaseRevisionsList; }
|
|
|
|
|
|
|
|
bool isCachedFileBlackListed(const std::string& originalFileName) const;
|
|
|
|
|
2008-10-21 00:24:57 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~FileCache();
|
2009-05-09 16:49:27 +08:00
|
|
|
|
2008-10-21 00:24:57 +08:00
|
|
|
std::string _fileCachePath;
|
|
|
|
|
2009-05-29 16:24:11 +08:00
|
|
|
DatabaseRevisionsList _databaseRevisionsList;
|
|
|
|
|
2009-06-04 22:07:12 +08:00
|
|
|
FileList* readFileList(const std::string& originalFileName) const;
|
|
|
|
bool removeFileFromBlackListed(const std::string& originalFileName) const;
|
|
|
|
|
2008-10-21 00:24:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|