00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __libutilxx__sella__util__TimeStamp_H__
00010 #define __libutilxx__sella__util__TimeStamp_H__
00011
00012 #include "../../common.h"
00013
00014 #include <sys/time.h>
00015 #include <stdint.h>
00016
00017 namespace sella {
00018 namespace util {
00019 class TimeStamp;
00020 }
00021 }
00022
00023 class sella::util::TimeStamp {
00024 public:
00025 TimeStamp(const struct timeval &tv) throw ();
00026 TimeStamp(int64_t micro) throw ();
00027 TimeStamp() throw ();
00028
00029 TimeStamp(const TimeStamp &other) throw ();
00030 virtual ~TimeStamp() throw ();
00031
00032 TimeStamp & operator = (const TimeStamp &other) throw ();
00033 TimeStamp & operator = (const struct timeval &value) throw ();
00034 TimeStamp & operator = (int64_t micro) throw ();
00035
00036 TimeStamp & operator += (const TimeStamp &other) throw ();
00037 TimeStamp & operator += (const struct timeval &value) throw ();
00038 TimeStamp & operator += (int64_t micro) throw ();
00039
00040 TimeStamp & operator -= (const TimeStamp &other) throw ();
00041 TimeStamp & operator -= (const struct timeval &value) throw ();
00042 TimeStamp & operator -= (int64_t micro) throw ();
00043
00044 TimeStamp & operator *= (const TimeStamp &other) throw ();
00045 TimeStamp & operator *= (const struct timeval &value) throw ();
00046 TimeStamp & operator *= (int64_t micro) throw ();
00047
00048 TimeStamp & operator /= (const TimeStamp &other) throw ();
00049 TimeStamp & operator /= (const struct timeval &value) throw ();
00050 TimeStamp & operator /= (int64_t micro) throw ();
00051
00052 TimeStamp operator + (const TimeStamp &other) throw ();
00053 TimeStamp operator + (const struct timeval &value) throw ();
00054 TimeStamp operator + (int64_t micro) throw ();
00055
00056 TimeStamp operator - (const TimeStamp &other) throw ();
00057 TimeStamp operator - (const struct timeval &value) throw ();
00058 TimeStamp operator - (int64_t micro) throw ();
00059
00060 TimeStamp operator * (const TimeStamp &other) throw ();
00061 TimeStamp operator * (const struct timeval &value) throw ();
00062 TimeStamp operator * (int64_t micro) throw ();
00063
00064 TimeStamp operator / (const TimeStamp &other) throw ();
00065 TimeStamp operator / (const struct timeval &value) throw ();
00066 TimeStamp operator / (int64_t micro) throw ();
00067
00068 bool operator == (const TimeStamp &other) const throw ();
00069 bool operator != (const TimeStamp &other) const throw ();
00070 bool operator >= (const TimeStamp &other) const throw ();
00071 bool operator <= (const TimeStamp &other) const throw ();
00072 bool operator > (const TimeStamp &other) const throw ();
00073 bool operator < (const TimeStamp &other) const throw ();
00074
00075 int64_t getEpochMicroseconds() const throw ();
00076 int64_t getEpochSeconds() const throw ();
00077
00078 void update() throw ();
00079
00080 private:
00081 static int64_t now() throw ();
00082
00083 int64_t stamp;
00084 };
00085
00086 #endif
00087
00088
00089
00090