BsManagedSerializableList.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "BsIReflectable.h"
  4. #include <mono/jit/jit.h>
  5. namespace BansheeEngine
  6. {
  7. class BS_SCR_BE_EXPORT ManagedSerializableList : public IReflectable
  8. {
  9. private:
  10. struct ConstructPrivately {};
  11. public:
  12. ManagedSerializableList(const ConstructPrivately& dummy, const ManagedSerializableTypeInfoListPtr& typeInfo, MonoObject* managedInstance);
  13. ManagedSerializableList(const ConstructPrivately& dummy);
  14. MonoObject* getManagedInstance() const { return mManagedInstance; }
  15. static ManagedSerializableListPtr createFromExisting(MonoObject* managedInstance, const ManagedSerializableTypeInfoListPtr& typeInfo);
  16. static ManagedSerializableListPtr createFromNew(const ManagedSerializableTypeInfoListPtr& typeInfo, UINT32 size);
  17. static MonoObject* createManagedInstance(const ManagedSerializableTypeInfoListPtr& typeInfo, UINT32 size);
  18. protected:
  19. MonoObject* mManagedInstance;
  20. MonoMethod* mAddMethod;
  21. MonoProperty* mItemProp;
  22. MonoProperty* mCountProp;
  23. ManagedSerializableTypeInfoListPtr mListTypeInfo;
  24. UINT32 mNumElements;
  25. void initMonoObjects(MonoClass* listClass);
  26. /**
  27. * @brief Creates a new managed instance and populates it with stored field data.
  28. */
  29. void deserializeManagedInstance(const Vector<ManagedSerializableFieldDataPtr>& entries);
  30. void setFieldData(UINT32 arrayIdx, const ManagedSerializableFieldDataPtr& val);
  31. void addFieldData(const ManagedSerializableFieldDataPtr& val);
  32. ManagedSerializableFieldDataPtr getFieldData(UINT32 arrayIdx);
  33. UINT32 getLength() const;
  34. /************************************************************************/
  35. /* RTTI */
  36. /************************************************************************/
  37. static ManagedSerializableListPtr createEmpty();
  38. public:
  39. friend class ManagedSerializableListRTTI;
  40. static RTTITypeBase* getRTTIStatic();
  41. virtual RTTITypeBase* getRTTI() const;
  42. };
  43. }