BsScriptResourceManager.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "BsModule.h"
  4. #include <mono/jit/jit.h>
  5. namespace BansheeEngine
  6. {
  7. class BS_SCR_BE_EXPORT ScriptResourceManager : public Module<ScriptResourceManager>
  8. {
  9. public:
  10. ScriptResourceManager();
  11. /**
  12. * @note Throws an exception if resource for the handle already exists.
  13. * Creates a new managed instance of the object.
  14. */
  15. ScriptTexture2D* createScriptTexture2D(const HTexture& resourceHandle);
  16. /**
  17. * @note Throws an exception if resource for the handle already exists.
  18. * Creates a new managed instance of the object.
  19. */
  20. ScriptTexture3D* createScriptTexture3D(const HTexture& resourceHandle);
  21. /**
  22. * @note Throws an exception if resource for the handle already exists.
  23. * Creates a new managed instance of the object.
  24. */
  25. ScriptTextureCube* createScriptTextureCube(const HTexture& resourceHandle);
  26. /**
  27. * @note Throws an exception if resource for the handle already exists.
  28. * Initializes the ScriptResource with an existing managed instance.
  29. */
  30. ScriptTexture2D* createScriptTexture2D(MonoObject* existingInstance, const HTexture& resourceHandle);
  31. /**
  32. * @note Throws an exception if resource for the handle already exists.
  33. * Initializes the ScriptResource with an existing managed instance.
  34. */
  35. ScriptTexture3D* createScriptTexture3D(MonoObject* existingInstance, const HTexture& resourceHandle);
  36. /**
  37. * @note Throws an exception if resource for the handle already exists.
  38. * Initializes the ScriptResource with an existing managed instance.
  39. */
  40. ScriptTextureCube* createScriptTextureCube(MonoObject* existingInstance, const HTexture& resourceHandle);
  41. /**
  42. * @note Throws an exception if resource for the handle already exists.
  43. * Initializes the ScriptResource with an existing managed instance.
  44. */
  45. ScriptPlainText* createScriptPlainText(const HPlainText& resourceHandle);
  46. /**
  47. * @note Throws an exception if resource for the handle already exists.
  48. * Initializes the ScriptResource with an existing managed instance.
  49. */
  50. ScriptPlainText* createScriptPlainText(MonoObject* existingInstance, const HPlainText& resourceHandle);
  51. /**
  52. * @note Throws an exception if resource for the handle already exists.
  53. * Initializes the ScriptResource with an existing managed instance.
  54. */
  55. ScriptScriptCode* createScriptScriptCode(const HScriptCode& resourceHandle);
  56. /**
  57. * @note Throws an exception if resource for the handle already exists.
  58. * Initializes the ScriptResource with an existing managed instance.
  59. */
  60. ScriptScriptCode* createScriptScriptCode(MonoObject* existingInstance, const HScriptCode& resourceHandle);
  61. /**
  62. * @note Throws an exception if resource for the handle already exists.
  63. * Creates a new managed instance of the object.
  64. */
  65. ScriptSpriteTexture* createScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  66. /**
  67. * @note Throws an exception if resource for the handle already exists.
  68. * Initializes the ScriptResource with an existing managed instance.
  69. */
  70. ScriptSpriteTexture* createScriptSpriteTexture(MonoObject* existingInstance, const HSpriteTexture& resourceHandle);
  71. /**
  72. * @note Throws an exception if resource for the handle already exists.
  73. * Creates a new managed instance of the object.
  74. */
  75. ScriptFont* createScriptFont(const HFont& resourceHandle);
  76. /**
  77. * @note Throws an exception if resource for the handle already exists.
  78. * Initializes the ScriptResource with an existing managed instance.
  79. */
  80. ScriptFont* createScriptFont(MonoObject* existingInstance, const HFont& resourceHandle);
  81. /**
  82. * @note Throws an exception if resource for the handle already exists.
  83. * Initializes the ScriptResource with an existing managed instance.
  84. */
  85. ScriptManagedResource* createManagedResource(MonoObject* existingInstance, const HManagedResource& resourceHandle);
  86. /**
  87. * @note Returns nullptr if script resource doesn't exist.
  88. */
  89. ScriptTexture2D* getScriptTexture(const HTexture& resourceHandle);
  90. /**
  91. * @note Returns nullptr if script resource doesn't exist.
  92. */
  93. ScriptSpriteTexture* getScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  94. /**
  95. * @note Returns nullptr if script resource doesn't exist.
  96. */
  97. ScriptPlainText* getScriptPlainText(const HPlainText& resourceHandle);
  98. /**
  99. * @note Returns nullptr if script resource doesn't exist.
  100. */
  101. ScriptScriptCode* getScriptScriptCode(const HScriptCode& resourceHandle);
  102. /**
  103. * @note Returns nullptr if script resource doesn't exist.
  104. */
  105. ScriptManagedResource* getScriptManagedResource(const HManagedResource& resourceHandle);
  106. /**
  107. * @note Returns nullptr if script resource doesn't exist.
  108. */
  109. ScriptResourceBase* getScriptResource(const String& UUID);
  110. /**
  111. * @note Returns nullptr if script resource doesn't exist.
  112. */
  113. ScriptResourceBase* createScriptResource(const HResource& resource);
  114. void destroyScriptResource(ScriptResourceBase* resource);
  115. private:
  116. UnorderedMap<String, ScriptResourceBase*> mScriptResources;
  117. void throwExceptionIfInvalidOrDuplicate(const String& uuid) const;
  118. };
  119. }