combiner.md

This commit is contained in:
JohannesItten
2026-07-09 15:49:35 +03:00
parent d2095d14d3
commit 3820d0eeb7
3 changed files with 167 additions and 7 deletions
+12 -1
View File
@@ -38,7 +38,9 @@ struct NodeProcess {
class StudioManager {
public:
StudioManager(fs::path bin_dir, std::string domain)
: bin_dir_(std::move(bin_dir)), domain_(std::move(domain)) {}
: bin_dir_(std::move(bin_dir))
, domain_(std::move(domain))
, save_path_(bin_dir_ / "last_graph.json") {}
~StudioManager() { shutdown(); }
@@ -53,6 +55,7 @@ public:
garbage_collect_locked();
try {
graph_ = parse_graph(graph_json);
save_graph_locked(graph_json);
start_all_locked();
} catch (const std::exception& e) {
err = e.what();
@@ -140,6 +143,7 @@ public:
private:
fs::path bin_dir_;
std::string domain_;
fs::path save_path_;
FlowGraph graph_;
std::vector<NodeProcess> processes_;
std::mutex mutex_;
@@ -235,6 +239,13 @@ private:
if (changed) notify(s);
}
void save_graph_locked(const nlohmann::json& j) {
std::ofstream f(save_path_);
if (f) f << j.dump(2);
else fprintf(stderr, "[studio-manager] warning: could not save graph to %s\n",
save_path_.c_str());
}
// ── static helpers ───────────────────────────────────────────────────────
static FlowGraph parse_graph(const nlohmann::json& j) {