00001 /* 00002 * Time.hpp 00003 * 00004 * Created on: Oct 26, 2011 00005 * Author: mriedel 00006 */ 00007 00008 // adapted from 00009 00010 #ifndef TIME_HPP_ 00011 #define TIME_HPP_ 00012 00013 #include <telekyb_defines/telekyb_defines.hpp> 00014 00015 #include <string> 00016 00017 #include <ros/time.h> 00018 00019 namespace TELEKYB_NAMESPACE { 00020 00021 class Time { 00022 protected: 00023 long int _sec; 00024 long int _usec; 00025 static const int TIME_RESOLUTION = 1000000; 00027 public: 00029 Time(); 00030 00032 Time(long int s,long int u); 00033 00035 Time(double t); 00036 00038 Time(const Time& t); 00039 00041 Time(const ros::Time& time); 00042 00044 virtual ~Time(); 00045 00047 Time& operator=(const Time& t); 00048 00050 Time& operator+=(const Time& t); 00051 00053 Time& operator-=(const Time& t); 00054 00056 /*const*/ Time operator+(const Time &other) const; 00057 00059 /*const*/ Time operator-(const Time &other) const; 00060 00062 Time& operator*=(double scalar); 00063 00065 Time& operator*(double scalar); 00066 00068 bool operator==(const Time &other) const; 00069 00071 bool operator!=(const Time &other) const; 00072 00074 bool operator>(const Time &other) const; 00075 00077 bool operator<(const Time &other) const; 00078 00080 bool operator>=(const Time &other) const; 00081 00083 bool operator<=(const Time &other) const; 00084 00086 long int sec (); 00087 long int usec (); 00088 00090 bool isZero() const; 00091 00093 void sleep(); 00094 00096 static Time Zero(); 00097 00099 double toDSec(); 00100 00102 double frequency(); 00103 00105 ros::Time toRosTime() const; 00106 00108 std::string toString(); 00110 std::string freqToString(); 00111 00112 std::string dSecToString(); 00113 00114 std::string dateTimeToString(); 00115 00116 00117 }; 00118 00119 00120 } /* namespace telekyb */ 00121 #endif /* TIME_HPP_ */