From: Gabe Black Date: Thu, 3 Feb 2011 02:05:03 +0000 (-0800) Subject: Time: Add serialization functions to the Time class. X-Git-Tag: stable_2012_02_02~626 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75d34c14fcdf514a09e94547a1d32b1b10f7e793;p=gem5.git Time: Add serialization functions to the Time class. --- diff --git a/src/base/time.cc b/src/base/time.cc index 0fab938a4..8ce2e2137 100644 --- a/src/base/time.cc +++ b/src/base/time.cc @@ -34,6 +34,7 @@ #include "base/time.hh" #include "config/use_posix_clock.hh" #include "sim/core.hh" +#include "sim/serialize.hh" using namespace std; @@ -113,6 +114,25 @@ Time::time() const return str.str(); } +void +Time::serialize(const std::string &base, ostream &os) +{ + paramOut(os, base + ".sec", sec()); + paramOut(os, base + ".nsec", nsec()); +} + +void +Time::unserialize(const std::string &base, Checkpoint *cp, + const string §ion) +{ + time_t secs; + time_t nsecs; + paramIn(cp, section, base + ".sec", secs); + paramIn(cp, section, base + ".nsec", nsecs); + sec(secs); + nsec(nsecs); +} + void sleep(const Time &time) { diff --git a/src/base/time.hh b/src/base/time.hh index 4fc3dd3ef..20b1c6d35 100644 --- a/src/base/time.hh +++ b/src/base/time.hh @@ -40,10 +40,13 @@ #include #include #include +#include #include #include "base/types.hh" +class Checkpoint; + class Time { protected: @@ -195,6 +198,10 @@ class Time std::string date(const std::string &format = "") const; std::string time() const; + + void serialize(const std::string &base, std::ostream &os); + void unserialize(const std::string &base, Checkpoint *cp, + const std::string §ion); }; void sleep(const Time &time);