Time: Add serialization functions to the Time class.
This commit is contained in:
parent
c4b81d311e
commit
75d34c14fc
|
@ -34,6 +34,7 @@
|
||||||
#include "base/time.hh"
|
#include "base/time.hh"
|
||||||
#include "config/use_posix_clock.hh"
|
#include "config/use_posix_clock.hh"
|
||||||
#include "sim/core.hh"
|
#include "sim/core.hh"
|
||||||
|
#include "sim/serialize.hh"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -113,6 +114,25 @@ Time::time() const
|
||||||
return str.str();
|
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
|
void
|
||||||
sleep(const Time &time)
|
sleep(const Time &time)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,10 +40,13 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/types.hh"
|
#include "base/types.hh"
|
||||||
|
|
||||||
|
class Checkpoint;
|
||||||
|
|
||||||
class Time
|
class Time
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -195,6 +198,10 @@ class Time
|
||||||
|
|
||||||
std::string date(const std::string &format = "") const;
|
std::string date(const std::string &format = "") const;
|
||||||
std::string time() 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);
|
void sleep(const Time &time);
|
||||||
|
|
Loading…
Reference in a new issue