void GraphIO::loadGraphFrom(const YAML::Node& doc) { TimerPtr timer = getProfiler()->getTimer("load graph"); timer->restart(); SemanticVersion version; if(doc["version"].IsDefined()) { version = doc["version"].as<SemanticVersion>(); } else { // with 0.9.7 versioning was introduced, so assume that the version was 0.9.6 version = SemanticVersion(0, 9, 6); } graph_.getLocalGraph()->beginTransaction(); { auto interlude = timer->step("load nodes"); loadNodes(doc, version); } { auto interlude = timer->step("load connections"); loadConnections(doc, version); } graph_.getLocalGraph()->finalizeTransaction(); { auto interlude = timer->step("load view"); loadViewRequest(graph_, doc); } timer->finish(); }
void GraphIO::loadNodes(const YAML::Node& doc, SemanticVersion version) { TimerPtr timer = getProfiler()->getTimer("load graph"); YAML::Node nodes = doc["nodes"]; if (nodes.IsDefined()) { for (std::size_t i = 0, total = nodes.size(); i < total; ++i) { const YAML::Node& n = nodes[i]; auto interlude = timer->step(n["uuid"].as<std::string>()); loadNode(n, version); } } }
void GraphIO::saveGraphTo(YAML::Node& yaml) { TimerPtr timer = getProfiler()->getTimer("save graph"); timer->restart(); yaml["version"] = csapex::info::CSAPEX_VERSION; saveNodes(yaml); saveConnections(yaml); { auto interlude = timer->step("save view"); saveViewRequest(graph_, yaml); } timer->finish(); }