Time.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef TIME_HH
00027 #define TIME_HH
00028
00029 #include <time.h>
00030 #include <iostream>
00031
00032 namespace gazebo
00033 {
00037
00038
00041 class Time
00042 {
00044 public: Time();
00045
00048 public: Time( const Time &time );
00049
00052 public: Time( const struct timeval &tv );
00053
00057 public: Time( int sec, int usec );
00058
00061 public: Time( double time );
00062
00064 public: virtual ~Time();
00065
00067 public: static Time GetWallTime();
00068
00070 public: void SetToWallTime();
00071
00075 public: void Set( int sec, int usec );
00076
00079 public: void Set(double seconds);
00080
00083 public: double Double() const;
00084
00086 public: const Time &operator=( const struct timeval &tv );
00087
00089 public: const Time &operator=( const Time &time );
00090
00092 public: Time operator +( const struct timeval &tv ) const;
00093
00095 public: const Time &operator +=( const struct timeval &tv );
00096
00098 public: Time operator +( const Time &time ) const;
00099
00101 public: const Time &operator +=( const Time &time );
00102
00104 public: Time operator -( const struct timeval &tv ) const;
00105
00107 public: const Time &operator -=( const struct timeval &tv );
00108
00110 public: Time operator -( const Time &time ) const;
00111
00113 public: const Time &operator -=( const Time &time );
00114
00116 public: Time operator *( const struct timeval &tv ) const;
00117
00119 public: const Time &operator *=( const struct timeval &tv );
00120
00122 public: Time operator *( const Time &time ) const;
00123
00125 public: const Time &operator *=( const Time &time );
00126
00128 public: Time operator /( const struct timeval &tv ) const;
00129
00131 public: const Time &operator /=( const struct timeval &tv );
00132
00134 public: Time operator /( const Time &time ) const;
00135
00137 public: const Time &operator /=( const Time &time );
00138
00140 public: bool operator==( const struct timeval &tv ) const;
00142 public: bool operator==( const Time &time ) const;
00144 public: bool operator==( double time ) const;
00146 public: bool operator!=( const struct timeval &tv ) const;
00148 public: bool operator!=( const Time &time ) const;
00150 public: bool operator!=( double time ) const;
00152 public: bool operator<( const struct timeval &tv ) const;
00154 public: bool operator<( const Time &time ) const;
00156 public: bool operator<( double time ) const;
00158 public: bool operator<=( const struct timeval &tv ) const;
00160 public: bool operator<=( const Time &time ) const;
00162 public: bool operator<=( double time ) const;
00164 public: bool operator>( const struct timeval &tv ) const;
00166 public: bool operator>( const Time &time ) const;
00168 public: bool operator>( double time ) const;
00170 public: bool operator>=( const struct timeval &tv ) const;
00172 public: bool operator>=( const Time &time ) const;
00174 public: bool operator>=( double time ) const;
00175
00177 public: friend std::ostream &operator<<(std::ostream &out, const Time &time);
00178
00180 public: int sec;
00181
00183 public: int usec;
00184
00186 private: void Correct();
00187 };
00189
00190 }
00191 #endif
00192