Implementing basic asset serialization

This commit is contained in:
Dynamitos
2023-02-13 14:56:13 +01:00
parent 9e1e4076f0
commit 48fa098546
82 changed files with 1834 additions and 423 deletions
+16 -23
View File
@@ -1,5 +1,6 @@
#pragma once
#include "MinimalEngine.h"
#include "Serialization/ArchiveBuffer.h"
namespace Seele
{
@@ -14,39 +15,31 @@ public:
Ready
};
Asset();
Asset(const std::string& directory, const std::string& name);
Asset(const std::filesystem::path& path);
Asset(std::string_view folderPath, std::string_view name);
virtual ~Asset();
virtual void save(Gfx::PGraphics graphics) = 0;
virtual void load(Gfx::PGraphics graphics) = 0;
virtual void save(ArchiveBuffer& buffer) const = 0;
virtual void load(ArchiveBuffer& buffer) = 0;
// returns the name of the file, without extension
std::string getFileName() const;
// returns the full absolute path, from root to extension
std::string getFullPath() const;
// returns the file extension, without preceding dot
std::string getExtension() const;
inline Status getStatus()
// returns the assets name
std::string getName() const;
// returns the (virtual) folder path
std::string getFolderPath() const;
// returns the identifier with which it can be found from the asset registry
std::string getAssetIdentifier() const;
constexpr Status getStatus()
{
std::scoped_lock lck(lock);
return status;
}
inline void setStatus(Status _status)
constexpr void setStatus(Status _status)
{
std::scoped_lock lck(lock);
status = _status;
}
protected:
std::mutex lock;
std::ifstream getReadStream() const;
std::ofstream getWriteStream() const;
private:
// Path relative to the project root
std::filesystem::path fullPath;
std::filesystem::path name;
std::filesystem::path parentDir;
std::filesystem::path extension;
std::string folderPath;
std::string name;
std::string assetId;
Status status;
uint32 byteSize;
};