X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftime%2Ftimedelta.h;h=0ced98ecd3e7e581795056959895a8941ae3e966;hb=6a38983c19fe78753962288e206c5817ad595448;hp=ad985c7e2c1d13a7a738237c9d9f3af33c4b7212;hpb=cd89068b8ebafdc0f888c1aa21498bb93b55d814;p=libs%2Fcore.git diff --git a/source/time/timedelta.h b/source/time/timedelta.h index ad985c7..0ced98e 100644 --- a/source/time/timedelta.h +++ b/source/time/timedelta.h @@ -1,12 +1,15 @@ -/* +/* $Id$ + This file is part of libmspcore Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + #ifndef MSP_TIME_TIMEDELTA_H_ #define MSP_TIME_TIMEDELTA_H_ #include +#include #include #include "types.h" @@ -18,6 +21,9 @@ Represents a quantity of time, such as five seconds. */ class TimeDelta { +private: + RawTime usec; + public: /** Constructs a zero TimeDelta. @@ -42,7 +48,9 @@ public: Fills in a timespec struct. To get a meaningful scalar value from the TimeDelta, divide with one of the values in units.h. */ - void fill_timespec(timespec &ts) const { ts.tv_sec=usec/1000000; ts.tv_nsec=(usec%1000000)*1000; } + void fill_timespec(timespec &ts) const { ts.tv_sec=usec/1000000; ts.tv_nsec = (usec%1000000)*1000; } + + void fill_timeval(timeval &tv) const { tv.tv_sec=usec/1000000; tv.tv_usec = usec%1000000; } #endif TimeDelta operator+(const TimeDelta &t) const { return TimeDelta(usec+t.usec); } @@ -70,8 +78,6 @@ public: bool operator!=(const TimeDelta &t) const { return usec!=t.usec; } operator const void *() const { return usec ? this : 0; } -private: - RawTime usec; }; template