Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SbTime.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2002 by Systems in Motion. All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public License
00008  *  version 2.1 as published by the Free Software Foundation. See the
00009  *  file LICENSE.LGPL at the root directory of the distribution for
00010  *  more details.
00011  *
00012  *  If you want to use Coin for applications not compatible with the
00013  *  LGPL, please contact SIM to acquire a Professional Edition license.
00014  *
00015  *  Systems in Motion, Prof Brochs gate 6, 7030 Trondheim, NORWAY
00016  *  http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097
00017  *
00018 \**************************************************************************/
00019 
00020 #ifndef COIN_SBTIME_H
00021 #define COIN_SBTIME_H
00022 
00023 // Usually you get all you need from time.h
00024 #include <time.h>
00025 #ifdef _WIN32
00026 #include <sys/timeb.h>
00027 
00028 struct timeval;
00029 #else
00030 // Sometimes (linux) sys/time.h is also needed
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   // "max" is a #define somewhere in the Win32 include hierarchy mess.
00052   // Believe it or not. Is there no end to the stupidity?
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

Generated at Tue Mar 5 03:31:11 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001