BsResource.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsIReflectable.h"
  4. #include "BsCoreObject.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Base class for all resources.
  9. */
  10. class BS_CORE_EXPORT Resource : public IReflectable, public CoreObject
  11. {
  12. public:
  13. Resource(bool requiresGpuInitialization = true);
  14. virtual ~Resource() {};
  15. /**
  16. * @brief Returns the name of the resource.
  17. */
  18. const WString& getName() const;
  19. /**
  20. * @brief Sets the name of the resource.
  21. */
  22. void setName(const WString& name);
  23. /**
  24. * @brief Retrieves meta-data containing various information describing a resource.
  25. */
  26. ResourceMetaDataPtr getMetaData() const { return mMetaData; }
  27. /**
  28. * @brief Returns whether or not this resource is allowed to be asynchronously loaded.
  29. */
  30. virtual bool allowAsyncLoading() const { return true; }
  31. protected:
  32. friend class Resources;
  33. friend class ResourceHandleBase;
  34. /**
  35. * @brief Retrieves a list of all resources that this resource depends on.
  36. *
  37. * TODO - Consider using a stack-allocated data type since returned data is almost
  38. * always transient. Then we can save on memory allocations.
  39. */
  40. virtual void getResourceDependencies(FrameVector<HResource>& dependencies) const { }
  41. /**
  42. * @brief Checks if all the resources this object is dependent on are fully loaded.
  43. */
  44. bool areDependenciesLoaded() const;
  45. UINT32 mSize;
  46. ResourceMetaDataPtr mMetaData;
  47. /************************************************************************/
  48. /* SERIALIZATION */
  49. /************************************************************************/
  50. public:
  51. friend class ResourceRTTI;
  52. static RTTITypeBase* getRTTIStatic();
  53. virtual RTTITypeBase* getRTTI() const;
  54. };
  55. }