CmResources.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmModule.h"
  4. #include "CmUUID.h"
  5. namespace CamelotEngine
  6. {
  7. class Resources : public Module<Resources>
  8. {
  9. public:
  10. /**
  11. * @brief Constructor.
  12. *
  13. * @param assetDatabasePath Pathname of the asset database file. Path should not include file extension.
  14. * If the database file doesn't exist it will be created in that location.
  15. * Meta data for resources is stored in the asset database.
  16. */
  17. Resources();
  18. ~Resources();
  19. /**
  20. * @brief Loads the resource from a given path. Returns null if resource can't be loaded.
  21. *
  22. * @param filePath The path of the file to load. The file is searched for in
  23. * the AssetDatabase first, and if it cannot be found it is
  24. * loaded as a temporary resource object. You can't save
  25. * references to temporary resource objects because they won't
  26. * persist after application shut-down, but otherwise they act
  27. * the same as normal resources.
  28. *
  29. * @return Loaded resource, or null if it cannot be found.
  30. */
  31. ResourcePtr load(const String& filePath);
  32. /**
  33. * @brief Loads the resource with the given uuid.
  34. *
  35. * @param uuid UUID of the resource to load.
  36. *
  37. * @return Loaded resource, or null if it cannot be found.
  38. */
  39. ResourcePtr load(const UUID& uuid);
  40. /**
  41. * @brief Saves the resource at the specified location.
  42. *
  43. * @param resource The resource.
  44. * @param filePath Full pathname of the file.
  45. */
  46. void save(ResourcePtr resource, const String& filePath);
  47. };
  48. CM_EXPORT Resources& gResources();
  49. }