BsResource.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. virtual void getResourceDependencies(FrameVector<HResource>& dependencies) const { }
  38. /**
  39. * @brief Checks if all the resources this object is dependent on are fully loaded.
  40. */
  41. bool areDependenciesLoaded() const;
  42. UINT32 mSize;
  43. ResourceMetaDataPtr mMetaData;
  44. /************************************************************************/
  45. /* SERIALIZATION */
  46. /************************************************************************/
  47. public:
  48. friend class ResourceRTTI;
  49. static RTTITypeBase* getRTTIStatic();
  50. virtual RTTITypeBase* getRTTI() const override;
  51. };
  52. }