CHAI3D  3.0.0
CPrecisionClock.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2015, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.0.0 $Rev: 1639 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CPrecisionClockH
46 #define CPrecisionClockH
47 //------------------------------------------------------------------------------
48 #include "system/CGlobals.h"
49 //------------------------------------------------------------------------------
50 
51 //------------------------------------------------------------------------------
52 namespace chai3d {
53 //------------------------------------------------------------------------------
54 
55 //==============================================================================
63 //==============================================================================
64 
65 //==============================================================================
83 //==============================================================================
84 
86 {
87  //--------------------------------------------------------------------------
88  // CONSTRUCTOR & DESTRUCTOR:
89  //--------------------------------------------------------------------------
90 
91 public:
92 
95 
97  virtual ~cPrecisionClock() {};
98 
99 
100  //--------------------------------------------------------------------------
101  // PUBLIC METHODS:
102  //--------------------------------------------------------------------------
103 
104 public:
105 
107  void reset(const double a_currentTime = 0.0);
108 
110  double start(bool a_resetClock = false);
111 
113  double stop();
114 
116  bool on() const { return (m_on); };
117 
119  double getCurrentTimeSeconds() const;
120 
122  void setTimeoutPeriodSeconds(const double a_timeoutPeriod);
123 
125  double getTimeoutPeriodSeconds() const { return (m_timeoutPeriod); }
126 
128  bool timeoutOccurred() const ;
129 
131  bool highResolution() const { return (m_highres); };
132 
134  double getCPUTimeSeconds() const;
135 
136 
137  //--------------------------------------------------------------------------
138  // PROTECTED MEMBERS:
139  //--------------------------------------------------------------------------
140 
141 protected:
142 
143 #if defined(WIN32) | defined(WIN64)
144  LARGE_INTEGER m_freq;
146 #endif
147 
150 
152  double m_timeStart;
153 
156 
159 
161  bool m_highres;
162 
164  bool m_on;
165 };
166 
167 //------------------------------------------------------------------------------
168 } // namespace chai3d
169 //------------------------------------------------------------------------------
170 
171 //------------------------------------------------------------------------------
172 #endif
173 //------------------------------------------------------------------------------
bool on() const
This method returns true if the clock is running (ON), otherwise false if the clock is paused (OFF)...
Definition: CPrecisionClock.h:116
LARGE_INTEGER m_freq
Stores information about CPU high precision clock.
Definition: CPrecisionClock.h:145
This class implements a high precision clock.
Definition: CPrecisionClock.h:85
bool timeoutOccurred() const
This method returns true if timeout has occurred, otherwise return false.
Definition: CPrecisionClock.cpp:177
bool m_on
If true, then clock is currently ON.
Definition: CPrecisionClock.h:164
double start(bool a_resetClock=false)
This method starts the clock with optional reset.
Definition: CPrecisionClock.cpp:118
bool highResolution() const
This method returns true if the high resolution CPU clock is available on this computer, false. otherwise.
Definition: CPrecisionClock.h:131
void reset(const double a_currentTime=0.0)
This method resets the clock.
Definition: CPrecisionClock.cpp:97
double getCPUTimeSeconds() const
This method returns the raw CPU time in seconds.
Definition: CPrecisionClock.cpp:216
Implements option settings for CHAI3D.
double stop()
This method stops the clock and return the elapsed time.
Definition: CPrecisionClock.cpp:142
double m_timeoutStart
Clock time in seconds when timer was started.
Definition: CPrecisionClock.h:158
double getTimeoutPeriodSeconds() const
This method reads the programmed timeout period is seconds.
Definition: CPrecisionClock.h:125
double getCurrentTimeSeconds() const
This method returns the current clock time in seconds.
Definition: CPrecisionClock.cpp:198
cPrecisionClock()
Constructor of cPrecisionClock.
Definition: CPrecisionClock.cpp:57
double m_timeStart
CPU time in seconds when clock was started.
Definition: CPrecisionClock.h:152
Definition: CAudioBuffer.cpp:56
void setTimeoutPeriodSeconds(const double a_timeoutPeriod)
This method sets the period in seconds before a timeout occurs (you need to poll for this)...
Definition: CPrecisionClock.cpp:164
bool m_highres
If true, then high precision CPU clock is available.
Definition: CPrecisionClock.h:161
double m_timeoutPeriod
Timeout period in seconds.
Definition: CPrecisionClock.h:155
double m_timeAccumulated
Time accumulated between previous calls to start() and stop().
Definition: CPrecisionClock.h:149
virtual ~cPrecisionClock()
Destructor of cPrecisionClock.
Definition: CPrecisionClock.h:97

CHAI3D 3.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2015 - CHAI3D
All Rights Reserved.