DatabaseRevisions 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  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.
  7. *
  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.
  12. */
  13. #ifndef OSGDB_DATABASEREVISIONS
  14. #define OSGDB_DATABASEREVISIONS 1
  15. #include <osg/Node>
  16. #include <osgDB/ReaderWriter>
  17. #include <set>
  18. namespace osgDB {
  19. class OSGDB_EXPORT FileList : public osg::Object
  20. {
  21. public:
  22. FileList();
  23. FileList(const FileList& fileList, const osg::CopyOp & copyop=osg::CopyOp::SHALLOW_COPY);
  24. META_Object(osgDB, FileList);
  25. typedef std::set<std::string> FileNames;
  26. FileNames& getFileNames() { return _files; }
  27. const FileNames& getFileNames() const { return _files; }
  28. bool empty() const { return _files.empty(); }
  29. bool containsFile(const std::string& filename) const { return _files.count(filename)!=0; }
  30. void addFile(const std::string& filename) { _files.insert(filename); }
  31. bool removeFile(const std::string& filename);
  32. void append(FileList* fileList);
  33. protected:
  34. virtual ~FileList();
  35. FileNames _files;
  36. };
  37. class OSGDB_EXPORT DatabaseRevision : public osg::Object
  38. {
  39. public:
  40. DatabaseRevision();
  41. DatabaseRevision(const DatabaseRevision& revision, const osg::CopyOp & copyop=osg::CopyOp::SHALLOW_COPY);
  42. META_Object(osgDB, DatabaseRevision)
  43. void setDatabasePath(const std::string& path) { _databasePath = path; }
  44. const std::string& getDatabasePath() const { return _databasePath; }
  45. typedef std::set<std::string> FileNames;
  46. void setFilesAdded(FileList* fileList) { _filesAdded = fileList; }
  47. FileList* getFilesAdded() { return _filesAdded.get(); }
  48. const FileList* getFilesAdded() const { return _filesAdded.get(); }
  49. void setFilesRemoved(FileList* fileList) { _filesRemoved = fileList; }
  50. FileList* getFilesRemoved() { return _filesRemoved.get(); }
  51. const FileList* getFilesRemoved() const { return _filesRemoved.get(); }
  52. void setFilesModified(FileList* fileList) { _filesModified = fileList; }
  53. FileList* getFilesModified() { return _filesModified.get(); }
  54. const FileList* getFilesModified() const { return _filesModified.get(); }
  55. bool isFileBlackListed(const std::string& filename) const;
  56. bool removeFile(const std::string& filename);
  57. protected:
  58. virtual ~DatabaseRevision();
  59. std::string _databasePath;
  60. osg::ref_ptr<FileList> _filesAdded;
  61. osg::ref_ptr<FileList> _filesRemoved;
  62. osg::ref_ptr<FileList> _filesModified;
  63. };
  64. class OSGDB_EXPORT DatabaseRevisions : public osg::Object
  65. {
  66. public:
  67. DatabaseRevisions();
  68. DatabaseRevisions(const DatabaseRevisions& revisions, const osg::CopyOp & copyop=osg::CopyOp::SHALLOW_COPY);
  69. META_Object(osgDB, DatabaseRevisions);
  70. typedef std::vector< osg::ref_ptr<DatabaseRevision> > DatabaseRevisionList;
  71. void setDatabasePath(const std::string& path) { _databasePath = path; }
  72. const std::string& getDatabasePath() const { return _databasePath; }
  73. void addRevision(DatabaseRevision* revision);
  74. void removeRevision(DatabaseRevision* revision);
  75. DatabaseRevision* getDatabaseRevision(unsigned int i) { return i<_revisionList.size() ? _revisionList[i].get() : 0; }
  76. DatabaseRevisionList& getDatabaseRevisionList() { return _revisionList; }
  77. const DatabaseRevisionList& getDatabaseRevisionList() const { return _revisionList; }
  78. bool isFileBlackListed(const std::string& filename) const;
  79. bool removeFile(const std::string& filename);
  80. protected:
  81. virtual ~DatabaseRevisions();
  82. std::string _databasePath;
  83. DatabaseRevisionList _revisionList;
  84. };
  85. }
  86. #endif