CmResourceRTTI.h 996 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmRTTIType.h"
  4. #include "CmResource.h"
  5. namespace CamelotFramework
  6. {
  7. class CM_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& getUUID(Resource* obj) { return obj->mUUID; }
  13. void setUUID(Resource* obj, String& uuid) { obj->mUUID = uuid; }
  14. public:
  15. ResourceRTTI()
  16. {
  17. addPlainField("Size", 0, &ResourceRTTI::getSize, &ResourceRTTI::setSize);
  18. addPlainField("UUID", 1, &ResourceRTTI::getUUID, &ResourceRTTI::setUUID);
  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. CM_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
  32. }
  33. };
  34. }