Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

HWTimer.h

Go to the documentation of this file.
00001 //
00002 // Author: Steve Kilthau
00003 // Date:   January 4, 2001
00004 //
00005 
00006 #ifndef _HWTIMER_H_
00007 #define _HWTIMER_H_
00008 
00009 #if defined(WIN32)
00010 #include <windows.h>
00011 #else
00012 #include <sys/time.h>
00013 #endif
00014 
00015 //
00016 // This class implements a basic hardware clock on systems
00017 // that have hardware which support a high performance
00018 // counter.
00019 //
00020 class HWTimer
00021 {
00022 public:
00023     //
00024     // Constructors and destructor.  If the system offers a
00025     // hardware clock, the default constructor sets up the
00026     // appropriate values.
00027     //
00028     HWTimer();
00029     HWTimer(HWTimer& t);
00030     ~HWTimer();
00031 
00032     //
00033     // Determines whether the system offers a hardware clock.
00034     //
00035     bool IsSupported(void);
00036 
00037     //
00038     // Gets the elapsed time since the last call to
00039     // GetElapsedTimeDouble/GetElapsedTimeFloat, or since
00040     // the return from the last call to SleepFloat/SleepDouble.
00041     //
00042     float GetElapsedTimeFloat(void);
00043     double GetElapsedTimeDouble(void);
00044 
00045     //
00046     // Causes the program to halt until s seconds have 
00047     // elapsed since the last call to GetElapsedTimeFloat,
00048     // GetElapsedTimeDouble, SleepFloat, or SleepDouble.
00049     // Before the function returns, the timer is updated.
00050     //
00051     void SleepFloat(float s);
00052     void SleepDouble(double s);
00053 
00054     //
00055     // Assignment operator.
00056     //
00057     HWTimer& operator=(HWTimer& rhs);
00058 
00059 private:
00060 #if defined(WIN32)
00061     LARGE_INTEGER  m_LastCount;
00062     float          m_FloatFreq;
00063     double         m_DoubleFreq;
00064 #else
00065     struct timeval m_LastCount;
00066 #endif
00067     bool           m_IsSupported;
00068 };
00069 
00070 #endif

Generated on Wed Dec 15 21:20:29 2004 for vuVolume by  doxygen 1.3.9.1