BsResource.h 1.6 KB

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