From e30c62ad994a730b78361b5ecce45b97e58c0701 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 4 Jun 2009 21:41:46 -0700 Subject: [PATCH] style: cleanup style --- src/sim/serialize.cc | 88 ++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index 481b9af3b..f73fc93a3 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -171,7 +171,7 @@ Serializable::nameOut(ostream &os, const string &_name) template void -paramOut(ostream &os, const std::string &name, const T ¶m) +paramOut(ostream &os, const string &name, const T ¶m) { os << name << "="; showParam(os, param); @@ -180,8 +180,7 @@ paramOut(ostream &os, const std::string &name, const T ¶m) template void -arrayParamOut(ostream &os, const std::string &name, - const std::vector ¶m) +arrayParamOut(ostream &os, const string &name, const vector ¶m) { int size = param.size(); os << name << "="; @@ -197,10 +196,9 @@ arrayParamOut(ostream &os, const std::string &name, template void -paramIn(Checkpoint *cp, const std::string §ion, - const std::string &name, T ¶m) +paramIn(Checkpoint *cp, const string §ion, const string &name, T ¶m) { - std::string str; + string str; if (!cp->find(section, name, str) || !parseParam(str, param)) { fatal("Can't unserialize '%s:%s'\n", section, name); } @@ -209,8 +207,7 @@ paramIn(Checkpoint *cp, const std::string §ion, template void -arrayParamOut(ostream &os, const std::string &name, - const T *param, int size) +arrayParamOut(ostream &os, const string &name, const T *param, int size) { os << name << "="; if (size > 0) @@ -225,10 +222,10 @@ arrayParamOut(ostream &os, const std::string &name, template void -arrayParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, T *param, int size) +arrayParamIn(Checkpoint *cp, const string §ion, const string &name, + T *param, int size) { - std::string str; + string str; if (!cp->find(section, name, str)) { fatal("Can't unserialize '%s:%s'\n", section, name); } @@ -269,10 +266,10 @@ arrayParamIn(Checkpoint *cp, const std::string §ion, template void -arrayParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, std::vector ¶m) +arrayParamIn(Checkpoint *cp, const string §ion, + const string &name, vector ¶m) { - std::string str; + string str; if (!cp->find(section, name, str)) { fatal("Can't unserialize '%s:%s'\n", section, name); } @@ -312,8 +309,8 @@ arrayParamIn(Checkpoint *cp, const std::string §ion, void -objParamIn(Checkpoint *cp, const std::string §ion, - const std::string &name, SimObject * ¶m) +objParamIn(Checkpoint *cp, const string §ion, + const string &name, SimObject * ¶m) { if (!cp->findObj(section, name, param)) { fatal("Can't unserialize '%s:%s'\n", section, name); @@ -323,22 +320,22 @@ objParamIn(Checkpoint *cp, const std::string §ion, #define INSTANTIATE_PARAM_TEMPLATES(type) \ template void \ -paramOut(ostream &os, const std::string &name, type const ¶m); \ +paramOut(ostream &os, const string &name, type const ¶m); \ template void \ -paramIn(Checkpoint *cp, const std::string §ion, \ - const std::string &name, type & param); \ +paramIn(Checkpoint *cp, const string §ion, \ + const string &name, type & param); \ template void \ -arrayParamOut(ostream &os, const std::string &name, \ +arrayParamOut(ostream &os, const string &name, \ type const *param, int size); \ template void \ -arrayParamIn(Checkpoint *cp, const std::string §ion, \ - const std::string &name, type *param, int size); \ +arrayParamIn(Checkpoint *cp, const string §ion, \ + const string &name, type *param, int size); \ template void \ -arrayParamOut(ostream &os, const std::string &name, \ - const std::vector ¶m); \ +arrayParamOut(ostream &os, const string &name, \ + const vector ¶m); \ template void \ -arrayParamIn(Checkpoint *cp, const std::string §ion, \ - const std::string &name, std::vector ¶m); +arrayParamIn(Checkpoint *cp, const string §ion, \ + const string &name, vector ¶m); INSTANTIATE_PARAM_TEMPLATES(signed char) INSTANTIATE_PARAM_TEMPLATES(unsigned char) @@ -405,17 +402,17 @@ Serializable::~Serializable() } void -Serializable::serialize(std::ostream &os) +Serializable::serialize(ostream &os) { } void -Serializable::unserialize(Checkpoint *cp, const std::string §ion) +Serializable::unserialize(Checkpoint *cp, const string §ion) { } void -Serializable::serializeAll(const std::string &cpt_dir) +Serializable::serializeAll(const string &cpt_dir) { setCheckpointDir(cpt_dir); string dir = Checkpoint::dir(); @@ -434,7 +431,7 @@ Serializable::serializeAll(const std::string &cpt_dir) } void -Serializable::unserializeAll(const std::string &cpt_dir) +Serializable::unserializeAll(const string &cpt_dir) { setCheckpointDir(cpt_dir); string dir = Checkpoint::dir(); @@ -459,7 +456,7 @@ const char *Checkpoint::baseFilename = "m5.cpt"; static string checkpointDirBase; void -setCheckpointDir(const std::string &name) +setCheckpointDir(const string &name) { checkpointDirBase = name; if (checkpointDirBase[checkpointDirBase.size() - 1] != '/') @@ -476,7 +473,7 @@ Checkpoint::dir() } void -debug_serialize(const std::string &cpt_dir) +debug_serialize(const string &cpt_dir) { Serializable::serializeAll(cpt_dir); } @@ -492,32 +489,26 @@ debug_serialize(const std::string &cpt_dir) // Need to make this a pointer so we can force initialization on the // first reference; otherwise, some SerializableClass constructors // may be invoked before the classMap constructor. -map *SerializableClass::classMap = 0; +map *SerializableClass::classMap = 0; // SerializableClass constructor: add mapping to classMap SerializableClass::SerializableClass(const string &className, - CreateFunc createFunc) + CreateFunc createFunc) { if (classMap == NULL) - classMap = new map(); + classMap = new map(); if ((*classMap)[className]) - { - cerr << "Error: simulation object class " << className << " redefined" - << endl; - fatal(""); - } + fatal("Error: simulation object class %s redefined\n", className); // add className --> createFunc to class map (*classMap)[className] = createFunc; } - // // Serializable * -SerializableClass::createObject(Checkpoint *cp, - const std::string §ion) +SerializableClass::createObject(Checkpoint *cp, const string §ion) { string className; @@ -542,7 +533,7 @@ SerializableClass::createObject(Checkpoint *cp, Serializable * -Serializable::create(Checkpoint *cp, const std::string §ion) +Serializable::create(Checkpoint *cp, const string §ion) { Serializable *object = SerializableClass::createObject(cp, section); object->unserialize(cp, section); @@ -550,7 +541,7 @@ Serializable::create(Checkpoint *cp, const std::string §ion) } -Checkpoint::Checkpoint(const std::string &cpt_dir, const std::string &path) +Checkpoint::Checkpoint(const string &cpt_dir, const string &path) : db(new IniFile), basePath(path), cptDir(cpt_dir) { string filename = cpt_dir + "/" + Checkpoint::baseFilename; @@ -561,15 +552,14 @@ Checkpoint::Checkpoint(const std::string &cpt_dir, const std::string &path) bool -Checkpoint::find(const std::string §ion, const std::string &entry, - std::string &value) +Checkpoint::find(const string §ion, const string &entry, string &value) { return db->find(section, entry, value); } bool -Checkpoint::findObj(const std::string §ion, const std::string &entry, +Checkpoint::findObj(const string §ion, const string &entry, SimObject *&value) { string path; @@ -583,7 +573,7 @@ Checkpoint::findObj(const std::string §ion, const std::string &entry, bool -Checkpoint::sectionExists(const std::string §ion) +Checkpoint::sectionExists(const string §ion) { return db->sectionExists(section); } -- 2.30.2