UQGL Beta(11/04/02)
|
00001 #pragma once 00002 00009 #include "Base.h" 00010 00011 namespace UQ{ 00012 00018 class DLL_EXPORT Task{ 00019 friend class TaskMgrImpl; 00020 00021 public: 00022 static const int NOT_INSERT_ = 0x8000; 00023 00024 public: 00034 Task(int updatePriority = NOT_INSERT_, int renderPriority = NOT_INSERT_); 00035 virtual ~Task(); 00036 00041 virtual void update(void){} 00042 00047 virtual void render(void){} 00048 00055 void erase(void); 00056 00062 void pauseUpdate(void); 00063 00069 void resumeUpdate(void); 00070 00076 void pauseRender(void); 00077 00083 void resumeRender(void); 00084 00090 int getUpdatePriority(void) const; 00091 00097 int getRenderPriority(void) const; 00098 00105 void setUpdatePriority(int updatePriority); 00106 00113 void setRenderPriority(int renderPriority); 00114 00115 private: 00116 struct Impl; 00117 Impl* pImpl_; 00118 }; 00119 00120 class TypeToInt{ 00121 public: 00122 template<typename T> static unsigned int value(void){static unsigned int r = count(); return r;} 00123 private: 00124 static unsigned int count(void){static unsigned int r = 0; return r++;} 00125 }; 00126 00134 class DLL_EXPORT TaskMgr{ 00135 public: 00136 virtual ~TaskMgr(){} 00137 00144 template<typename T> void insert(T* pTask, Task* pParent = 0){insertImpl(TypeToInt::value<T>(), pTask, pParent);} 00145 00151 virtual void clear(void) = 0; 00152 00158 template<typename T> unsigned int count(void) const{return countImpl(TypeToInt::value<T>());} 00159 00167 template<typename T> T* enumerate(unsigned int index) const{return static_cast<T*>(enumerateImpl(TypeToInt::value<T>(), index));} 00168 00177 template<typename T> T* get(void) const{return static_cast<T*>(enumerateImpl(TypeToInt::value<T>(), 0));} 00178 00179 private: 00180 virtual void insertImpl(unsigned int, Task*, Task*) = 0; 00181 virtual unsigned int countImpl(unsigned int) const = 0; 00182 virtual Task* enumerateImpl(unsigned int, unsigned int) const = 0; 00183 }; 00184 00185 } // namespace UQ