Files
Destrum/destrum/include/destrum/Serialization/SceneSerializer.h
T

39 lines
1.2 KiB
C++

#ifndef DESTRUM_SCENESERIALIZER_H
#define DESTRUM_SCENESERIALIZER_H
#include <filesystem>
#include <functional>
#include <future>
#include <nlohmann/json.hpp>
class Scene;
class SceneSerializer final {
public:
struct LoadResult {
bool success{false};
std::string errorMessage;
nlohmann::json root;
};
static bool Save(Scene& scene, const std::filesystem::path& path);
static bool Load(Scene& scene, const std::filesystem::path& path,
std::function<void(float)> progressCallback = nullptr);
// Thread-safe: parse and validate a scene file on any thread.
// No engine state is touched during parsing.
static LoadResult LoadSceneFile(const std::filesystem::path& path);
// Main-thread-only: construct a scene from pre-validated JSON.
static bool ConstructScene(Scene& scene, LoadResult& result,
std::function<void(float)> progressCallback = nullptr);
// Parse the scene file on a background thread. Call LoadFromJson on the
// main thread once the future is ready.
static std::future<LoadResult> LoadSceneFileAsync(const std::filesystem::path& path);
};
#endif //DESTRUM_SCENESERIALIZER_H