2020-05-05 01:51:13 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "MinimalEngine.h"
|
|
|
|
|
|
|
|
|
|
namespace Seele
|
|
|
|
|
{
|
2023-01-29 18:58:59 +01:00
|
|
|
DECLARE_NAME_REF(Gfx, Graphics)
|
2020-05-05 01:51:13 +02:00
|
|
|
class Asset
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-06-02 11:46:18 +02:00
|
|
|
enum class Status
|
|
|
|
|
{
|
|
|
|
|
Uninitialized,
|
|
|
|
|
Loading,
|
|
|
|
|
Ready
|
|
|
|
|
};
|
2020-05-05 01:51:13 +02:00
|
|
|
Asset();
|
2020-06-02 11:46:18 +02:00
|
|
|
Asset(const std::string& directory, const std::string& name);
|
2020-06-08 01:44:47 +02:00
|
|
|
Asset(const std::filesystem::path& path);
|
2020-05-05 01:51:13 +02:00
|
|
|
virtual ~Asset();
|
2020-06-08 01:44:47 +02:00
|
|
|
|
2023-01-29 18:58:59 +01:00
|
|
|
virtual void save(Gfx::PGraphics graphics) = 0;
|
|
|
|
|
virtual void load(Gfx::PGraphics graphics) = 0;
|
2020-06-02 11:46:18 +02:00
|
|
|
|
|
|
|
|
// returns the name of the file, without extension
|
2020-09-19 14:36:50 +02:00
|
|
|
std::string getFileName() const;
|
2020-06-02 11:46:18 +02:00
|
|
|
// returns the full absolute path, from root to extension
|
2020-09-19 14:36:50 +02:00
|
|
|
std::string getFullPath() const;
|
2020-06-02 11:46:18 +02:00
|
|
|
// returns the file extension, without preceding dot
|
2020-09-19 14:36:50 +02:00
|
|
|
std::string getExtension() const;
|
2020-06-02 11:46:18 +02:00
|
|
|
inline Status getStatus()
|
|
|
|
|
{
|
2022-01-12 14:40:26 +01:00
|
|
|
std::scoped_lock lck(lock);
|
2020-06-02 11:46:18 +02:00
|
|
|
return status;
|
|
|
|
|
}
|
2022-11-15 12:19:11 +01:00
|
|
|
inline void setStatus(Status _status)
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
2022-01-12 14:40:26 +01:00
|
|
|
std::scoped_lock lck(lock);
|
2022-11-15 12:19:11 +01:00
|
|
|
status = _status;
|
2020-06-02 11:46:18 +02:00
|
|
|
}
|
|
|
|
|
protected:
|
|
|
|
|
std::mutex lock;
|
2022-04-13 13:01:35 +02:00
|
|
|
std::ifstream getReadStream() const;
|
|
|
|
|
std::ofstream getWriteStream() const;
|
2020-05-05 01:51:13 +02:00
|
|
|
private:
|
2020-09-19 14:36:50 +02:00
|
|
|
// Path relative to the project root
|
2020-06-02 11:46:18 +02:00
|
|
|
std::filesystem::path fullPath;
|
|
|
|
|
std::filesystem::path name;
|
2021-04-01 16:40:14 +02:00
|
|
|
std::filesystem::path parentDir;
|
2020-06-02 11:46:18 +02:00
|
|
|
std::filesystem::path extension;
|
2021-04-01 16:40:14 +02:00
|
|
|
Status status;
|
2020-06-02 11:46:18 +02:00
|
|
|
uint32 byteSize;
|
2020-05-05 01:51:13 +02:00
|
|
|
};
|
2021-04-01 16:40:14 +02:00
|
|
|
DEFINE_REF(Asset)
|
2020-05-05 01:51:13 +02:00
|
|
|
} // namespace Seele
|