GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

timeval.hh

Go to the documentation of this file.
00001 /* GFC-Core: GTK+ Foundation Classes (Core Library) 00002 * Copyright (C) 2003-2004 The GFC Development Team. 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 Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library 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 00024 00025 #ifndef GFC_G_TIME_VAL_HH 00026 #define GFC_G_TIME_VAL_HH 00027 00028 #ifndef GFC_OBJECT_HH 00029 #include <gfc/object.hh> 00030 #endif 00031 00032 #ifndef __G_TYPES_H__ 00033 #include <glib/gtypes.h> 00034 #endif 00035 00036 namespace GFC { 00037 00038 namespace G { 00039 00040 class TimeVal; 00041 00044 00045 TimeVal get_current_time(); 00048 00049 void usleep(unsigned long microseconds); 00056 00058 00064 00065 class TimeVal 00066 { 00067 GTimeVal timeval_; 00068 00069 public: 00072 00073 TimeVal(); 00075 00076 TimeVal(long seconds, long microseconds); 00084 00085 TimeVal(const double& timeval); 00092 00093 TimeVal(const GTimeVal& timeval); 00096 00100 00101 GTimeVal* g_time_val() const; 00103 00104 operator GTimeVal* () const; 00106 00107 long seconds() const; 00109 00110 long microseconds() const; 00112 00113 double get_double() const; 00119 00120 bool equal(const TimeVal& other) const; 00124 00125 bool operator==(const TimeVal& other); 00129 00130 bool operator!=(const TimeVal& other); 00134 00135 bool operator<(const TimeVal& other); 00139 00140 bool operator<=(const TimeVal& other); 00144 00145 bool operator>(const TimeVal& other); 00149 00150 bool operator>=(const TimeVal& other); 00154 00158 00159 void add(long microseconds); 00162 00163 void add(long seconds, long microseconds); 00171 00172 void add(const TimeVal& other); 00175 00176 void subtract(const TimeVal& other); 00179 00180 long difference(const TimeVal& other); 00184 00185 TimeVal& operator+=(long microseconds); 00189 00190 TimeVal& operator+=(const TimeVal& other); 00194 00195 TimeVal& operator-=(long microseconds); 00199 00200 TimeVal& operator-=(const TimeVal& other); 00204 00206 }; 00207 00210 00211 inline const TimeVal 00212 operator+(const TimeVal& lhs, long microseconds) 00213 { 00214 return TimeVal(lhs) += microseconds; 00215 } 00217 00218 inline const TimeVal 00219 operator+(const TimeVal& lhs, const TimeVal& rhs) 00220 { 00221 return TimeVal(lhs) += rhs; 00222 } 00224 00228 00229 inline const TimeVal 00230 operator-(const TimeVal& lhs, long microseconds) 00231 { 00232 return TimeVal(lhs) -= microseconds; 00233 } 00235 00236 inline const TimeVal 00237 operator-(const TimeVal& lhs, const TimeVal& rhs) 00238 { 00239 return TimeVal(lhs) -= rhs; 00240 } 00242 00244 00245 } // namespace G 00246 00247 } // namespace GFC 00248 00249 #include <gfc/glib/inline/timeval.inl> 00250 00251 #endif // GFC_G_TIMER_HH 00252 00253 00254

Generated on Tue Aug 24 00:04:56 2004 for GFC-Core by doxygen 1.3.8