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

SbTime.h

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-2003 by Systems in Motion.  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 Systems in Motion about acquiring
00018  *  a Coin Professional Edition License.
00019  *
00020  *  See <URL:http://www.coin3d.org> for  more information.
00021  *
00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
00023  *  <URL:http://www.sim.no>.
00024  *
00025 \**************************************************************************/
00026 
00027 // FIXME: the following system testing and conditional header file
00028 // inclusion is a mess. Sort it out properly (with configure checks,
00029 // probably). 20011019 mortene.
00030 
00031 // Usually you get all you need from time.h
00032 #include <time.h>
00033 #ifdef _WIN32
00034 #include <sys/timeb.h>
00035 
00036 struct timeval;
00037 #else
00038 // Sometimes (linux) sys/time.h is also needed
00039 #include <sys/time.h>
00040 #endif // ! WIN32
00041 
00042 #include <stdio.h>
00043 
00044 #include <Inventor/system/inttypes.h>
00045 #include <Inventor/SbBasic.h>
00046 #include <Inventor/SbString.h>
00047 
00048 
00049 class COIN_DLL_API SbTime {
00050 public:
00051   SbTime(void);
00052   SbTime(const double sec);
00053   SbTime(const int32_t sec, const long usec);
00054   SbTime(const struct timeval * const tv);
00055   static SbTime getTimeOfDay(void);
00056   void setToTimeOfDay(void);
00057   static SbTime zero(void);
00058 
00059   // "max" is a #define somewhere in the Win32 include hierarchy mess.
00060   // Believe it or not. Is there no end to the stupidity?
00061 #ifndef _WIN32 // FIXME: #ifdef'ing on system is bad design. 20011019 mortene.
00062   static SbTime max(void);
00063 #endif // _WIN32
00064 
00065   static SbTime maxTime(void);
00066   void setValue(const double sec);
00067   void setValue(const int32_t sec, const long usec);
00068   void setValue(const struct timeval * const tv);
00069   void setMsecValue(const unsigned long msec);
00070   double getValue(void) const;
00071   void getValue(time_t & sec, long & usec) const;
00072   void getValue(struct timeval * tv) const;
00073   unsigned long getMsecValue(void) const;
00074   SbString format(const char * const fmt = "%S.%i") const;
00075 #ifndef _WIN32 // FIXME: #ifdef'ing on system is bad design. 20011019 mortene.
00076   SbString formatDate(const char * const fmt = "%A, %D %r") const;
00077 #else // _WIN32
00078   SbString formatDate(const char * const fmt = "%#c") const;
00079 #endif // _WIN32
00080   SbBool parsedate(const char * const date);
00081   friend COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1);
00082   friend COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1);
00083   SbTime & operator +=(const SbTime & tm);
00084   SbTime & operator -=(const SbTime & tm);
00085   SbTime operator-(void) const;
00086   friend COIN_DLL_API SbTime operator *(const double s, const SbTime & tm);
00087   friend COIN_DLL_API SbTime operator *(const SbTime & tm, const double s);
00088   friend COIN_DLL_API SbTime operator /(const SbTime & tm, const double s);
00089   SbTime & operator *=(const double s);
00090   SbTime & operator /=(const double s);
00091   double operator /(const SbTime & tm) const;
00092   SbTime operator %(const SbTime & tm) const;
00093   int operator ==(const SbTime & tm) const;
00094   int operator !=(const SbTime & tm) const;
00095   SbBool operator <(const SbTime & tm) const;
00096   SbBool operator >(const SbTime & tm) const;
00097   SbBool operator <=(const SbTime & tm) const;
00098   SbBool operator >=(const SbTime & tm) const;
00099 
00100   void print(FILE * fp) const;
00101 
00102 private:
00103   double dtime;
00104   void addToString(SbString & str, const double val) const;
00105 };
00106 
00107 COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1);
00108 COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1);
00109 COIN_DLL_API SbTime operator *(const double s, const SbTime & tm);
00110 COIN_DLL_API SbTime operator *(const SbTime & tm, const double s);
00111 COIN_DLL_API SbTime operator /(const SbTime & tm, const double s);
00112 
00113 #endif // !COIN_SBTIME_H

Generated on Sat May 24 22:39:06 2003 for Coin by doxygen1.2.18