summaryrefslogtreecommitdiff
path: root/src/sim/serialize.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/serialize.cc')
-rw-r--r--src/sim/serialize.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index 5ae9128e5..0e6d9b254 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -204,6 +204,18 @@ paramIn(Checkpoint *cp, const string &section, const string &name, T &param)
}
}
+template <class T>
+bool
+optParamIn(Checkpoint *cp, const string &section, const string &name, T &param)
+{
+ string str;
+ if (!cp->find(section, name, str) || !parseParam(str, param)) {
+ warn("optional parameter %s:%s not present\n", section, name);
+ return false;
+ } else {
+ return true;
+ }
+}
template <class T>
void
@@ -322,6 +334,9 @@ paramOut(ostream &os, const string &name, type const &param); \
template void \
paramIn(Checkpoint *cp, const string &section, \
const string &name, type & param); \
+template bool \
+optParamIn(Checkpoint *cp, const string &section, \
+ const string &name, type & param); \
template void \
arrayParamOut(ostream &os, const string &name, \
type const *param, unsigned size); \
@@ -422,7 +437,7 @@ Serializable::serializeAll(const string &cpt_dir)
time_t t = time(NULL);
if (!outstream.is_open())
fatal("Unable to open file %s for writing\n", cpt_file.c_str());
- outstream << "// checkpoint generated: " << ctime(&t);
+ outstream << "## checkpoint generated: " << ctime(&t);
globals.serialize(outstream);
SimObject::serializeAll(outstream);