FileProcessor.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <QObject>
  11. #include <QString>
  12. #include <QMap>
  13. #include <native/AssetDatabase/AssetDatabase.h>
  14. #include <native/assetprocessor.h>
  15. #endif
  16. namespace AzToolsFramework
  17. {
  18. namespace AssetDatabase
  19. {
  20. class FileDatabaseEntry;
  21. }
  22. }
  23. namespace AssetProcessor
  24. {
  25. class PlatformConfiguration;
  26. class FileProcessor
  27. : public QObject
  28. {
  29. Q_OBJECT
  30. public:
  31. explicit FileProcessor(PlatformConfiguration* config);
  32. ~FileProcessor();
  33. public Q_SLOTS:
  34. //! AssetScanner changed its status
  35. void OnAssetScannerStatusChange(AssetScanningStatus status);
  36. //! AssetScanner found a file
  37. void AssessFilesFromScanner(QSet<AssetFileInfo> files);
  38. //! AssetScanner found a folder
  39. void AssessFoldersFromScanner(QSet<AssetFileInfo> folders);
  40. //! FileWatcher detected added file
  41. virtual void AssessAddedFile(QString fileName);
  42. //! FileWatcher detected removed file
  43. virtual void AssessDeletedFile(QString fileName);
  44. //! Synchronize AssetScanner data with Files table
  45. void Sync();
  46. //! its time to shut down!
  47. void QuitRequested();
  48. Q_SIGNALS:
  49. void ReadyToQuit(QObject* source); //After receiving QuitRequested, you must send this when its safe
  50. private:
  51. PlatformConfiguration* m_platformConfig = nullptr;
  52. AZStd::shared_ptr<AssetDatabaseConnection> m_connection;
  53. //! Files and folders located by AssetScanner during a scan
  54. QList<AssetFileInfo> m_filesInAssetScanner;
  55. QString m_normalizedCacheRootPath;
  56. bool m_shutdownSignalled = false;
  57. bool GetRelativePath(QString& filePath, QString& relativeFileName, QString& scanFolder) const;
  58. bool DeleteFileRecursive(const AzToolsFramework::AssetDatabase::FileDatabaseEntry& file) const;
  59. };
  60. } // namespace AssetProcessor