00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00033 #ifndef PG_TIMEROBJECT_H
00034 #define PG_TIMEROBJECT_H
00035
00036 #include "paragui.h"
00037 #include "pgsignals.h"
00038 #include <map>
00039
00040
00049 class DECLSPEC PG_TimerObject {
00050
00051 public:
00052
00053 typedef unsigned long ID;
00054
00058 template<class datatype = PG_Pointer>
00059 class SignalTimer : public PG_Signal2<PG_TimerObject*, PG_TimerObject::ID, datatype> {}
00060 ;
00061
00067 PG_TimerObject();
00068
00069 virtual ~PG_TimerObject();
00070
00081 PG_TimerObject::ID AddTimer(Uint32 interval);
00082
00088 bool RemoveTimer(PG_TimerObject::ID id);
00089
00090 int SetTimer(Uint32 interval);
00091
00092 void StopTimer();
00093
00101 virtual Uint32 eventTimer(PG_TimerObject::ID id, Uint32 interval);
00102
00103 virtual Uint32 eventTimer(Uint32 interval);
00104
00105 SignalTimer<> sigTimer;
00106
00107 private:
00108
00109 DLLLOCAL static Uint32 callbackTimer(Uint32 interval, void* data);
00110
00111 DLLLOCAL static Uint32 callbackSingleTimer(Uint32 interval);
00112
00113 static PG_TimerObject::ID globalTimerID;
00114
00115 static std::map<PG_TimerObject::ID, PG_TimerObject*> timermap;
00116
00117 static Uint32 objectcount;
00118
00119 static PG_TimerObject* objSingleTimer;
00120
00121 std::map<PG_TimerObject::ID, SDL_TimerID> my_timermap;
00122
00123 SDL_mutex* my_lock;
00124 };
00125
00126 #endif // PG_TIMEROBJECT_H