# Deals with resuming simulation from saved files # Resume.tz (c) 2010 Jacob Schrum. # See Simulation.tz for more copyright information @include "Abstract.tz". @include "File.tz". Abstract : Resume { + variables: resume (int). # Trivial archiving, since state is simple + to archive: return 1. + to dearchive: return 1. + to init: resume = 0. + to signal-resume: resume = 1. + to is-resuming: return resume. + to read-auto-resume-info: handle (object). print "Reading auto-resume info". handle = new File. handle open-for-reading with-file ((controller get-commandline) string-param named "auto-resume"). controller set-last-path-saved to (handle read-line). controller set-last-file-saved to (handle read-line). handle close. + to create-auto-resume-file named file (string): handle (object). print "Create auto-resume file: $file". handle = new File. handle open-for-writing with-file file. handle write-line text ((controller get-commandline) string-param named "last-path-saved"). handle write-line text ((controller get-commandline) string-param named "last-file-saved"). handle close. }