* Steve Reinhardt
*/
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
+#include <cerrno>
#include <fstream>
#include <list>
#include <string>
os << "\n";
}
+template <class T>
+void
+arrayParamOut(ostream &os, const string &name, const list<T> ¶m)
+{
+ 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
// for which operator[] returns a special reference class
// that's not the same as 'bool&', (since it's a packed
// vector)
- T scalar_value;
+ T scalar_value = 0;
if (!parseParam(tokens[i], scalar_value)) {
string err("could not parse \"");
// for which operator[] returns a special reference class
// that's not the same as 'bool&', (since it's a packed
// vector)
- T scalar_value;
+ T scalar_value = 0;
if (!parseParam(tokens[i], scalar_value)) {
string err("could not parse \"");
}
}
+template <class T>
+void
+arrayParamIn(Checkpoint *cp, const string §ion,
+ const string &name, list<T> ¶m)
+{
+ 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 §ion,
const string &name, SimObject * ¶m)
const vector<type> ¶m); \
template void \
arrayParamIn(Checkpoint *cp, const string §ion, \
- const string &name, vector<type> ¶m);
+ const string &name, vector<type> ¶m); \
+template void \
+arrayParamOut(ostream &os, const string &name, \
+ const list<type> ¶m); \
+template void \
+arrayParamIn(Checkpoint *cp, const string §ion, \
+ const string &name, list<type> ¶m);
INSTANTIATE_PARAM_TEMPLATES(char)
INSTANTIATE_PARAM_TEMPLATES(signed char)
Globals::serialize(ostream &os)
{
nameOut(os);
- SERIALIZE_SCALAR(curTick);
+ paramOut(os, "curTick", curTick());
nameOut(os, "MainEventQueue");
mainEventQueue.serialize(os);
Globals::unserialize(Checkpoint *cp)
{
const string §ion = name();
- UNSERIALIZE_SCALAR(curTick);
+ Tick tick;
+ paramIn(cp, section, "curTick", tick);
+ curTick(tick);
mainEventQueue.unserialize(cp, "MainEventQueue");
}
string
Checkpoint::setDir(const string &name)
{
- // use csprintf to insert curTick into directory name if it
+ // use csprintf to insert curTick() into directory name if it
// appears to have a format placeholder in it.
currentDirectory = (name.find("%") != string::npos) ?
- csprintf(name, curTick) : name;
+ csprintf(name, curTick()) : name;
if (currentDirectory[currentDirectory.size() - 1] != '/')
currentDirectory += "/";
return currentDirectory;