Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeTimer Class Reference

pure virtual mix-in class for timers in Cascade More...

#include <cascade/app/CascadeTimer.h>

Inheritance diagram for CascadeTimer:

CascadeObject List of all members.

Public Member Functions

 CascadeTimer ()
virtual ~CascadeTimer ()
u32 SetTimer (u32 nMilliseconds)
void KillTimer (u32 nTimerID)
virtual void OnTimer (u32 nTimerID)=0

Detailed Description

pure virtual mix-in class for timers in Cascade

Skip the description

CascadeTimer is a mix-in class that allows any class that is running in the context of a CascadeApp to receive timer notifications.
Example Usage:

    class MyWindow : public CascadeWindow, CascadeTimer
    {
    public:
        virtual void OnTimer(u32 nTimerID)
        {
            if (m_nTimerID == nTimerID) { KillTimer(nTimerID); m_nTimerID = 0; }
        };
    public:
        u32 m_nTimerID;
    };

    MyWindow myWindow;
    myWindow.m_nTimerID = myWindow.SetTimer(1000); // set a timer to fire every 1000 ms
    

In this example, the CascadeTimer is mixed into the MyWindow class. A timer is set to fire every 1000 milliseconds and its timer id is remembered in the member variable m_nTimerID. The first time the timer is fired, the timer is killed in OnTimer(). Note that we make sure that the timer id passed into OnTimer is the timer id of the timer we created. In this example that is overkill since we've only set one timer on the MyWindow CascadeTimer derived object.

Timer notifications are always delivered to the app's main thread. To avoid thread contention for the CascadeApp object, all CascadeTimer functions must only be called within the context of the main app thread.

See also:
CascadeApp

class CascadeTimer


Constructor & Destructor Documentation

CascadeTimer::CascadeTimer  ) 
 

default constructor

The CascadeTimer constructor is lightweight.

virtual CascadeTimer::~CascadeTimer  )  [virtual]
 

destructor

The CascadeTimer destructor is lightweight.


Member Function Documentation

void CascadeTimer::KillTimer u32  nTimerID  ) 
 

kills a previously created timer

KillTimer() kills a timer that was previously set with SetTimer().

Parameters:
nTimerID the id of the timer to kill
See also:
SetTimer

virtual void CascadeTimer::OnTimer u32  nTimerID  )  [pure virtual]
 

called whenever a timer expires

OnTimer() is called within the context of a CascadeApp's main thread whenever the timer identified by nTimerID fires.

Parameters:
nTimerID the id of the timer to kill
See also:
SetTimer

u32 CascadeTimer::SetTimer u32  nMilliseconds  ) 
 

sets a new timer

SetTimer() sets a timer to repeatedly expire every nMilliseconds until KillTimer() is called. Whenever the timer expires, OnTimer() is called.

Parameters:
nMilliseconds the duration of the timer in milliseconds
Returns:
the id of the timer or zero if the timer couldn't be set
See also:
KillTimer

OnTimer


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:21 2005 for Cascade Library by  doxygen 1.4.1