BsProjectLibrary.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "CmModule.h"
  4. #include "CmPath.h"
  5. namespace BansheeEditor
  6. {
  7. class ProjectLibrary : public CM::Module<ProjectLibrary>
  8. {
  9. public:
  10. struct LibraryEntry;
  11. struct ResourceEntry;
  12. struct DirectoryEntry;
  13. enum class LibraryEntryType
  14. {
  15. File,
  16. Directory
  17. };
  18. struct LibraryEntry
  19. {
  20. LibraryEntryType type;
  21. CM::WPath path;
  22. DirectoryEntry* parent;
  23. };
  24. struct ResourceEntry : public LibraryEntry
  25. {
  26. ResourceMetaPtr meta;
  27. std::time_t lastUpdateTime;
  28. };
  29. struct DirectoryEntry : public LibraryEntry
  30. {
  31. CM::Vector<LibraryEntry*>::type mChildren;
  32. };
  33. public:
  34. ProjectLibrary();
  35. ~ProjectLibrary();
  36. void update();
  37. void checkForModifications(const CM::WString& fullPath);
  38. const LibraryEntry* getRootEntry() const { return mRootEntry; }
  39. LibraryEntry* findEntry(const CM::WPath& fullPath) const;
  40. void moveEntry(const CM::WPath& oldPath, const CM::WPath& newPath);
  41. void deleteEntry(const CM::WPath& path);
  42. boost::signal<void(const CM::WPath&)> onEntryRemoved;
  43. boost::signal<void(const CM::WPath&)> onEntryAdded;
  44. private:
  45. static const CM::WString INTERNAL_RESOURCES_DIR;
  46. DirectoryEntry* mRootEntry;
  47. CM::FolderMonitor* mMonitor;
  48. ResourceEntry* addResourceInternal(DirectoryEntry* parent, const CM::WPath& filePath);
  49. DirectoryEntry* addDirectoryInternal(DirectoryEntry* parent, const CM::WPath& dirPath);
  50. void deleteResourceInternal(ResourceEntry* resource);
  51. void deleteDirectoryInternal(DirectoryEntry* directory);
  52. void reimportResourceInternal(ResourceEntry* resource);
  53. void createInternalParentHierarchy(const CM::WPath& fullPath, DirectoryEntry** newHierarchyRoot, DirectoryEntry** newHierarchyLeaf);
  54. bool isUpToDate(ResourceEntry* resource) const;
  55. CM::WPath getMetaPath(const CM::WPath& path) const;
  56. bool isMeta(const CM::WPath& fullPath) const;
  57. void onMonitorFileModified(const CM::WString& path);
  58. };
  59. }