frametimer.h

Go to the documentation of this file.
00001 /********************************************************************************/
00002 /*                                                                              */
00003 /*  Netrinjo-Engine - a library for game-development                            */
00004 /*  Copyright (C) 2005 by Tobias Nadler                                         */
00005 /*                                                                              */
00006 /*  This library is free software; you can redistribute it and/or               */
00007 /*  modify it under the terms of the GNU Lesser General Public                  */
00008 /*  License as published by the Free Software Foundation; either                */
00009 /*  version 2.1 of the License, or (at your option) any later version.          */
00010 /*                                                                              */
00011 /*  This library is distributed in the hope that it will be useful,             */
00012 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of              */
00013 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           */
00014 /*  Lesser General Public License for more details.                             */
00015 /*                                                                              */
00016 /*  You should have received a copy of the GNU Lesser General Public            */
00017 /*  License along with this library; if not, write to the Free Software         */
00018 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */
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; // read-only!
00092         Uint32 tNext; // read-only!
00093 //      friend class FrameTimer;
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

Generated on Wed May 9 17:35:55 2007 for netrinjo by  doxygen 1.5.1