00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \version 2.0.0 $Rev: 251 $ 00018 */ 00019 //=========================================================================== 00020 00021 //--------------------------------------------------------------------------- 00022 #ifndef CPrecisionClockH 00023 #define CPrecisionClockH 00024 //--------------------------------------------------------------------------- 00025 #include "extras/CGlobals.h" 00026 //--------------------------------------------------------------------------- 00027 00028 //=========================================================================== 00036 //=========================================================================== 00037 00038 //=========================================================================== 00048 //=========================================================================== 00049 class cPrecisionClock 00050 { 00051 public: 00052 00053 //----------------------------------------------------------------------- 00054 // CONSTRUCTOR & DESTRUCTOR: 00055 //----------------------------------------------------------------------- 00056 00058 cPrecisionClock(); 00059 00061 ~cPrecisionClock(); 00062 00063 00064 //----------------------------------------------------------------------- 00065 // METHODS: 00066 //----------------------------------------------------------------------- 00067 00069 void reset(); 00070 00072 double start(bool a_resetClock = false); 00073 00075 double stop(); 00076 00078 bool on() { return (m_on); }; 00079 00081 double getCurrentTimeSeconds(); 00082 00084 void setTimeoutPeriodSeconds(double a_timeoutPeriod); 00085 00087 double getTimeoutPeriodSeconds() { return (m_timeoutPeriod); } 00088 00090 bool timeoutOccurred(); 00091 00093 bool highResolution() { return (m_highres); }; 00094 00096 double getCPUTimeSeconds(); 00097 00099 double getCPUTime() { return getCPUTimeSeconds(); } 00100 00102 double getCPUtime() { return getCPUTimeSeconds(); } 00103 00104 private: 00105 00106 #if defined(_WIN32) 00108 LARGE_INTEGER m_freq; 00109 #endif 00110 00112 double m_timeAccumulated; 00113 00115 double m_timeStart; 00116 00118 double m_timeoutPeriod; 00119 00121 double m_timeoutStart; 00122 00124 bool m_highres; 00125 00127 bool m_on; 00128 }; 00129 00130 //--------------------------------------------------------------------------- 00131 #endif 00132 //---------------------------------------------------------------------------