00001 /*********************************************************************** 00002 * 00003 * KRYPTOS - Educational software for teaching cryptography 00004 * For more information, see http://www.kryptosproject.org/ 00005 * Submissions may be sent to kryptos@gmu.edu (see web site for details) 00006 * 00007 * 00008 * Copyright (c) 2002-2004 George Mason University 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject 00016 * to the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 00025 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 00026 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 00027 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00028 * 00029 ***********************************************************************/ 00030 #ifndef __KRYPTOS_TIMER_H 00031 #define __KRYPTOS_TIMER_H 00032 00033 #include "cputicker.h" 00034 00035 class CKryptosTimer { 00036 public: 00037 CKryptosTimer(); 00038 ~CKryptosTimer(); 00039 CKryptosTimer(const CCPUTicker &oldTicker); 00040 void Reset(); // Reset timer values to zero 00041 void Start(); // Start Timer 00042 void Stop(); // Stop Timer 00043 __int64 GetClockTicks(); 00044 double GetSeconds(); 00045 void GlobalInit(); // Global Initialization for all timing mechanisms 00046 00047 private: 00048 CCPUTicker *ticker; 00049 __int64 base; // current reference point (clock ticks) 00050 __int64 total; // running total counter (clock ticks) 00051 double baseSeconds; // current reference point (seconds) 00052 double totalSeconds; // running total counter (seconds) 00053 bool timing; // Is the timer running? 00054 }; 00055 00056 #endif