00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SBTIME_H
00021 #define COIN_SBTIME_H
00022
00023
00024 #include <time.h>
00025 #ifdef _WIN32
00026 #include <sys/timeb.h>
00027
00028 struct timeval;
00029 #else
00030
00031 #include <sys/time.h>
00032 #endif // ! WIN32
00033
00034 #include <stdio.h>
00035
00036 #include <Inventor/system/inttypes.h>
00037 #include <Inventor/SbBasic.h>
00038 #include <Inventor/SbString.h>
00039
00040
00041 class COIN_DLL_API SbTime {
00042 public:
00043 SbTime(void);
00044 SbTime(const double sec);
00045 SbTime(const int32_t sec, const long usec);
00046 SbTime(const struct timeval * const tv);
00047 static SbTime getTimeOfDay(void);
00048 void setToTimeOfDay(void);
00049 static SbTime zero(void);
00050
00051
00052
00053 #ifndef _WIN32
00054 static SbTime max(void);
00055 #endif // _WIN32
00056
00057 static SbTime maxTime(void);
00058 void setValue(const double sec);
00059 void setValue(const int32_t sec, const long usec);
00060 void setValue(const struct timeval * const tv);
00061 void setMsecValue(const unsigned long msec);
00062 double getValue(void) const;
00063 void getValue(time_t & sec, long & usec) const;
00064 void getValue(struct timeval * tv) const;
00065 unsigned long getMsecValue(void) const;
00066 SbString format(const char * const fmt = "%S.%i") const;
00067 #ifndef _WIN32
00068 SbString formatDate(const char * const fmt = "%A, %D %r") const;
00069 #else // _WIN32
00070 SbString formatDate(const char * const fmt = "%#c") const;
00071 #endif // _WIN32
00072 SbBool parsedate(const char * const date);
00073 friend COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1);
00074 friend COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1);
00075 SbTime & operator +=(const SbTime & tm);
00076 SbTime & operator -=(const SbTime & tm);
00077 SbTime operator -(void) const;
00078 friend COIN_DLL_API SbTime operator *(const double s, const SbTime & tm);
00079 friend COIN_DLL_API SbTime operator *(const SbTime & tm, const double s);
00080 friend COIN_DLL_API SbTime operator /(const SbTime & tm, const double s);
00081 SbTime & operator *=(const double s);
00082 SbTime & operator /=(const double s);
00083 double operator /(const SbTime & tm) const;
00084 SbTime operator %(const SbTime & tm) const;
00085 int operator ==(const SbTime & tm) const;
00086 int operator !=(const SbTime & tm) const;
00087 SbBool operator <(const SbTime & tm) const;
00088 SbBool operator >(const SbTime & tm) const;
00089 SbBool operator <=(const SbTime & tm) const;
00090 SbBool operator >=(const SbTime & tm) const;
00091
00092 void print(FILE * fp) const;
00093
00094 private:
00095 double dtime;
00096 void addToString(SbString & str, const double val) const;
00097 };
00098
00099 COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1);
00100 COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1);
00101 COIN_DLL_API SbTime operator *(const double s, const SbTime & tm);
00102 COIN_DLL_API SbTime operator *(const SbTime & tm, const double s);
00103 COIN_DLL_API SbTime operator /(const SbTime & tm, const double s);
00104
00105 #endif // !COIN_SBTIME_H