EditorFileMonitor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 CRYINCLUDE_EDITOR_EDITORFILEMONITOR_H
  9. #define CRYINCLUDE_EDITOR_EDITORFILEMONITOR_H
  10. #pragma once
  11. #include "Include/IEditorFileMonitor.h"
  12. #include "Util/FileChangeMonitor.h"
  13. class CEditorFileMonitor
  14. : public IEditorFileMonitor
  15. , public CFileChangeMonitorListener
  16. , public IEditorNotifyListener
  17. {
  18. public:
  19. CEditorFileMonitor();
  20. ~CEditorFileMonitor();
  21. bool RegisterListener(IFileChangeListener* pListener, const char* filename) override;
  22. bool RegisterListener(IFileChangeListener* pListener, const char* folderRelativeToGame, const char* ext) override;
  23. bool UnregisterListener(IFileChangeListener* pListener) override;
  24. // from CFileChangeMonitorListener
  25. void OnFileMonitorChange(const SFileChangeInfo& rChange) override;
  26. // from IEditorNotifyListener
  27. void OnEditorNotifyEvent(EEditorNotifyEvent ev) override;
  28. private:
  29. void MonitorDirectories();
  30. // File Change Monitor stuff
  31. struct SFileChangeCallback
  32. {
  33. IFileChangeListener* pListener;
  34. QString item;
  35. QString extension;
  36. SFileChangeCallback()
  37. : pListener(nullptr)
  38. {}
  39. SFileChangeCallback(IFileChangeListener* pListener, const char* item, const char* extension)
  40. : pListener(pListener)
  41. , item(item)
  42. , extension(extension)
  43. {}
  44. };
  45. std::vector<SFileChangeCallback> m_vecFileChangeCallbacks;
  46. };
  47. #endif // CRYINCLUDE_EDITOR_EDITORFILEMONITOR_H