00001 00002 /* 00003 * The aedTimer class 00004 * A _very_ simple timer 00005 * Initial design by Eduardo B. Fonseca <ebf@aedsolucoes.com.br> 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public 00018 * License along with this library; if not, write to the Free 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 */ 00022 00023 #ifndef AEDTIMER_H 00024 #define AEDTIMER_H 00025 00026 #include "aedObject.h" 00027 00033 class DLLEXPORT aedTimer:public aedObject 00034 { 00035 public: 00036 aedTimer(); 00037 ~aedTimer(); 00038 00041 void setAlarm(Uint32 time); 00042 00044 void enable(bool state); 00045 00046 private: 00047 /* The timer class uses static member function (timer_cb) as the 00048 * callback for a SDL timer; since static functions don't have 'this' 00049 * pointer, timer_cb receives it via its second parameter (void *). 00050 */ 00051 static Uint32 timer_cb(Uint32 interval, void *p); 00052 00053 bool m_IsEnabled; 00054 Uint32 m_AlarmTime, m_CurTicks, m_LastTicks; 00055 SDL_TimerID m_TID; 00056 }; 00057 00058 #if defined(_MSC_VER) 00059 DLLEXTERN template DLLEXPORT aedFunctor1Arg < stub, aedTimer >; 00060 #endif 00061 00062 #endif