BWAPI
|
00001 #pragma once 00002 #include <windows.h> 00003 #include "Utils/CSingleton.h" 00004 #include <BWAPI.h> 00005 #include <string> 00006 #include <exception> 00007 00008 using namespace BWAPI; 00009 00010 struct TimeManaged; 00011 00012 class TooLongException: public std::exception 00013 { 00014 virtual const char* what() const throw() 00015 { 00016 return "an update function took more than 40ms"; 00017 } 00018 }; 00019 00022 /*class ThreadAbort 00023 { 00024 __declspec (noreturn) static void Throw(); 00025 public: 00026 static bool RaiseInThread(HANDLE hThread); 00027 static void DontOptimize() throw (...); 00028 };*/ 00029 00030 00038 class TimeManager : public CSingleton<TimeManager> 00039 { 00040 friend class CSingleton<TimeManager>; 00041 00042 private: 00043 TimeManager(); 00044 ~TimeManager(); 00045 std::list<TimeManaged*> _managed; 00046 00047 public: 00048 // Common interface 00049 void update(); 00050 std::string getName() const; 00051 void display() const; // display ellapsed TimeManager. 00052 void insert(TimeManaged* toManage); 00053 const std::list<TimeManaged*>& getManaged() const; 00054 00055 // TimeManager 00056 static VOID CALLBACK suspendAll( // static for the purpose of TIMERPROC C function call 00057 HWND hwnd, // handle to window for timer messages 00058 UINT message, // WM_TIMER message 00059 UINT idTimer, // timer identifier 00060 DWORD dwTime // current system time 00061 ); 00062 00063 private: 00064 unsigned long frameCount; // frame count since the begining 00065 };