feat: started on implementing asset system (expecting to revert later)

main
Sara 2024-11-26 11:16:06 +01:00
parent 95880f8530
commit 99db3cd951
2 changed files with 24 additions and 4 deletions

View File

@ -0,0 +1,9 @@
#include "asset_wrapper.h"
#include <filesystem>
namespace ce {
AssetPtrBase::AssetPtrBase(std::filesystem::path const &path)
: path{path} {
this->path.c_str();
}
}

View File

@ -3,17 +3,24 @@
#include <memory>
#include <vector>
#include <filesystem>
namespace ce {
class AssetPtrBase {
std::string path{};
std::string name{};
std::filesystem::path path{};
protected:
AssetPtrBase(std::filesystem::path const &path);
public:
virtual ~AssetPtrBase() = default;
virtual bool request_unload() = 0;
virtual void load() = 0;
virtual bool is_loaded() const = 0;
std::filesystem::path const &get_path() const;
};
template <class AssetType>
class AssetPtr {
std::shared_ptr<AssetType> asset;
class AssetPtr : public AssetPtrBase {
std::shared_ptr<AssetType> *asset{nullptr};
public:
AssetPtr();
virtual ~AssetPtr();
@ -22,7 +29,11 @@ public:
class AssetDB {
std::vector<std::unique_ptr<AssetPtrBase>> assets;
public:
AssetDB();
~AssetDB() = default;
template <class AssetType> std::shared_ptr<AssetType> load_asset();
};
}
#endif // !CANVAS_ASSET_WRAPPER_HPP