00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TIMER_H
00023 #define TIMER_H
00024
00025 #include <list>
00026 #include "SDL/SDL.h"
00027 #include "basicobject.h"
00028
00035 using namespace std;
00036
00051 class DECLSPEC FrameTimer
00052 {
00053 public:
00057 typedef BasicObject::Callback Callback;
00061 struct CbInfo
00062 {
00067 void init( Callback c, BasicObject * d, Uint32 iv, Uint32 n )
00068 {
00069 cb = c;
00070 pData = d;
00071 tInterval = iv;
00072 tNext = n;
00073 }
00077 Callback cb;
00082 BasicObject * pData;
00087 Uint32 tInterval;
00092 Uint32 tNext;
00093
00094 };
00099 DECLSPEC FrameTimer();
00100 virtual DECLSPEC ~FrameTimer();
00108 DECLSPEC bool setInterval( CbInfo * id, Uint32 iv );
00119 DECLSPEC CbInfo * addCallback( Callback c, BasicObject * d, Uint32 iv );
00124 DECLSPEC void removeCallback( CbInfo * pCb );
00125
00130 static FrameTimer * the;
00137 DECLSPEC static FrameTimer *getThe();
00138 private:
00139 typedef list<CbInfo*>::iterator CbInfoIter;
00140 list<CbInfo*> cbs, cbsInactive;
00141 void doTimer();
00142
00143 friend class UiManager;
00144 };
00145
00146 #endif