Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

arstimer.cpp

Go to the documentation of this file.
00001 #include "SdlArs.h"
00002 
00003 namespace Ars
00004 {
00005 Uint32 TimerCallback(Uint32 Interval, void* param)
00006 {
00007         return static_cast<Timer*>(param)->TimerHit(Interval);
00008 }
00009 
00010 
00011 Timer::Timer( MessageClient *pOwner ) :
00012         m_TimerID(0),
00013         m_bAutoRestart(false),
00014         m_iCounter(0),
00015         m_pOwner(pOwner)
00016 {
00017 
00018 }
00019 
00020 
00021 Timer::~Timer(void)
00022 {
00023         StopTimer();
00024 }
00025 
00026 
00027 void Timer::StartTimer(unsigned long int Interval, bool bAutoRestart)
00028 {
00029         m_bAutoRestart = bAutoRestart;
00030         if (!m_TimerID)
00031                 m_TimerID = SDL_AddTimer(Interval, &TimerCallback, this);
00032 }
00033 
00034 
00035 void Timer::StopTimer(void)
00036 {
00037         if (m_TimerID)
00038         {
00039                 SDL_RemoveTimer(m_TimerID);
00040                 m_TimerID = 0;
00041         }
00042 }
00043 
00044 
00045 Uint32 Timer::TimerHit(Uint32 Interval)
00046 {
00047         m_iCounter++;
00048         ArsSendMessage( CtrlMessage( Message::CTRL_TIMER, m_pOwner, this, m_iCounter ) );
00049         if (!m_bAutoRestart)
00050                 StopTimer();
00051 
00052         return Interval;
00053 }
00054 
00055 }

Generated on Fri Dec 5 04:05:59 2003 for Borqueror by doxygen 1.3.3