![]() |
http://www.sim.no/ http://www.coin3d.org/ |
00001 #ifndef COIN_SBTIME_H 00002 #define COIN_SBTIME_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2009 by Kongsberg SIM. All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Kongsberg SIM about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Kongsberg SIM, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <stdio.h> 00028 00029 #include <Inventor/system/inttypes.h> 00030 #include <Inventor/SbBasic.h> 00031 #include <Inventor/SbString.h> 00032 00033 // Avoid problem with Microsoft Visual C++ Win32 API headers (they 00034 // #define "max" (in 3 different header files, no less)). 00035 #ifdef max 00036 #define SBTIME_UNDEF_MAX 00037 #undef max 00038 #endif // max 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 static SbTime max(void); 00052 static SbTime maxTime(void); 00053 static void sleep(int msec); 00054 void setValue(const double sec); 00055 void setValue(const int32_t sec, const long usec); 00056 void setValue(const struct timeval * const tv); 00057 void setMsecValue(const unsigned long msec); 00058 double getValue(void) const; 00059 void getValue(time_t & sec, long & usec) const; 00060 void getValue(struct timeval * tv) const; 00061 unsigned long getMsecValue(void) const; 00062 SbString format(const char * const fmt = "%S.%i") const; 00063 SbString formatDate(const char * const fmt = NULL) const; 00064 SbBool parsedate(const char * const date); 00065 friend COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1); 00066 friend COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1); 00067 SbTime & operator +=(const SbTime & tm); 00068 SbTime & operator -=(const SbTime & tm); 00069 SbTime operator-(void) const; 00070 friend COIN_DLL_API SbTime operator *(const double s, const SbTime & tm); 00071 friend COIN_DLL_API SbTime operator *(const SbTime & tm, const double s); 00072 friend COIN_DLL_API SbTime operator /(const SbTime & tm, const double s); 00073 SbTime & operator *=(const double s); 00074 SbTime & operator /=(const double s); 00075 double operator /(const SbTime & tm) const; 00076 SbTime operator %(const SbTime & tm) const; 00077 int operator ==(const SbTime & tm) const; 00078 int operator !=(const SbTime & tm) const; 00079 SbBool operator <(const SbTime & tm) const; 00080 SbBool operator >(const SbTime & tm) const; 00081 SbBool operator <=(const SbTime & tm) const; 00082 SbBool operator >=(const SbTime & tm) const; 00083 00084 void print(FILE * fp) const; 00085 00086 private: 00087 double dtime; 00088 void addToString(SbString & str, const double val) const; 00089 }; 00090 00091 COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1); 00092 COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1); 00093 COIN_DLL_API SbTime operator *(const double s, const SbTime & tm); 00094 COIN_DLL_API SbTime operator *(const SbTime & tm, const double s); 00095 COIN_DLL_API SbTime operator /(const SbTime & tm, const double s); 00096 00097 // Avoid problem with Microsoft Win32 API headers (see above). 00098 // Redefine macro max() back to a definition compatible with what it 00099 // is in the MSVC header files. 00100 #ifdef SBTIME_UNDEF_MAX 00101 #define max(a,b) (((a) > (b)) ? (a) : (b)) 00102 #undef SBTIME_UNDEF_MAX 00103 #endif // SBTIME_UNDEF_MAX 00104 00105 #endif // !COIN_SBTIME_H
Copyright © 1998-2009 by Kongsberg SIM. All rights reserved.
Generated on Mon Jun 15 11:58:15 2009 for Coin by Doxygen 1.5.9.