44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <filesystem>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
namespace metacore::engine::assets {
|
|
|
|
struct AssetRecord {
|
|
std::string id;
|
|
std::string type;
|
|
std::string relative_path;
|
|
};
|
|
|
|
class AssetDatabase {
|
|
public:
|
|
std::map<std::string, AssetRecord>& records();
|
|
const std::map<std::string, AssetRecord>& records() const;
|
|
|
|
bool save(const std::filesystem::path& asset_db_file) const;
|
|
bool load(const std::filesystem::path& asset_db_file);
|
|
|
|
private:
|
|
std::map<std::string, AssetRecord> records_;
|
|
};
|
|
|
|
class AssetService {
|
|
public:
|
|
void ensure_default_asset_tree(const std::filesystem::path& project_root) const;
|
|
std::string ensure_asset_record(
|
|
AssetDatabase& asset_database,
|
|
const std::string& type,
|
|
const std::filesystem::path& relative_path
|
|
) const;
|
|
bool write_meta_file(
|
|
const std::filesystem::path& project_root,
|
|
const std::filesystem::path& relative_path,
|
|
const std::string& asset_id,
|
|
const std::string& type
|
|
) const;
|
|
};
|
|
|
|
} // namespace metacore::engine::assets
|