?? asl_timer.h
字號:
//-----------------------------------------------------------------------------
//
// ____ Azure Star Game Engine 藍星游戲引擎 ____
//
// Copyright (c) 2006, 藍星工作室
// All rights reserved.
//
// 文件名稱: asl_timer.h
// 摘 要: 高精度計時器類定義
//
// 當前版本: 1.0
// 作 者: 湯 祺
// 創建日期: 2006-7-26
//
//-----------------------------------------------------------------------------
#ifndef ASL_TIMER_INCLUDE
#define ASL_TIMER_INCLUDE
#pragma once
#include "asl_utils.h"
//-----------------------------------------------------------------------------
namespace ASL
{
//-----------------------------------------------------------------------------
// 類名: ASLTimer
// 功能: 高精度計時器類
// 本類為高精度計時器, 需要硬件支持, 在某些配置過低的機器上可能無法運行.
// 本類的使用方式完全類似一個標準秒表, 支持開始/停止/暫停/讀數等操作.
//-----------------------------------------------------------------------------
class ASLTimer
{
// 計時器狀態枚舉定義
private:
enum TimerStatus { tsRun, tsStop, tsPause };
// 構造/析構函數定義
public:
ASLTimer(int nPrecision = 10000, bool bPlay = true) throw(ASLSimpleException);
~ASLTimer(void);
// 公有函數
public:
//設置計時器精度
void SetPrecision(int nPrecision = 10000)
{ ASSERT(nPrecision > 0); m_nPrecision = nPrecision; }
// 取計時器精度
int GetPrecision(void) const { return m_nPrecision; }
// 取當前計時器讀數
DWORD GetTime(void);
// 開始計時
void Play(void);
// 停止計時
void Stop(void);
// 暫停計時
void Pause(void);
// 私有函數
private:
// 取系統計時器的計數值
__int64 GetCurrentCount(void);
// 成員變量
private:
static __int64 m_n64Freq; // 計時器頻率
__int64 m_n64TimeBegin; // 開始時刻
__int64 m_n64TimeEnd; // 停止時刻
int m_nPrecision; // 計時器精度
TimerStatus m_TimerStatus; // 計時器狀態
}; // ASLTimer類定義結束
} // namespace ASL
#endif // ASL_TIMER_INCLUDE
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -