IEditorClassFactory.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. // Description : Class factory support classes
  9. #ifndef CRYINCLUDE_EDITOR_INCLUDE_IEDITORCLASSFACTORY_H
  10. #define CRYINCLUDE_EDITOR_INCLUDE_IEDITORCLASSFACTORY_H
  11. #pragma once
  12. #include <CryCommon/platform.h>
  13. #include <vector>
  14. #include <QtCore/QString>
  15. #include <AzCore/Math/Guid.h>
  16. #define DEFINE_UUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  17. static const GUID uuid() { return { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }; }
  18. #ifdef AZ_PLATFORM_WINDOWS
  19. #include <Unknwn.h>
  20. #else
  21. struct IUnknown
  22. {
  23. virtual ~IUnknown() = default;
  24. };
  25. #endif
  26. #define __az_uuidof(T) T::uuid()
  27. #if defined(AZ_PLATFORM_LINUX) || defined(AZ_PLATFORM_MAC)
  28. # ifndef _REFGUID_DEFINED
  29. # define _REFGUID_DEFINED
  30. typedef const GUID& REFGUID;
  31. # endif
  32. # ifndef _REFIID_DEFINED
  33. # define _REFIID_DEFINED
  34. typedef const GUID& REFIID;
  35. # endif
  36. # ifndef IID_DEFINED
  37. # define IID_DEFINED
  38. typedef GUID IID;
  39. # endif
  40. #ifndef HRESULT_VALUES_DEFINED
  41. #define HRESULT_VALUES_DEFINED
  42. enum
  43. {
  44. E_OUTOFMEMORY = 0x8007000E,
  45. E_FAIL = 0x80004005,
  46. E_ABORT = 0x80004004,
  47. E_INVALIDARG = 0x80070057,
  48. E_NOINTERFACE = 0x80004002,
  49. E_NOTIMPL = 0x80004001,
  50. E_UNEXPECTED = 0x8000FFFF
  51. };
  52. #endif
  53. #endif // defined(AZ_PLATFORM_LINUX) || defined(AZ_PLATFORM_MAC)
  54. #include "SandboxAPI.h"
  55. class QObject;
  56. //! System class IDs
  57. enum ESystemClassID
  58. {
  59. ESYSTEM_CLASS_OBJECT = 0x0001,
  60. ESYSTEM_CLASS_EDITTOOL = 0x0002,
  61. ESYSTEM_CLASS_PREFERENCE_PAGE = 0x0020,
  62. ESYSTEM_CLASS_VIEWPANE = 0x0021,
  63. //! Source/Asset Control Management Provider
  64. ESYSTEM_CLASS_SCM_PROVIDER = 0x0022,
  65. ESYSTEM_CLASS_CONSOLE_CONNECTIVITY = 0x0023,
  66. ESYSTEM_CLASS_ASSET_DISPLAY = 0x0024,
  67. ESYSTEM_CLASS_ASSET_TAGGING = 0x0025,
  68. ESYSTEM_CLASS_FRAMEWND_EXTENSION_PANE = 0x0030,
  69. ESYSTEM_CLASS_TRACKVIEW_KEYUI = 0x0040,
  70. ESYSTEM_CLASS_UITOOLS = 0x0050, // UI Emulator tool
  71. ESYSTEM_CLASS_CONTROL = 0x0900,
  72. ESYSTEM_CLASS_USER = 0x1000
  73. };
  74. //! This interface describes a class created by a plugin
  75. struct IClassDesc
  76. : public IUnknown
  77. {
  78. //////////////////////////////////////////////////////////////////////////
  79. // IUnknown implementation.
  80. //////////////////////////////////////////////////////////////////////////
  81. virtual HRESULT STDMETHODCALLTYPE QueryInterface([[maybe_unused]] const IID& riid, [[maybe_unused]] void** ppvObj) { return E_NOINTERFACE; }
  82. virtual ULONG STDMETHODCALLTYPE AddRef() { return 0; }
  83. virtual ULONG STDMETHODCALLTYPE Release() { return 0; }
  84. template<class Q>
  85. HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
  86. {
  87. return QueryInterface(__az_uuidof(Q), (void**)pp);
  88. }
  89. //////////////////////////////////////////////////////////////////////////
  90. // Class description.
  91. //////////////////////////////////////////////////////////////////////////
  92. //! This method returns an Editor defined GUID describing the class this plugin class is associated with.
  93. virtual ESystemClassID SystemClassID() = 0;
  94. //! Return the GUID of the class created by plugin.
  95. virtual REFGUID ClassID() = 0;
  96. //! This method returns the human readable name of the class.
  97. virtual QString ClassName() = 0;
  98. //! This method returns Category of this class, Category is specifying where this plugin class fits best in
  99. //! create panel.
  100. virtual QString Category() = 0;
  101. virtual QString MenuSuggestion() { return QString(); }
  102. virtual QString Tooltip() { return QString(); }
  103. virtual QString Description() { return QString(); }
  104. //! This method returns if the plugin should have a menu item for its pane.
  105. virtual bool ShowInMenu() const { return true; }
  106. //! Qt equivalent of CRuntimeClass::CreateObject(). We might create a full QRuntimeClass, if there's a need for it.
  107. virtual QObject* CreateQObject() const { return nullptr; }
  108. //! For any class that may be conditionally enabled or disabled, this function can be overriden to return true if it is enabled, false otherwise.
  109. //! The default is to always return true.
  110. virtual bool IsEnabled() const { return true; }
  111. //////////////////////////////////////////////////////////////////////////
  112. };
  113. struct CRYEDIT_API IEditorClassFactory
  114. {
  115. public:
  116. virtual ~IEditorClassFactory() = default;
  117. //! Register new class to the factory.
  118. virtual void RegisterClass(IClassDesc* pClassDesc) = 0;
  119. //! Find class in the factory by class name.
  120. virtual IClassDesc* FindClass(const char* pClassName) const = 0;
  121. //! Find class in the factory by class id
  122. virtual IClassDesc* FindClass(const GUID& rClassID) const = 0;
  123. virtual void UnregisterClass(const char* pClassName) = 0;
  124. virtual void UnregisterClass(const GUID& rClassID) = 0;
  125. //! Get classes that matching specific requirements.
  126. virtual void GetClassesBySystemID(ESystemClassID aSystemClassID, std::vector<IClassDesc*>& rOutClasses) = 0;
  127. virtual void GetClassesByCategory(const char* pCategory, std::vector<IClassDesc*>& rOutClasses) = 0;
  128. };
  129. #endif // CRYINCLUDE_EDITOR_INCLUDE_IEDITORCLASSFACTORY_H