home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 2.ddi / CLASSINC.ZIP / TIMER.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.6 KB  |  82 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  TIMER.H                                                               */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1992                            */
  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. #pragma option -Vo-
  22. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  23. #pragma option -po-
  24. #endif
  25.  
  26. class Timer
  27. {
  28.  
  29. public:
  30.  
  31.     Timer();
  32.  
  33.     void start();
  34.     void stop();
  35.     void reset();
  36.  
  37.     int status();
  38.     double time();
  39.  
  40.     static double resolution();
  41.  
  42. private:
  43.  
  44.     static unsigned adjust;
  45.     static unsigned calibrate();
  46.     int running;
  47.  
  48.     struct TIME
  49.         {
  50.         unsigned long dosCount;
  51.         unsigned timerCount;
  52.         };
  53.  
  54.     TIME startTime;
  55.  
  56.     double time_;
  57.  
  58. };
  59.  
  60. inline int Timer::status()
  61. {
  62.     return running;
  63. }
  64.  
  65. inline double Timer::time()
  66. {
  67.     return time_/1.E6;
  68. }
  69.  
  70. inline double Timer::resolution()
  71. {
  72.     return 839/1.E9;
  73. }
  74.  
  75. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  76. #pragma option -po.
  77. #endif
  78. #pragma option -Vo.
  79.  
  80. #endif  // __TIMER_H
  81.  
  82.