Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

pgtimerobject.h

Go to the documentation of this file.
00001 /*
00002     ParaGUI - crossplatform widgetset
00003     Copyright (C) 2000,2001,2002  Alexander Pipelka
00004  
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009  
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014  
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  
00019     Alexander Pipelka
00020     pipelka@teleweb.at
00021  
00022     Last Update:      $Author: mbickel $
00023     Update Date:      $Date: 2007-04-13 16:15:57 $
00024     Source File:      $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/include/pgtimerobject.h,v $
00025     CVS/RCS Revision: $Revision: 1.2 $
00026     Status:           $State: Exp $
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

Generated on Tue Jun 24 01:27:49 2008 for Advanced Strategic Command by  doxygen 1.4.2