assetScannerWorker.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifndef ASSETSCANNERWORKER_H
  9. #define ASSETSCANNERWORKER_H
  10. #if !defined(Q_MOC_RUN)
  11. #include "native/assetprocessor.h"
  12. #include "assetScanFolderInfo.h"
  13. #include <QString>
  14. #include <QSet>
  15. #include <QObject>
  16. #endif
  17. namespace AssetProcessor
  18. {
  19. class PlatformConfiguration;
  20. /** This Class is actually responsible for scanning the game folder
  21. * and finding file of interest files.
  22. * Its created on the main thread and then moved to the worker thread
  23. * so it should contain no QObject-based classes at construction time (it can make them later)
  24. */
  25. class AssetScannerWorker
  26. : public QObject
  27. {
  28. Q_OBJECT
  29. public:
  30. explicit AssetScannerWorker(PlatformConfiguration* config, QObject* parent = 0);
  31. Q_SIGNALS:
  32. void ScanningStateChanged(AssetProcessor::AssetScanningStatus status);
  33. void FilesFound(QSet<AssetFileInfo> files); // QSet<QString> is a refcounted copy-on-write object, do not pass by ref.
  34. void FoldersFound(QSet<AssetFileInfo> folders); // QSet<QString> is a refcounted copy-on-write object, do not pass by ref.
  35. void ExcludedFound(QSet<AssetFileInfo> excluded); // QSet<QString> is a refcounted copy-on-write object, do not pass by ref.
  36. public Q_SLOTS:
  37. void StartScan();
  38. void StopScan();
  39. protected:
  40. // scanFolderInfo - the folder we're currently scanning (this will sometimes be a fake scanfolder created when recursing through directories)
  41. // rootScanFolder - the actual scan folder we started with, which will either be the same as scanFolderInfo or a parent folder
  42. void ScanForSourceFiles(const ScanFolderInfo& scanFolderInfo, const ScanFolderInfo& rootScanFolder);
  43. void EmitFiles();
  44. private:
  45. volatile bool m_doScan = true;
  46. QSet<AssetFileInfo> m_fileList; // note: neither QSet nor QString are qobject-derived
  47. QSet<AssetFileInfo> m_folderList;
  48. QSet<AssetFileInfo> m_excludedList;
  49. PlatformConfiguration* m_platformConfiguration;
  50. };
  51. } // end namespace AssetProcessor
  52. #endif // ASSETSCANNERWORKER_H