00001 #ifndef PROTON_TIMESTAMP_HPP
00002 #define PROTON_TIMESTAMP_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "./duration.hpp"
00024
00025 namespace proton {
00026
00030 class timestamp : private internal::comparable<timestamp> {
00031 public:
00033 typedef int64_t numeric_type;
00034
00036 PN_CPP_EXTERN static timestamp now();
00037
00039 explicit timestamp(numeric_type ms = 0) : ms_(ms) {}
00040
00042 timestamp& operator=(numeric_type ms) { ms_ = ms; return *this; }
00043
00045 numeric_type milliseconds() const { return ms_; }
00046
00047 private:
00048 numeric_type ms_;
00049 };
00050
00053 inline bool operator==(timestamp x, timestamp y) { return x.milliseconds() == y.milliseconds(); }
00054 inline bool operator<(timestamp x, timestamp y) { return x.milliseconds() < y.milliseconds(); }
00055
00056 inline timestamp operator+(timestamp ts, duration d) { return timestamp(ts.milliseconds() + d.milliseconds()); }
00057 inline duration operator-(timestamp t0, timestamp t1) { return duration(t0.milliseconds() - t1.milliseconds()); }
00058 inline timestamp operator+(duration d, timestamp ts) { return ts + d; }
00060
00062 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, timestamp);
00063
00064 }
00065
00066 #endif // PROTON_TIMESTAMP_HPP