CmResourceRefRTTI.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmRTTIType.h"
  4. #include "CmResourceRef.h"
  5. namespace CamelotEngine
  6. {
  7. class CM_EXPORT ResourceRefDataRTTI : public RTTIType<ResourceRefData, IReflectable, ResourceRefDataRTTI>
  8. {
  9. private:
  10. String& getUUID(ResourceRefData* obj) { return obj->mUUID; }
  11. void setUUID(ResourceRefData* obj, String& uuid)
  12. {
  13. obj->mUUID = uuid;
  14. if(uuid != "")
  15. {
  16. // TODO - I probably want to load the resource here
  17. // - Important: consider that user might just want to load the level meta data and not the actual resources
  18. // (Maybe he wants to stream them in as player goes through the world?)
  19. // - Although this should probably be handled on a higher level. Here we just load.
  20. }
  21. }
  22. public:
  23. ResourceRefDataRTTI()
  24. {
  25. addPlainField("mUUID", 0, &ResourceRefDataRTTI::getUUID, &ResourceRefDataRTTI::setUUID);
  26. }
  27. virtual const String& getRTTIName()
  28. {
  29. static String name = "ResourceRefData";
  30. return name;
  31. }
  32. virtual UINT32 getRTTIId()
  33. {
  34. return TID_ResourceRefData;
  35. }
  36. virtual std::shared_ptr<IReflectable> newRTTIObject()
  37. {
  38. return std::shared_ptr<ResourceRefData>(new ResourceRefData());
  39. }
  40. };
  41. class CM_EXPORT ResourceRefRTTI : public RTTIType<ResourceRefBase, IReflectable, ResourceRefRTTI>
  42. {
  43. private:
  44. std::shared_ptr<ResourceRefData> getResData(ResourceRefBase* obj) { return obj->mData; }
  45. void setResData(ResourceRefBase* obj, std::shared_ptr<ResourceRefData> val) { obj->mData = val; }
  46. public:
  47. ResourceRefRTTI()
  48. {
  49. addReflectablePtrField("mData", 0, &ResourceRefRTTI::getResData, &ResourceRefRTTI::setResData);
  50. }
  51. virtual const String& getRTTIName()
  52. {
  53. static String name = "ResourceRefBase";
  54. return name;
  55. }
  56. virtual UINT32 getRTTIId()
  57. {
  58. return TID_ResourceRef;
  59. }
  60. virtual std::shared_ptr<IReflectable> newRTTIObject()
  61. {
  62. return std::shared_ptr<ResourceRefBase>(new ResourceRefBase());
  63. }
  64. };
  65. }