Asset.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // the .fbx, .png, etc path, attempts to load .asset, creates missing .asset
  18. bool SetPath(const String& path);
  19. const String& GetGUID() const { return guid_; }
  20. const String& GetName() const { return name_; }
  21. const String& GetPath() const { return path_; }
  22. String GetCachePath() const;
  23. unsigned GetTimestamp() const { return timestamp_; }
  24. const StringHash GetImporterType() { return importer_.Null() ? String::EMPTY : importer_->GetType(); }
  25. const String& GetImporterTypeName() { return importer_.Null() ? String::EMPTY : importer_->GetTypeName(); }
  26. AssetImporter* GetImporter() { return importer_; }
  27. void SetDirty(bool dirty) { dirty_ = dirty; }
  28. bool IsDirty() const { return dirty_; }
  29. // get the .asset filename
  30. String GetDotAssetFilename();
  31. bool IsFolder() const { return isFolder_; }
  32. private:
  33. // load .asset
  34. bool Load();
  35. // save .asset
  36. bool Save();
  37. bool CreateImporter();
  38. bool CheckCacheFile();
  39. String guid_;
  40. // can change
  41. String path_;
  42. String name_;
  43. unsigned timestamp_;
  44. bool dirty_;
  45. bool isFolder_;
  46. SharedPtr<JSONFile> json_;
  47. SharedPtr<AssetImporter> importer_;
  48. };
  49. }