2
0

BsScriptAssemblyManager.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "BsManagedSerializableObjectInfo.h"
  6. #include "BsModule.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup SBansheeEngine
  10. * @{
  11. */
  12. /** Stores data about managed serializable objects in specified assemblies. */
  13. class BS_SCR_BE_EXPORT ScriptAssemblyManager : public Module<ScriptAssemblyManager>
  14. {
  15. public:
  16. ScriptAssemblyManager();
  17. ~ScriptAssemblyManager();
  18. /**
  19. * Loads all information about managed serializable objects in an assembly with the specified name. Assembly must be
  20. * currently loaded. Once the data has been loaded you will be able to call getSerializableObjectInfo() and
  21. * hasSerializableObjectInfo() to retrieve information about those objects. If an assembly already had data loaded
  22. * it will be rebuilt.
  23. */
  24. void loadAssemblyInfo(const String& assemblyName);
  25. /** Clears any assembly data previously loaded with loadAssemblyInfo(). */
  26. void clearAssemblyInfo();
  27. /**
  28. * Returns managed serializable object info for a specific managed type.
  29. *
  30. * @param[in] ns Namespace of the type.
  31. * @param[in] typeName Name of the type.
  32. * @param[out] outInfo Output object containing information about the type if the type was found, unmodified
  33. * otherwise.
  34. * @return True if the type was found, false otherwise.
  35. */
  36. bool getSerializableObjectInfo(const String& ns, const String& typeName,
  37. SPtr<ManagedSerializableObjectInfo>& outInfo);
  38. /** Generates or retrieves a type info object for the specified managed class, if the class is serializable. */
  39. SPtr<ManagedSerializableTypeInfo> getTypeInfo(MonoClass* monoClass);
  40. /**
  41. * Checks if the managed serializable object info for the specified type exists.
  42. *
  43. * @param[in] ns Namespace of the type.
  44. * @param[in] typeName Name of the type.
  45. * @return True if the object info was found, false otherwise.
  46. */
  47. bool hasSerializableObjectInfo(const String& ns, const String& typeName);
  48. /** Returns names of all assemblies that currently have managed serializable object data loaded. */
  49. Vector<String> getScriptAssemblies() const;
  50. /** Gets the managed class for System.Array type. */
  51. MonoClass* getSystemArrayClass() const { return mSystemArrayClass; }
  52. /** Gets the managed class for System.Collections.Generic.List<T> type. */
  53. MonoClass* getSystemGenericListClass() const { return mSystemGenericListClass; }
  54. /** Gets the managed class for System.Collections.Generic.Dictionary<T,U> type. */
  55. MonoClass* getSystemGenericDictionaryClass() const { return mSystemGenericDictionaryClass; }
  56. /** Gets the managed class for System.Type type. */
  57. MonoClass* getSystemTypeClass() const { return mSystemTypeClass; }
  58. /** Gets the managed class for BansheeEngine.Component type. */
  59. MonoClass* getComponentClass() const { return mComponentClass; }
  60. /** Gets the managed class for BansheeEngine.MissingComponent type. */
  61. MonoClass* getMissingComponentClass() const { return mMissingComponentClass; }
  62. /** Gets the managed class for BansheeEngine.SceneObject type. */
  63. MonoClass* getSceneObjectClass() const { return mSceneObjectClass; }
  64. /** Gets the managed class for BansheeEngine.Range attribute */
  65. MonoClass* getRangeAttribute() const { return mRangeAttribute; }
  66. /** Gets the managed class for BansheeEngine.Step attribute */
  67. MonoClass* getStepAttribute() const { return mStepAttribute; }
  68. private:
  69. /** Deletes all stored managed serializable object infos for all assemblies. */
  70. void clearScriptObjects();
  71. /**
  72. * Initializes the base managed types. These are the types we expect must exist in loaded assemblies as they're used
  73. * for various common operations.
  74. */
  75. void initializeBaseTypes();
  76. UnorderedMap<String, SPtr<ManagedSerializableAssemblyInfo>> mAssemblyInfos;
  77. bool mBaseTypesInitialized;
  78. MonoClass* mSystemArrayClass;
  79. MonoClass* mSystemGenericListClass;
  80. MonoClass* mSystemGenericDictionaryClass;
  81. MonoClass* mSystemTypeClass;
  82. MonoClass* mComponentClass;
  83. MonoClass* mSceneObjectClass;
  84. MonoClass* mMissingComponentClass;
  85. MonoClass* mSerializeObjectAttribute;
  86. MonoClass* mDontSerializeFieldAttribute;
  87. MonoClass* mSerializeFieldAttribute;
  88. MonoClass* mHideInInspectorAttribute;
  89. MonoClass* mShowInInspectorAttribute;
  90. MonoClass* mRangeAttribute;
  91. MonoClass* mStepAttribute;
  92. };
  93. /** @} */
  94. }