Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MNTimeval.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef MN_TIMEVAL_H 00025 #define MN_TIMEVAL_H 00026 00027 #include <config.h> 00028 00029 #include <sys/time.h> 00030 #include <sys/types.h> 00031 #include <unistd.h> 00032 #include <string.h> 00033 00034 #include "mnstream.h" 00035 00036 typedef struct timeval C_timeval; 00037 00038 extern bool operator< (const C_timeval& t1, const C_timeval& t2); 00039 extern bool operator> (const C_timeval& t1, const C_timeval& t2); 00040 extern bool operator>=(const C_timeval& t1, const C_timeval& t2); 00041 extern bool operator<=(const C_timeval& t1, const C_timeval& t2); 00042 extern C_timeval operator-(const C_timeval& t1, const C_timeval& t2); 00043 extern C_timeval operator+(const C_timeval& t1, const C_timeval& t2); 00044 extern C_timeval operator+(const C_timeval& t1, unsigned int usecs); 00045 extern C_timeval operator-(const C_timeval& t1, unsigned int usecs); 00046 extern C_timeval operator*(int mul, const C_timeval& t); 00047 extern C_timeval operator*(const C_timeval& t, int mul); 00048 00049 class Timeval 00050 : public C_timeval 00051 { 00052 public: 00053 static const size_t MAX_USEC = 1000000; 00054 00055 enum Now 00056 { 00057 NOW 00058 }; 00059 00060 public: 00061 Timeval( ); 00062 Timeval( const Timeval& tv ); 00063 Timeval( const C_timeval& tv ); 00064 Timeval( int microseconds ); 00065 Timeval( size_t microseconds ); 00066 Timeval( int64_t microseconds ); 00067 Timeval( double seconds ); 00068 Timeval( Now ); 00069 00070 Timeval& operator=( const Timeval& tv ); 00071 Timeval& operator=( int microseconds ); 00072 Timeval& operator=( size_t microseconds ); 00073 Timeval& operator=( int64_t microseconds ); 00074 Timeval& operator=( double seconds ); 00075 Timeval& operator=( Now ); 00076 00077 Timeval& operator+=( unsigned int tv ); 00078 Timeval& operator+=( Now ); 00079 Timeval& operator-=( unsigned int tv ); 00080 Timeval& operator-=( const Timeval& tv ); 00081 00082 size_t asUsec() const; 00083 int64_t asUsec64() const; 00084 double asSec() const; 00085 00091 void asNPT( ostream& ostr ) const; 00092 }; 00093 00094 extern Timeval operator*(int mul, const Timeval& t); 00095 extern Timeval operator*(const Timeval& t, int mul); 00096 00097 #endif /* MN_TIMEVAL_H */ 00098

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8