BsMonoField.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsMonoPrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Mono
  8. * @{
  9. */
  10. /**
  11. * Encapsulates information about a single Mono (managed) field belonging to some managed class. This object also
  12. * allows you to set or retrieve values to/from specific instances containing the field.
  13. */
  14. class BS_MONO_EXPORT MonoField
  15. {
  16. public:
  17. /** Returns the name of the field. */
  18. const String& getName() const { return mName; }
  19. /** Returns the class representing the type of data the field holds. */
  20. MonoClass* getType();
  21. /**
  22. * Retrieves value currently set in the field on the specified object instance. If field is static object instance
  23. * can be null.
  24. *
  25. * @note
  26. * Value will be a pointer to raw data type for value types (for example int, float), and a MonoObject* for
  27. * reference types.
  28. */
  29. void getValue(MonoObject* instance, void* outValue);
  30. /**
  31. * Retrieves value currently set in the field on the specified object instance. If field is static object instance
  32. * can be null. If returned value is a value type it will be boxed.
  33. */
  34. MonoObject* getValueBoxed(MonoObject* instance);
  35. /**
  36. * Sets a value for the field on the specified object instance. If field is static object instance can be null.
  37. *
  38. * @note
  39. * Value should be a pointer to raw data type for value types (for example int, float), and a MonoObject* for
  40. * reference types.
  41. */
  42. void setValue(MonoObject* instance, void* value);
  43. /** Checks if field has an attribute of the specified type. */
  44. bool hasAttribute(MonoClass* monoClass);
  45. /**
  46. * Returns an instance of an attribute of the specified type. Returns null if the field doesn't have such an
  47. * attribute.
  48. */
  49. MonoObject* getAttribute(MonoClass* monoClass);
  50. /** Returns field visibility in the class. */
  51. MonoMemberVisibility getVisibility();
  52. /** Query if the field is static. */
  53. bool isStatic();
  54. private:
  55. friend class MonoClass;
  56. MonoField(MonoClassField* field);
  57. String mName;
  58. MonoClassField* mField;
  59. MonoClass* mFieldType;
  60. };
  61. /** @} */
  62. }