Coin Logo http://www.sim.no
http://www.coin3d.org

SbTime.h
1 #ifndef COIN_SBTIME_H
2 #define COIN_SBTIME_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <stdio.h>
28 
29 #include <Inventor/system/inttypes.h>
30 #include <Inventor/SbBasic.h>
31 #include <Inventor/SbString.h>
32 
33 // Avoid problem with Microsoft Visual C++ Win32 API headers (they
34 // #define "max" (in 3 different header files, no less)).
35 #ifdef max
36 #define SBTIME_UNDEF_MAX
37 #undef max
38 #endif // max
39 
40 
41 class COIN_DLL_API SbTime {
42 public:
43  SbTime(void);
44  SbTime(const double sec);
45  SbTime(const int32_t sec, const long usec);
46  SbTime(const struct timeval * const tv);
47  static SbTime getTimeOfDay(void);
48  void setToTimeOfDay(void);
49  static SbTime zero(void);
50 
51  static SbTime max(void);
52  static SbTime maxTime(void);
53  void setValue(const double sec);
54  void setValue(const int32_t sec, const long usec);
55  void setValue(const struct timeval * const tv);
56  void setMsecValue(const unsigned long msec);
57  double getValue(void) const;
58  void getValue(time_t & sec, long & usec) const;
59  void getValue(struct timeval * tv) const;
60  unsigned long getMsecValue(void) const;
61  SbString format(const char * const fmt = "%S.%i") const;
62  SbString formatDate(const char * const fmt = NULL) const;
63  SbBool parsedate(const char * const date);
64  friend COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1);
65  friend COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1);
66  SbTime & operator +=(const SbTime & tm);
67  SbTime & operator -=(const SbTime & tm);
68  SbTime operator-(void) const;
69  friend COIN_DLL_API SbTime operator *(const double s, const SbTime & tm);
70  friend COIN_DLL_API SbTime operator *(const SbTime & tm, const double s);
71  friend COIN_DLL_API SbTime operator /(const SbTime & tm, const double s);
72  SbTime & operator *=(const double s);
73  SbTime & operator /=(const double s);
74  double operator /(const SbTime & tm) const;
75  SbTime operator %(const SbTime & tm) const;
76  int operator ==(const SbTime & tm) const;
77  int operator !=(const SbTime & tm) const;
78  SbBool operator <(const SbTime & tm) const;
79  SbBool operator >(const SbTime & tm) const;
80  SbBool operator <=(const SbTime & tm) const;
81  SbBool operator >=(const SbTime & tm) const;
82 
83  void print(FILE * fp) const;
84 
85 private:
86  double dtime;
87  void addToString(SbString & str, const double val) const;
88 };
89 
90 COIN_DLL_API SbTime operator +(const SbTime & t0, const SbTime & t1);
91 COIN_DLL_API SbTime operator -(const SbTime & t0, const SbTime & t1);
92 COIN_DLL_API SbTime operator *(const double s, const SbTime & tm);
93 COIN_DLL_API SbTime operator *(const SbTime & tm, const double s);
94 COIN_DLL_API SbTime operator /(const SbTime & tm, const double s);
95 
96 // Avoid problem with Microsoft Win32 API headers (see above).
97 // Redefine macro max() back to a definition compatible with what it
98 // is in the MSVC header files.
99 #ifdef SBTIME_UNDEF_MAX
100 #define max(a,b) (((a) > (b)) ? (a) : (b))
101 #undef SBTIME_UNDEF_MAX
102 #endif // SBTIME_UNDEF_MAX
103 
104 #endif // !COIN_SBTIME_H
The SbTime class instances represents time values.SbTime is a convenient way of doing system independ...
Definition: SbTime.h:41
The SbString class is a string class with convenience functions for string operations....
Definition: SbString.h:42

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Wed Jul 24 2019 for Coin by Doxygen. 1.8.15