PluginManager.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef CRYINCLUDE_EDITOR_PLUGINMANAGER_H
  10. #define CRYINCLUDE_EDITOR_PLUGINMANAGER_H
  11. class QLibrary;
  12. struct IPlugin;
  13. struct SPluginEntry
  14. {
  15. QLibrary *hLibrary = nullptr;
  16. IPlugin* pPlugin = nullptr;
  17. };
  18. typedef std::list<SPluginEntry> TPluginList;
  19. // Event IDs associated with event handlers
  20. typedef std::map<int, IUIEvent*> TEventHandlerMap;
  21. typedef TEventHandlerMap::iterator TEventHandlerIt;
  22. // Plugins associated with ID / handler maps
  23. typedef std::map<IPlugin*, TEventHandlerMap> TPluginEventMap;
  24. typedef TPluginEventMap::iterator TPluginEventIt;
  25. // UI IDs associated with plugin pointers. When a plugin UI element is
  26. // activated, the ID is used to determine which plugin should handle
  27. // the event
  28. typedef std::map<uint8, IPlugin*> TUIIDPluginMap;
  29. typedef TUIIDPluginMap::iterator TUIIDPluginIt;
  30. class SANDBOX_API CPluginManager
  31. {
  32. public:
  33. CPluginManager();
  34. virtual ~CPluginManager();
  35. bool LoadPlugins(const char* pluginsPath);
  36. // release all plugins (ie, call Release() on them) - but don't drop their DLL
  37. void ReleaseAllPlugins();
  38. // actually drop their DLL.
  39. void UnloadAllPlugins();
  40. bool CanAllPluginsExitNow();
  41. void AddHandlerForCmdID(IPlugin* pPlugin, uint8 aCmdID, IUIEvent* pEvent);
  42. void NotifyPlugins(EEditorNotifyEvent aEventId);
  43. IPlugin* GetPluginByGUID(const char* pGUID);
  44. IPlugin* GetPluginByUIID(uint8 iUserInterfaceID);
  45. IUIEvent* GetEventByIDAndPluginID(uint8 iPluginID, uint8 iEvtID);
  46. void RegisterPlugin(QLibrary* dllHandle, IPlugin* pPlugin);
  47. const TPluginList& GetPluginList() const
  48. {
  49. return m_plugins;
  50. }
  51. protected:
  52. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  53. TPluginList m_plugins;
  54. TPluginEventMap m_pluginEventMap;
  55. TUIIDPluginMap m_uuidPluginMap;
  56. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  57. int m_currentUUID;
  58. };
  59. #endif // CRYINCLUDE_EDITOR_PLUGINMANAGER_H