BsResourceRTTI.h 966 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsRTTIType.h"
  4. #include "BsResource.h"
  5. namespace BansheeEngine
  6. {
  7. class BS_CORE_EXPORT ResourceRTTI : public RTTIType<Resource, IReflectable, ResourceRTTI>
  8. {
  9. private:
  10. UINT32& getSize(Resource* obj) { return obj->mSize; }
  11. void setSize(Resource* obj, UINT32& size) { obj->mSize = size; }
  12. String& getName(Resource* obj) { return obj->mName; }
  13. void setName(Resource* obj, String& name) { obj->mName = name; }
  14. public:
  15. ResourceRTTI()
  16. {
  17. addPlainField("mSize", 0, &ResourceRTTI::getSize, &ResourceRTTI::setSize);
  18. addPlainField("mName", 1, &ResourceRTTI::getName, &ResourceRTTI::setName);
  19. }
  20. virtual const String& getRTTIName()
  21. {
  22. static String name = "Resource";
  23. return name;
  24. }
  25. virtual UINT32 getRTTIId()
  26. {
  27. return 100;
  28. }
  29. virtual std::shared_ptr<IReflectable> newRTTIObject()
  30. {
  31. BS_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
  32. }
  33. };
  34. }