BsResource.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsIReflectable.h"
  6. #include "BsCoreObject.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Resources
  10. * @{
  11. */
  12. /** Base class for all resources. */
  13. class BS_CORE_EXPORT Resource : public IReflectable, public CoreObject
  14. {
  15. public:
  16. Resource(bool requiresGpuInitialization = true);
  17. virtual ~Resource() {};
  18. /** Returns the name of the resource. */
  19. const WString& getName() const;
  20. /** Sets the name of the resource. */
  21. void setName(const WString& name);
  22. /** Retrieves meta-data containing various information describing a resource. */
  23. SPtr<ResourceMetaData> getMetaData() const { return mMetaData; }
  24. /** Returns whether or not this resource is allowed to be asynchronously loaded. */
  25. virtual bool allowAsyncLoading() const { return true; }
  26. protected:
  27. friend class Resources;
  28. friend class ResourceHandleBase;
  29. /** Retrieves a list of all resources that this resource depends on. */
  30. virtual void getResourceDependencies(FrameVector<HResource>& dependencies) const { }
  31. /** Checks if all the resources this object is dependent on are fully loaded. */
  32. bool areDependenciesLoaded() const;
  33. UINT32 mSize;
  34. SPtr<ResourceMetaData> mMetaData;
  35. /**
  36. * Signal to the resource implementation if original data should be kept in memory. This is sometimes needed if
  37. * the resource destroys original data during normal usage, but it might still be required for special purposes
  38. * (like saving in the editor).
  39. */
  40. bool mKeepSourceData;
  41. /************************************************************************/
  42. /* SERIALIZATION */
  43. /************************************************************************/
  44. public:
  45. friend class ResourceRTTI;
  46. static RTTITypeBase* getRTTIStatic();
  47. RTTITypeBase* getRTTI() const override;
  48. };
  49. /** @} */
  50. }