Deleted Added
sdiff udiff text old ( 4762:c94e103c83ad ) new ( 4841:89a9419e7361 )
full compact
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 26 unchanged lines hidden (view full) ---

35#include <sys/stat.h>
36#include <errno.h>
37
38#include <fstream>
39#include <list>
40#include <string>
41#include <vector>
42
43#include "base/inifile.hh"
44#include "base/misc.hh"
45#include "base/output.hh"
46#include "base/str.hh"
47#include "base/trace.hh"
48#include "sim/eventq.hh"
49#include "sim/serialize.hh"
50#include "sim/sim_events.hh"

--- 122 unchanged lines hidden (view full) ---

173void
174paramOut(ostream &os, const std::string &name, const T &param)
175{
176 os << name << "=";
177 showParam(os, param);
178 os << "\n";
179}
180
181
182template <class T>
183void
184paramIn(Checkpoint *cp, const std::string &section,
185 const std::string &name, T &param)
186{
187 std::string str;
188 if (!cp->find(section, name, str) || !parseParam(str, param)) {
189 fatal("Can't unserialize '%s:%s'\n", section, name);

--- 56 unchanged lines hidden (view full) ---

246 fatal(err);
247 }
248
249 // assign parsed value to vector
250 param[i] = scalar_value;
251 }
252}
253
254
255void
256objParamIn(Checkpoint *cp, const std::string &section,
257 const std::string &name, SimObject * &param)
258{
259 if (!cp->findObj(section, name, param)) {
260 fatal("Can't unserialize '%s:%s'\n", section, name);
261 }
262}

--- 5 unchanged lines hidden (view full) ---

268template void \
269paramIn(Checkpoint *cp, const std::string &section, \
270 const std::string &name, type & param); \
271template void \
272arrayParamOut(ostream &os, const std::string &name, \
273 type const *param, int size); \
274template void \
275arrayParamIn(Checkpoint *cp, const std::string &section, \
276 const std::string &name, type *param, int size);
277
278INSTANTIATE_PARAM_TEMPLATES(signed char)
279INSTANTIATE_PARAM_TEMPLATES(unsigned char)
280INSTANTIATE_PARAM_TEMPLATES(signed short)
281INSTANTIATE_PARAM_TEMPLATES(unsigned short)
282INSTANTIATE_PARAM_TEMPLATES(signed int)
283INSTANTIATE_PARAM_TEMPLATES(unsigned int)
284INSTANTIATE_PARAM_TEMPLATES(signed long)

--- 53 unchanged lines hidden (view full) ---

338 fatal("couldn't mkdir %s\n", dir);
339
340 string cpt_file = dir + Checkpoint::baseFilename;
341 ofstream outstream(cpt_file.c_str());
342 time_t t = time(NULL);
343 outstream << "// checkpoint generated: " << ctime(&t);
344
345 globals.serialize(outstream);
346 SimObject::serializeAll(outstream);
347}
348
349void
350Serializable::unserializeAll(const std::string &cpt_dir)
351{
352 setCheckpointDir(cpt_dir);
353 string dir = Checkpoint::dir();
354 string cpt_file = dir + Checkpoint::baseFilename;
355 string section = "";
356
357 DPRINTFR(Config, "Loading checkpoint dir '%s'\n",
358 dir);
359 Checkpoint *cp = new Checkpoint(dir, section);
360 unserializeGlobals(cp);
361
362 SimObject::unserializeAll(cp);
363}
364
365void
366Serializable::unserializeGlobals(Checkpoint *cp)
367{
368 globals.unserialize(cp);
369}

--- 134 unchanged lines hidden ---