home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-1.ZIP / CLASSINC.ZIP / TIMER.H < prev    next >
C/C++ Source or Header  |  1992-02-18  |  1KB  |  73 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  TIMER.H                                                               */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991                                  */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __TIMER_H )
  11. #define __TIMER_H
  12.  
  13. #if defined( _Windows ) && !defined( _BUILDRTLDLL )
  14. #error Timer not available for Windows
  15. #endif
  16.  
  17. #if !defined( __DEFS_H )
  18. #include <_defs.h>
  19. #endif
  20.  
  21.  
  22. class Timer
  23. {
  24.  
  25. public:
  26.  
  27.     Timer();
  28.  
  29.     void start();
  30.     void stop();
  31.     void reset();
  32.  
  33.     int status();
  34.     double time();
  35.  
  36.     static double resolution();
  37.  
  38. private:
  39.  
  40.     static unsigned adjust;
  41.     static unsigned calibrate();
  42.     int running;
  43.  
  44.     struct TIME
  45.         {
  46.         unsigned long dosCount;
  47.         unsigned timerCount;
  48.         };
  49.  
  50.     TIME startTime;
  51.  
  52.     double time_;
  53.  
  54. };
  55.  
  56. inline int Timer::status()
  57. {
  58.     return running;
  59. }
  60.  
  61. inline double Timer::time()
  62. {
  63.     return time_/1.E6;
  64. }
  65.  
  66. inline double Timer::resolution()
  67. {
  68.     return 839/1.E9;
  69. }
  70.  
  71. #endif  // __TIMER_H
  72.  
  73.