Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

timeval.h

Go to the documentation of this file.
00001 /*  Inti: Integrated Foundation Classes
00002  *  Copyright (C) 2003 The Inti 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 INTI_G_TIME_VAL_H
00026 #define INTI_G_TIME_VAL_H
00027 
00028 #ifndef INTI_OBJECT_H
00029 #include <inti/object.h>
00030 #endif
00031 
00032 #ifndef __G_TYPES_H__
00033 #include <glib/gtypes.h>
00034 #endif
00035 
00036 namespace Inti {
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 { return const_cast<GTimeVal*>(&timeval_); }
00103 
00104         operator GTimeVal* () const;
00106 
00107         long seconds() const { return timeval_.tv_sec; }
00109 
00110         long microseconds() const { return timeval_.tv_usec; }
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 
00208 inline bool
00209 TimeVal::operator==(const TimeVal& other)
00210 {
00211         return equal(other);
00212 }
00213 
00214 inline bool
00215 TimeVal::operator!=(const TimeVal& other)
00216 {
00217         return !equal(other);
00218 }
00219 
00220 inline bool
00221 TimeVal::operator<=(const TimeVal& other)
00222 {
00223         return operator==(other) || operator<(other);
00224 }
00225 
00226 inline bool
00227 TimeVal::operator>=(const TimeVal& other)
00228 {
00229         return operator==(other) || operator>(other);
00230 }
00231 
00234 
00235 inline const TimeVal
00236 operator+(const TimeVal& lhs, long microseconds)
00237 {
00238         return TimeVal(lhs) += microseconds;
00239 }
00241 
00242 inline const TimeVal
00243 operator+(const TimeVal& lhs, const TimeVal& rhs)
00244 {
00245         return TimeVal(lhs) += rhs;
00246 }
00248 
00252 
00253 inline const TimeVal
00254 operator-(const TimeVal& lhs, long microseconds)
00255 {
00256         return TimeVal(lhs) -= microseconds;
00257 }
00259 
00260 inline const TimeVal
00261 operator-(const TimeVal& lhs, const TimeVal& rhs)
00262 {
00263         return TimeVal(lhs) -= rhs;
00264 }
00266 
00268 
00269 } // namespace G
00270 
00271 } // namespace Inti
00272 
00273 #endif // INTI_G_TIMER_H
00274 
00275 
00276 
Main Page - Footer


Generated on Sun Sep 14 20:08:04 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002