BsScriptResourceManager.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. * Creates a new managed instance of the object.
  44. */
  45. ScriptSpriteTexture* createScriptSpriteTexture(const HSpriteTexture& 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. ScriptSpriteTexture* createScriptSpriteTexture(MonoObject* existingInstance, const HSpriteTexture& resourceHandle);
  51. /**
  52. * @note Throws an exception if resource for the handle already exists.
  53. * Creates a new managed instance of the object.
  54. */
  55. ScriptFont* createScriptFont(const HFont& 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. ScriptFont* createScriptFont(MonoObject* existingInstance, const HFont& resourceHandle);
  61. /**
  62. * @note Throws an exception if resource for the handle already exists.
  63. * Initializes the ScriptResource with an existing managed instance.
  64. */
  65. ScriptManagedResource* createManagedResource(MonoObject* existingInstance, const HManagedResource& resourceHandle);
  66. /**
  67. * @note Returns nullptr if script resource doesn't exist.
  68. */
  69. ScriptTexture2D* getScriptTexture(const HTexture& resourceHandle);
  70. /**
  71. * @note Returns nullptr if script resource doesn't exist.
  72. */
  73. ScriptSpriteTexture* getScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  74. /**
  75. * @note Returns nullptr if script resource doesn't exist.
  76. */
  77. ScriptManagedResource* getScriptManagedResource(const HManagedResource& resourceHandle);
  78. /**
  79. * @note Returns nullptr if script resource doesn't exist.
  80. */
  81. ScriptResourceBase* getScriptResource(const String& UUID);
  82. /**
  83. * @note Returns nullptr if script resource doesn't exist.
  84. */
  85. ScriptResourceBase* createScriptResource(const HResource& resource);
  86. void destroyScriptResource(ScriptResourceBase* resource);
  87. private:
  88. UnorderedMap<String, ScriptResourceBase*> mScriptResources;
  89. void throwExceptionIfInvalidOrDuplicate(const String& uuid) const;
  90. };
  91. }