00001 /*---------------------------------------------------------------------------- 00002 SWORD 2000 - Software With Objects for Rapid Development 00003 Copyright (C) 2003 Eric NICOLAS 00004 ---------------------------------------------------------------------------- 00005 SWORD is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU Lesser General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 SWORD is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public License 00016 along with SWORD; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 --------------------------------------------------------------------------*/ 00019 #ifndef _SWORD_TIME_CHRONOGRAPH_ 00020 #define _SWORD_TIME_CHRONOGRAPH_ 00021 00022 namespace sword { 00023 00037 class SWORDDECL Chronograph { 00038 public: 00040 00043 Chronograph(); 00044 ~Chronograph(); 00045 00047 00050 void clear(); 00051 00053 00055 void start(); 00056 00058 00062 void stop(); 00063 00065 00069 word32 elapsedTimeInMillis(); 00070 00072 /* More precision is available in the decimal part of the returned 00073 * value. This method can be called either 'during measurement' 00074 * (between a start() and a stop() ), or 'post morten' (after a stop() ). 00075 * \see elapsedTimeInMillis, start, stop 00076 */ 00077 double elapsedTimeInSec(); 00078 00079 private: 00080 // The two platform-dependant methods 00081 static int64 now_(); // gets the current timestamp 00082 static int64 freq_(); // gets the resolution of now() 00083 00084 int64 start_; 00085 int64 elapsed_; 00086 int64 freqInMillis_; 00087 double freqInSec_; 00088 bool active_; 00089 }; 00090 00091 } // namespace sword 00092 00093 #include "sword.private/time.Chronograph.inl" 00094 00095 #endif // _SWORD_TIME_CHRONOGRAPH_
1.3-rc2