TNB Library
TnbTickCount.h
[詳解]
1#pragma once
14#include "TnbDef.h"
15
16
17
18#ifdef _WIN32_WCE
19 #define _TnbTIME_Winmm_DISABLE
20#endif
21
22#ifndef _TnbTIME_Winmm_DISABLE
23 #include <mmsystem.h>
24 #pragma comment(lib, "winmm.lib")
25#endif
26
27
28
29//TNB Library
30namespace TNB
31{
32
33
34
57{
58public:
59
64 CTickCount(void) : m_dwTick(m_Get())
65 {
66 }
67
73 explicit CTickCount(bool b) : m_dwTick(m_Get())
74 {
75 m_dwTick -= 0x80000000;
76 }
77
82 void Reset(void)
83 {
84 m_dwTick = m_Get();
85 }
86
92 DWORD GetResetedCount(void) const
93 {
94 return m_dwTick;
95 }
96
102 DWORD GetPassedCount(void) const
103 {
104 return m_Get() - m_dwTick;
105 }
106
114 bool IsPassed(DWORD dwTime) const
115 {
116 return GetPassedCount() >= dwTime;
117 }
118
128 bool IsPassedAndReset(DWORD dwTime, bool isNow = true)
129 {
130 bool r = IsPassed(dwTime);
131 if ( r )
132 {
133 if ( isNow )
134 {
135 Reset();
136 }
137 else
138 {
139 m_dwTick += dwTime;
140 if ( IsPassed(dwTime) )
141 {
142 Reset();
143 }
144 }
145 }
146 return r;
147 }
148
154 void OutputDebugPassedCount(void) const
155 {
156 TRACE1( " passed count = %d(ms)\n", GetPassedCount() );
157 }
158
159private:
160 DWORD m_dwTick;
161
162 #ifndef _TnbDOXYGEN //Document作成用シンボル
163 #ifndef _TnbTIME_Winmm_DISABLE
165 class CAutoPeriod
166 {
167 public:
168 CAutoPeriod(void)
169 {
170 VERIFY(timeBeginPeriod(1) == TIMERR_NOERROR);
171 }
172 ~CAutoPeriod(void)
173 {
174 VERIFY(timeEndPeriod(1) == TIMERR_NOERROR);
175 }
176 };
178 DWORD m_Get(void) const
179 {
180 static CAutoPeriod s_autoPeriod;
181 return ::timeGetTime();
182 }
183 #else
185 DWORD m_Get(void) const
186 {
187 return ::GetTickCount();
188 }
189 #endif
190 #endif // _TnbDOXYGEN
191};
192
193
194
195};//TNB
TNBライブラリの定義ヘッダ
経過時間管理クラス
Definition: TnbTickCount.h:57
CTickCount(void)
コンストラクタ
Definition: TnbTickCount.h:64
bool IsPassedAndReset(DWORD dwTime, bool isNow=true)
[確認] 経過確認&リセット.
Definition: TnbTickCount.h:128
DWORD GetResetedCount(void) const
[取得] Reset時の時間取得.
Definition: TnbTickCount.h:92
bool IsPassed(DWORD dwTime) const
[確認] 経過確認.
Definition: TnbTickCount.h:114
DWORD GetPassedCount(void) const
[取得] 経過時間取得.
Definition: TnbTickCount.h:102
void OutputDebugPassedCount(void) const
[出力] 経過時間表示.
Definition: TnbTickCount.h:154
CTickCount(bool b)
コンストラクタ
Definition: TnbTickCount.h:73
void Reset(void)
[設定] リセット.
Definition: TnbTickCount.h:82
TNB Library
Definition: TnbDoxyTitle.txt:2