Asset.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <Atomic/Core/Object.h>
  3. #include "AssetImporter.h"
  4. using namespace Atomic;
  5. namespace ToolCore
  6. {
  7. #define ASSET_VERSION 1
  8. class Asset : public Object
  9. {
  10. friend class AssetDatabase;
  11. OBJECT(Asset);
  12. public:
  13. /// Construct.
  14. Asset(Context* context);
  15. virtual ~Asset();
  16. bool Import();
  17. bool Preload();
  18. // the .fbx, .png, etc path, attempts to load .asset, creates missing .asset
  19. bool SetPath(const String& path);
  20. const String& GetGUID() const { return guid_; }
  21. const String& GetName() const { return name_; }
  22. const String& GetPath() const { return path_; }
  23. String GetCachePath() const;
  24. unsigned GetTimestamp() const { return timestamp_; }
  25. const StringHash GetImporterType() { return importer_.Null() ? String::EMPTY : importer_->GetType(); }
  26. const String& GetImporterTypeName() { return importer_.Null() ? String::EMPTY : importer_->GetTypeName(); }
  27. AssetImporter* GetImporter() { return importer_; }
  28. void SetDirty(bool dirty) { dirty_ = dirty; }
  29. bool IsDirty() const { return dirty_; }
  30. // get the .asset filename
  31. String GetDotAssetFilename();
  32. bool IsFolder() const { return isFolder_; }
  33. // load .asset
  34. bool Load();
  35. // save .asset
  36. bool Save();
  37. private:
  38. bool CreateImporter();
  39. bool CheckCacheFile();
  40. String guid_;
  41. // can change
  42. String path_;
  43. String name_;
  44. unsigned timestamp_;
  45. bool dirty_;
  46. bool isFolder_;
  47. SharedPtr<JSONFile> json_;
  48. SharedPtr<AssetImporter> importer_;
  49. };
  50. }