00001 #ifndef __CONTROL_H 00002 #define __CONTROL_H 00003 00004 #include <windows.h> 00005 00013 class Control 00014 { 00015 public: 00016 virtual ~Control() { } 00017 00023 virtual void SetDelay(int d) 00024 { 00025 m_delay = d; 00026 m_lastTime -= m_delay; 00027 } 00028 00033 virtual unsigned int GetIteration() { return m_iteration; } 00034 00039 virtual bool Iterate() = 0; 00040 00044 virtual void Snapshot() {} 00045 00046 protected: 00047 Control() 00048 { 00049 m_lastTime = GetTickCount(); 00050 m_iteration = 0; 00051 } 00052 00053 virtual bool IsReadyToIterate() 00054 { 00055 if(m_delay==0) 00056 return true; 00057 00058 unsigned int currentTime = GetTickCount(); 00059 if(currentTime > m_lastTime + m_delay) 00060 { 00061 m_lastTime = currentTime; 00062 return true; 00063 } 00064 return false; 00065 } 00066 00067 virtual bool IsStopCriteriaMet() = 0; 00068 00069 protected: 00070 int m_delay; 00071 unsigned int m_lastTime; 00072 unsigned int m_iteration; 00073 }; 00074 00075 00076 #endif