--- a/src/simulator/nstime.h Wed Nov 01 13:11:30 2006 +0100
+++ b/src/simulator/nstime.h Wed Nov 01 13:27:32 2006 +0100
@@ -57,6 +57,12 @@
int64_t m_ns;
};
+Time Scale (Time const &time, double scale);
+Time Abs (Time const &time);
+Time Max (Time const &a, Time const &b);
+Time Min (Time const &a, Time const &b);
+
+
Time operator + (Time const &lhs, Time const &rhs);
Time operator - (Time const &lhs, Time const &rhs);
bool operator == (Time const &lhs, Time const &rhs);
--- a/src/simulator/time.cc Wed Nov 01 13:11:30 2006 +0100
+++ b/src/simulator/time.cc Wed Nov 01 13:27:32 2006 +0100
@@ -118,6 +118,32 @@
return time.ApproximateToNanoSeconds ();
}
+Time Scale (Time const &time, double scale)
+{
+ return NanoSeconds ((int64_t) (GetNs (time) * scale));
+}
+Time Abs (Time const &time)
+{
+ int64_t retval = GetNs (time);
+ retval = (retval<0)?(-retval):(retval);
+ return NanoSeconds (retval);
+}
+Time Max (Time const &ta, Time const &tb)
+{
+ int64_t a = GetNs (ta);
+ int64_t b = GetNs (tb);
+ int64_t retval = (a>b)?(a):(b);
+ return NanoSeconds (retval);
+}
+Time Min (Time const &ta, Time const &tb)
+{
+ int64_t a = GetNs (ta);
+ int64_t b = GetNs (tb);
+ int64_t retval = (a<b)?(a):(b);
+ return NanoSeconds (retval);
+}
+
+
Time operator + (Time const &lhs, Time const &rhs)
{
return NanoSeconds (GetNs (lhs) + GetNs (rhs));