Files
Seele/src/Engine/Asset/Asset.h
T

54 lines
1.2 KiB
C++
Raw Normal View History

2020-05-05 01:51:13 +02:00
#pragma once
#include "MinimalEngine.h"
namespace Seele
{
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
virtual void save() = 0;
virtual void load() = 0;
2020-06-02 11:46:18 +02:00
// returns the name of the file, without extension
std::string getFileName();
// returns the full absolute path, from root to extension
std::string getFullPath();
// returns the file extension, without preceding dot
std::string getExtension();
inline Status getStatus()
{
std::scoped_lock lck(lock);
return status;
}
inline void setStatus(Status status)
{
std::scoped_lock lck(lock);
this->status = status;
}
protected:
std::mutex lock;
2020-06-08 01:44:47 +02:00
std::ifstream& getReadStream();
std::ofstream& getWriteStream();
2020-05-05 01:51:13 +02:00
private:
2020-06-02 11:46:18 +02:00
Status status;
std::filesystem::path fullPath;
std::filesystem::path parentDir;
std::filesystem::path name;
std::filesystem::path extension;
uint32 byteSize;
std::ifstream inStream;
std::ofstream outStream;
2020-05-05 01:51:13 +02:00
};
DEFINE_REF(Asset);
} // namespace Seele