summaryrefslogtreecommitdiff
path: root/src/sim/serialize.cc
diff options
context:
space:
mode:
authorAli Saidi <Ali.Saidi@ARM.com>2011-02-11 18:29:35 -0600
committerAli Saidi <Ali.Saidi@ARM.com>2011-02-11 18:29:35 -0600
commitded4d319f275aa6e1518f760d67b9e0519b31565 (patch)
tree496c2a5227e780167e13beb6cdace41061fbe16a /src/sim/serialize.cc
parenta05032f4df8be28c0ceaefba03114f3e7a5f6ab4 (diff)
downloadgem5-ded4d319f275aa6e1518f760d67b9e0519b31565.tar.xz
Serialization: Allow serialization of stl lists
Diffstat (limited to 'src/sim/serialize.cc')
-rw-r--r--src/sim/serialize.cc56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index d28f335be..44fe7b2e7 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -201,6 +201,23 @@ arrayParamOut(ostream &os, const string &name, const vector<T> &param)
os << "\n";
}
+template <class T>
+void
+arrayParamOut(ostream &os, const string &name, const list<T> &param)
+{
+ typename list<T>::const_iterator it = param.begin();
+
+ os << name << "=";
+ if (param.size() > 0)
+ showParam(os, *it);
+ it++;
+ while (it != param.end()) {
+ os << " ";
+ showParam(os, *it);
+ it++;
+ }
+ os << "\n";
+}
template <class T>
void
@@ -326,6 +343,37 @@ arrayParamIn(Checkpoint *cp, const string &section,
}
}
+template <class T>
+void
+arrayParamIn(Checkpoint *cp, const string &section,
+ const string &name, list<T> &param)
+{
+ string str;
+ if (!cp->find(section, name, str)) {
+ fatal("Can't unserialize '%s:%s'\n", section, name);
+ }
+ param.clear();
+
+ vector<string> tokens;
+ tokenize(tokens, str, ' ');
+
+ for (vector<string>::size_type i = 0; i < tokens.size(); i++) {
+ T scalar_value = 0;
+ if (!parseParam(tokens[i], scalar_value)) {
+ string err("could not parse \"");
+
+ err += str;
+ err += "\"";
+
+ fatal(err);
+ }
+
+ // assign parsed value to vector
+ param.push_back(scalar_value);
+ }
+}
+
+
void
objParamIn(Checkpoint *cp, const string &section,
const string &name, SimObject * &param)
@@ -356,7 +404,13 @@ arrayParamOut(ostream &os, const string &name, \
const vector<type> &param); \
template void \
arrayParamIn(Checkpoint *cp, const string &section, \
- const string &name, vector<type> &param);
+ const string &name, vector<type> &param); \
+template void \
+arrayParamOut(ostream &os, const string &name, \
+ const list<type> &param); \
+template void \
+arrayParamIn(Checkpoint *cp, const string &section, \
+ const string &name, list<type> &param);
INSTANTIATE_PARAM_TEMPLATES(char)
INSTANTIATE_PARAM_TEMPLATES(signed char)