00001 /* 00002 * Copyright (C) 2006 Helmut Grohne 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 #ifndef LIBMUTH_TIMEVAL_DECLS_H 00020 #define LIBMUTH_TIMEVAL_DECLS_H 00021 00022 #include <time.h> 00023 #ifndef __WIN32__ 00024 #include <sys/time.h> 00025 #else 00026 #include "win32.h" 00027 #include <sys/timeb.h> 00028 #include <sys/types.h> 00029 #endif 00030 00031 #define TimevalNow ((void*)0) 00032 00036 class Timeval : public timeval{ 00037 public: 00041 Timeval(); 00048 Timeval(const timeval &o); 00054 Timeval(void*); 00059 Timeval(time_t sec); 00065 Timeval(time_t sec, suseconds_t usec); 00070 Timeval(float sec); 00075 Timeval(double sec); 00082 Timeval &operator=(const timeval &o); 00088 Timeval &operator=(time_t sec); 00094 Timeval &operator=(float sec); 00100 Timeval &operator=(double sec); 00105 Timeval &gettimeofday(); 00110 operator time_t() const; 00115 operator float() const; 00120 operator double() const; 00126 unsigned int milliseconds() const; 00132 bool operator>(const timeval &o) const; 00138 bool operator>=(const timeval &o) const; 00145 bool operator==(const timeval &o) const; 00151 bool operator<=(const timeval &o) const; 00157 bool operator<(const timeval &o) const; 00164 bool operator!=(const timeval &o) const; 00171 Timeval operator+(const timeval &o) const; 00178 Timeval operator+(time_t sec) const; 00185 Timeval operator+(float sec) const; 00192 Timeval operator+(double sec) const; 00199 Timeval &operator+=(const timeval &o); 00205 Timeval &operator+=(time_t sec); 00211 Timeval &operator+=(float sec); 00217 Timeval &operator+=(double sec); 00224 Timeval operator-(const timeval &o) const; 00232 Timeval operator-(time_t sec) const; 00240 Timeval operator-(float sec) const; 00248 Timeval operator-(double sec) const; 00255 Timeval &operator-=(const timeval &o); 00261 Timeval &operator-=(time_t sec); 00267 Timeval &operator-=(float sec); 00273 Timeval &operator-=(double sec); 00274 }; 00275 00276 #endif