MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / saveModel

Function saveModel

src/model/FileOperations.cpp:343–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341 }
342
343 bool saveModel(openstudio::model::Model model, const openstudio::path& osmPath, const openstudio::path& modelTempDir) {
344 // set the workflow's path
345 openstudio::path oswPath = modelTempDir / openstudio::toPath("resources/workflow.osw");
346 boost::optional<openstudio::path> currentOswPath = model.workflowJSON().oswPath();
347 if (!currentOswPath || (oswPath != currentOswPath.get())) {
348 model.workflowJSON().setOswPath(oswPath);
349 }
350
351 // set the seed name
352 openstudio::path seedFile = toPath("..") / osmPath.filename();
353 boost::optional<openstudio::path> currentSeedFile = model.workflowJSON().seedFile();
354 if (!currentSeedFile || (seedFile != currentSeedFile.get())) {
355 model.workflowJSON().setSeedFile(seedFile);
356 }
357
358 // save the osw, do before temp dirs get copied
359 model.workflowJSON().save();
360
361 // save osm to temp directory, saveModelTempDir will copy to real location
362 openstudio::path tempModelPath = modelTempDir / osmPath.filename();
363 bool modelSaved = model.save(tempModelPath, true);
364
365 if (modelSaved) {
366 LOG_FREE(Debug, "saveModel", "Saved model to '" << toString(tempModelPath) << "'");
367 } else {
368 LOG_FREE(Error, "saveModel", "Failed to save model to '" << toString(tempModelPath) << "'");
369 }
370
371 bool tempDirSaved = saveModelTempDir(modelTempDir, osmPath);
372
373 return (modelSaved && tempDirSaved);
374 }
375
376 void removeModelTempDir(const openstudio::path& modelTempDir) {
377 removeDir(modelTempDir);

Callers

nothing calls this directly

Calls 11

saveModelTempDirFunction · 0.85
oswPathMethod · 0.80
workflowJSONMethod · 0.80
setOswPathMethod · 0.80
filenameMethod · 0.80
seedFileMethod · 0.80
setSeedFileMethod · 0.80
toPathFunction · 0.50
toStringFunction · 0.50
getMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected