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

Ars::Timer Class Reference

#include <arstimer.h>

Collaboration diagram for Ars::Timer:

Collaboration graph
[legend]

Public Member Functions

 Timer (MessageClient *pOwner=0)
virtual ~Timer (void)
 Standard destructor.

void StartTimer (unsigned long int Interval, bool bAutoRestart=false)
void StopTimer (void)
 Stops the running timer.

bool IsRunning (void)
 true is the timer is currently running

long int GetCount (void) const
 The count of times the timer has fired.

void ResetCount (void)
 Resets the internal counter to zero.

Uint32 TimerHit (Uint32 Interval)

Protected Attributes

SDL_TimerID m_TimerID
 The ID of the SDL timer used.

bool m_bAutoRestart
 If this is true, the timer will restart as soon as it expires.

long int m_iCounter
 A simple counter that increments each time the timer fires.

MessageClientm_pOwner
 A pointer the the timer's owner. this is where messages are destined.


Detailed Description

A simple timer class Timer will post a CTRL_TIMER message every time the timer expires

Definition at line 14 of file arstimer.h.


Constructor & Destructor Documentation

Ars::Timer::Timer MessageClient pOwner = 0  ) 
 

Standard constructor

Parameters:
pOwner A pointer to the timer 'owner'. This is what the timer will set as the destination for it's messages. Use 0 to broadcast the message.

Definition at line 11 of file arstimer.cpp.

00011                                     :
00012         m_TimerID(0),
00013         m_bAutoRestart(false),
00014         m_iCounter(0),
00015         m_pOwner(pOwner)
00016 {
00017 
00018 }

Ars::Timer::~Timer void   )  [virtual]
 

Standard destructor.

Definition at line 21 of file arstimer.cpp.

References StopTimer().

00022 {
00023         StopTimer();
00024 }


Member Function Documentation

long int Ars::Timer::GetCount void   )  const [inline]
 

The count of times the timer has fired.

Definition at line 36 of file arstimer.h.

References m_iCounter.

00036 { return m_iCounter; }

bool Ars::Timer::IsRunning void   )  [inline]
 

true is the timer is currently running

Definition at line 33 of file arstimer.h.

References m_TimerID.

00033 { return m_TimerID != 0; }

void Ars::Timer::ResetCount void   )  [inline]
 

Resets the internal counter to zero.

Definition at line 39 of file arstimer.h.

References m_iCounter.

00039 { m_iCounter = 0; }

void Ars::Timer::StartTimer unsigned long int  Interval,
bool  bAutoRestart = false
 

Start the timer. When the timer expires, it will post an CTRL_TIMER message

Parameters:
Interval The time interval in milliseconds before the timer will expire
bAutoRestart If this is true, the timer will restart again as soon as it expires

Definition at line 27 of file arstimer.cpp.

References m_bAutoRestart, m_TimerID, and Ars::TimerCallback().

Referenced by Ars::XToolTip::evMouseMove().

00028 {
00029         m_bAutoRestart = bAutoRestart;
00030         if (!m_TimerID)
00031                 m_TimerID = SDL_AddTimer(Interval, &TimerCallback, this);
00032 }

void Ars::Timer::StopTimer void   ) 
 

Stops the running timer.

Definition at line 35 of file arstimer.cpp.

References m_TimerID.

Referenced by Ars::XToolTip::evMouseMove(), TimerHit(), and ~Timer().

00036 {
00037         if (m_TimerID)
00038         {
00039                 SDL_RemoveTimer(m_TimerID);
00040                 m_TimerID = 0;
00041         }
00042 }

Uint32 Ars::Timer::TimerHit Uint32  Interval  ) 
 

For internal use only

For internal use only.

This is where the SDL timer calls back to, and should not be used elsewhere

Definition at line 45 of file arstimer.cpp.

References ArsSendMessage, m_bAutoRestart, m_iCounter, m_pOwner, and StopTimer().

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 }


Field Documentation

bool Ars::Timer::m_bAutoRestart [protected]
 

If this is true, the timer will restart as soon as it expires.

Definition at line 50 of file arstimer.h.

Referenced by StartTimer(), and TimerHit().

long int Ars::Timer::m_iCounter [protected]
 

A simple counter that increments each time the timer fires.

Definition at line 53 of file arstimer.h.

Referenced by GetCount(), ResetCount(), and TimerHit().

MessageClient* Ars::Timer::m_pOwner [protected]
 

A pointer the the timer's owner. this is where messages are destined.

Definition at line 56 of file arstimer.h.

Referenced by TimerHit().

SDL_TimerID Ars::Timer::m_TimerID [protected]
 

The ID of the SDL timer used.

Definition at line 47 of file arstimer.h.

Referenced by IsRunning(), StartTimer(), and StopTimer().


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 04:06:50 2003 for Borqueror by doxygen 1.3.3