#include <string>
#include <vector>
+#include "base/annotate.hh"
#include "base/inifile.hh"
#include "base/misc.hh"
#include "base/output.hh"
os << "\n";
}
+template <class T>
+void
+arrayParamOut(ostream &os, const std::string &name,
+ const std::vector<T> ¶m)
+{
+ int size = param.size();
+ os << name << "=";
+ if (size > 0)
+ showParam(os, param[0]);
+ for (int i = 1; i < size; ++i) {
+ os << " ";
+ showParam(os, param[i]);
+ }
+ os << "\n";
+}
+
template <class T>
void
}
}
+template <class T>
+void
+arrayParamIn(Checkpoint *cp, const std::string §ion,
+ const std::string &name, std::vector<T> ¶m)
+{
+ std::string str;
+ if (!cp->find(section, name, str)) {
+ fatal("Can't unserialize '%s:%s'\n", section, name);
+ }
+
+ // code below stolen from VectorParam<T>::parse().
+ // it would be nice to unify these somehow...
+
+ vector<string> tokens;
+
+ tokenize(tokens, str, ' ');
+
+ // Need this if we were doing a vector
+ // value.resize(tokens.size());
+
+ param.resize(tokens.size());
+
+ for (int i = 0; i < tokens.size(); i++) {
+ // need to parse into local variable to handle vector<bool>,
+ // for which operator[] returns a special reference class
+ // that's not the same as 'bool&', (since it's a packed
+ // vector)
+ T scalar_value;
+ if (!parseParam(tokens[i], scalar_value)) {
+ string err("could not parse \"");
+
+ err += str;
+ err += "\"";
+
+ fatal(err);
+ }
+
+ // assign parsed value to vector
+ param[i] = scalar_value;
+ }
+}
+
+
void
objParamIn(Checkpoint *cp, const std::string §ion,
type const *param, int size); \
template void \
arrayParamIn(Checkpoint *cp, const std::string §ion, \
- const std::string &name, type *param, int size);
+ const std::string &name, type *param, int size); \
+template void \
+arrayParamOut(ostream &os, const std::string &name, \
+ const std::vector<type> ¶m); \
+template void \
+arrayParamIn(Checkpoint *cp, const std::string §ion, \
+ const std::string &name, std::vector<type> ¶m);
INSTANTIATE_PARAM_TEMPLATES(signed char)
INSTANTIATE_PARAM_TEMPLATES(unsigned char)
outstream << "// checkpoint generated: " << ctime(&t);
globals.serialize(outstream);
+ Annotate::annotations.serialize(outstream);
SimObject::serializeAll(outstream);
}
dir);
Checkpoint *cp = new Checkpoint(dir, section);
unserializeGlobals(cp);
-
+ Annotate::annotations.unserialize(cp);
SimObject::unserializeAll(cp);
}
#include <list>
+#include <vector>
#include <iostream>
#include <map>
void arrayParamOut(std::ostream &os, const std::string &name,
const T *param, int size);
+template <class T>
+void arrayParamOut(std::ostream &os, const std::string &name,
+ const std::vector<T> ¶m);
+
template <class T>
void arrayParamIn(Checkpoint *cp, const std::string §ion,
const std::string &name, T *param, int size);
+template <class T>
+void arrayParamIn(Checkpoint *cp, const std::string §ion,
+ const std::string &name, std::vector<T> ¶m);
+
void
objParamIn(Checkpoint *cp, const std::string §ion,
const std::string &name, SimObject * ¶m);