diff --git a/include/osgDB/DatabaseRevisions b/include/osgDB/DatabaseRevisions new file mode 100644 index 000000000..a480f7e6a --- /dev/null +++ b/include/osgDB/DatabaseRevisions @@ -0,0 +1,76 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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_DATABASEREVISIONS +#define OSGDB_DATABASEREVISIONS 1 + +#include + +#include + +#include + +namespace osgDB { + + +class OSGDB_EXPORT DatabaseRevision : public osg::Object +{ + public: + + DatabaseRevision(); + DatabaseRevision(const DatabaseRevision& revision, const osg::CopyOp=osg::CopyOp::SHALLOW_COPY); + + META_Object(osgDB, DatabaseRevision) + + typedef std::set FileNames; + + FileNames& getFilesAdded() { return _filesAdded; } + FileNames& getFilesRemoved() { return _filesRemoved; } + FileNames& getFilesModified() { return _filesModified; } + + bool isFileBlackListed(const std::string& filename) const; + + protected: + + virtual ~DatabaseRevision(); + + FileNames _filesAdded; + FileNames _filesRemoved; + FileNames _filesModified; +}; + +class OSGDB_EXPORT DatabaseRevisions : public osg::Object +{ + public: + + DatabaseRevisions(); + DatabaseRevisions(const DatabaseRevisions& revisions, const osg::CopyOp=osg::CopyOp::SHALLOW_COPY); + + META_Object(osgDB, DatabaseRevisions) + + typedef std::vector< osg::ref_ptr > DatabaseRevisionList; + + DatabaseRevisionList& getDatabaseRevisionList() { return _revisionList; } + + bool isFileBlackListed(const std::string& filename) const; + + protected: + + virtual ~DatabaseRevisions(); + + DatabaseRevisionList _revisionList; +}; + +} + +#endif diff --git a/include/osgDB/FileCache b/include/osgDB/FileCache index 1fa264de2..dd56661a2 100644 --- a/include/osgDB/FileCache +++ b/include/osgDB/FileCache @@ -17,6 +17,9 @@ #include #include +#include + +#include namespace osgDB { @@ -49,12 +52,20 @@ class OSGDB_EXPORT FileCache : public osg::Referenced 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; + + typedef std::list< osg::ref_ptr > DatabaseRevisionsList; + DatabaseRevisionsList& getDatabaseRevisionsList() { return _databaseRevisionsList; } + + bool isCachedFileBlackListed(const std::string& originalFileName) const; + protected: virtual ~FileCache(); std::string _fileCachePath; + DatabaseRevisionsList _databaseRevisionsList; + }; } diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt index 052d7baf0..35dd231cb 100644 --- a/src/osgDB/CMakeLists.txt +++ b/src/osgDB/CMakeLists.txt @@ -24,6 +24,7 @@ SET(LIB_PUBLIC_HEADERS ${HEADER_PATH}/Callbacks ${HEADER_PATH}/ConvertUTF ${HEADER_PATH}/DatabasePager + ${HEADER_PATH}/DatabaseRevisions ${HEADER_PATH}/DotOsgWrapper ${HEADER_PATH}/DynamicLibrary ${HEADER_PATH}/Export @@ -60,6 +61,7 @@ ADD_LIBRARY(${LIB_NAME} Callbacks.cpp ConvertUTF.cpp DatabasePager.cpp + DatabaseRevisions.cpp DotOsgWrapper.cpp DynamicLibrary.cpp Field.cpp diff --git a/src/osgDB/DatabaseRevisions.cpp b/src/osgDB/DatabaseRevisions.cpp new file mode 100644 index 000000000..b57013271 --- /dev/null +++ b/src/osgDB/DatabaseRevisions.cpp @@ -0,0 +1,74 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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. +*/ + +#include +#include +#include +#include +#include + +using namespace osgDB; + +//////////////////////////////////////////////////////////////////////////////////////////// +// +// DatabaseRevision +// +DatabaseRevision::DatabaseRevision() +{ +} + +DatabaseRevision::DatabaseRevision(const DatabaseRevision& revision, const osg::CopyOp): + _filesAdded(revision._filesAdded), + _filesRemoved(revision._filesRemoved), + _filesModified(revision._filesModified) +{ +} + +DatabaseRevision::~DatabaseRevision() +{ +} + +bool DatabaseRevision::isFileBlackListed(const std::string& filename) const +{ + return _filesRemoved.count(filename)!=0 || _filesModified.count(filename)!=0; +} + + +//////////////////////////////////////////////////////////////////////////////////////////// +// +// DatabaseRevisions +// +DatabaseRevisions::DatabaseRevisions() +{ +} + +DatabaseRevisions::DatabaseRevisions(const DatabaseRevisions& revisions, const osg::CopyOp): + _revisionList(revisions._revisionList) +{ +} + +DatabaseRevisions::~DatabaseRevisions() +{ +} + +bool DatabaseRevisions::isFileBlackListed(const std::string& filename) const +{ + for(DatabaseRevisionList::const_iterator itr = _revisionList.begin(); + itr != _revisionList.end(); + ++itr) + { + if ((*itr)->isFileBlackListed(filename)) return true; + } + return false; +} + diff --git a/src/osgDB/FileCache.cpp b/src/osgDB/FileCache.cpp index 5a0a8bc49..065d5eccb 100644 --- a/src/osgDB/FileCache.cpp +++ b/src/osgDB/FileCache.cpp @@ -19,6 +19,10 @@ using namespace osgDB; +//////////////////////////////////////////////////////////////////////////////////////////// +// +// FileCache +// FileCache::FileCache(const std::string& path): _fileCachePath(path) { @@ -40,15 +44,19 @@ std::string FileCache::createCacheFileName(const std::string& originalFileName) std::string cacheFileName = _fileCachePath + "/" + osgDB::getServerAddress(originalFileName) + "/" + osgDB::getServerFileName(originalFileName); - + osg::notify(osg::INFO)<<"FileCache::createCacheFileName("<isFileBlackListed(originalFileName)) return true; + } + return false; +}