StopWatch.h

Go to the documentation of this file.
00001 /*==============================================================================
00002 Copyright 2010 Autodesk, Inc.  All rights reserved.
00003 
00004 Use of this software is subject to the terms of the Autodesk license agreement provided
00005 at the time of installation or download, or which otherwise accompanies this software
00006 in either electronic or hard copy form.   
00007 
00008 //**************************************************************************/
00009 // DESCRIPTION: Classes To Watch Time Consumption For Max's Components
00010 // AUTHOR: Golden Cheng created March 2010
00011 //***************************************************************************/
00012 #pragma once
00013 #include <Windows.h>
00014 #include "utilexp.h"
00015 #include "MaxHeap.h"
00016 
00017 namespace MaxSDK
00018 {
00019     namespace Util
00020     {
00022 
00051         class StopWatch: public MaxHeapOperators
00052         {
00053         public:
00055             enum TimerState
00056             {
00058                 PLAYING =0,
00060                 PAUSED ,
00062                 STOPPED 
00063             };
00065             UtilExport StopWatch();
00067             UtilExport void Start();
00069             UtilExport void Pause();
00071             UtilExport void Resume();
00073             UtilExport void Stop();
00075             UtilExport void Reset();
00077             UtilExport bool IsRunning() const;
00079             UtilExport bool IsPaused() const;
00081             UtilExport bool IsStopped() const;
00083             UtilExport TimerState GetTimerCurrentState() const;
00085             UtilExport double GetElapsedTime() const;
00087             UtilExport void GetLocalTime(SYSTEMTIME* time) const;
00088 
00089         private:
00090             void StartTicking();
00091 
00092             LARGE_INTEGER mStartTime;
00093             LARGE_INTEGER mFreq;
00094             double mElapsedTime;
00095             TimerState mTimerState;
00096         };
00097 
00098     }
00099 }