rwlogo

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
List of all members | Public Member Functions
IlvTimer Class Reference

Timer class. More...

#include <ilviews/base/timer.h>

Inherited by IlvSharedTimer, and IlvSmartTimer.

Public Member Functions

 IlvTimer (IlvDisplay *display, int secs=1, int millis=0, IlvTimerProc proc=0, IlAny arg=0)
 Constructor. More...
 
virtual void doIt ()
 Calls the internal function set in the constructor or by setProc. More...
 
IlvDisplaygetDisplay () const
 Gets the display object. More...
 
IlUInt getPeriod () const
 Gets the period of the object. More...
 
virtual IlBoolean isRunning () const
 Indicates whether the timer is currently running. More...
 
virtual void run ()
 Launches the timer. More...
 
virtual void run (int secs, int millis=0)
 Launches the timer with a new time period. More...
 
IlBoolean runOnce () const
 Checks the "run once" state of this timer. More...
 
void runOnce (IlBoolean runOnce)
 Sets the "run once" state of this timer. More...
 
void setProc (IlvTimerProc proc, IlAny arg=0)
 Sets the user-defined function that will be called when the timer wakes up. More...
 
virtual void suspend ()
 Stops the timer. More...
 

Detailed Description

Timer class.

Library: xviews or winviews or mviews (mutually exclusive)

Rogue Wave Views has an internal mechanism for implementing timers. The internal mechanism is hidden and system-dependent. It is based on the IlvTimer class.
The purpose of a timer is to call a function repeatedly, once every given time period. To call a function this way, create an IlvTimer instance and call its member function run. The timer object calls its member function doIt each time the period expires. Timers are based on the time-out mechanisms of the display system. The timer automatically repeats the call to doIt after every period if the timer is not specified to run only once. The IlvTimer class can be used in two different cases:

A timer is attached to an instance of the IlvDisplay class.

See Also
IlvTimerProc.

Constructor & Destructor Documentation

IlvTimer::IlvTimer ( IlvDisplay display,
int  secs = 1,
int  millis = 0,
IlvTimerProc  proc = 0,
IlAny  arg = 0 
)

Constructor.

Initializes a new timer for a given display.

Parameters
displayThe display instance of this timer.
secsThe number of seconds of this timer's period.
millisThe number of milliseconds of this timer's period.
procThe procedure that is called regularly.
argA user argument sent to proc.

Member Function Documentation

virtual void IlvTimer::doIt ( )
virtual

Calls the internal function set in the constructor or by setProc.

This is the virtual member function that is called when the timer is running. Its default implementation consists of calling the internal function that you may have set in the constructor call or in a call to the member function setProc. You can also overload this member function to define your own implementation.

IlvDisplay* IlvTimer::getDisplay ( ) const

Gets the display object.

Returns
A pointer to the IlvDisplay object for which this object was created.
IlUInt IlvTimer::getPeriod ( ) const

Gets the period of the object.

Returns
The period of the object in milliseconds.
virtual IlBoolean IlvTimer::isRunning ( ) const
virtual

Indicates whether the timer is currently running.

An IlBoolean value that indicates whether the timer is currently running.

Returns
IlTrue if the timer is currently running. If IlFalse, the timer is suspended.
virtual void IlvTimer::run ( )
virtual

Launches the timer.

Launches the timer with its internal time period.

virtual void IlvTimer::run ( int  secs,
int  millis = 0 
)
virtual

Launches the timer with a new time period.

Lets you specify a new period which is ( 1000 * secs + millis ), in milliseconds. Then it launches the timer.

Parameters
secsThe number of seconds of the period.
millisThe number of milliseconds added to the period.
IlBoolean IlvTimer::runOnce ( ) const

Checks the "run once" state of this timer.

If the "run once" state is set to IlTrue, the timer will not be rearmed when called. This means that it will run only once. However, after the first call to doIt is complete-and you do not need the timer anymore-you need to delete it.

void IlvTimer::runOnce ( IlBoolean  runOnce)

Sets the "run once" state of this timer.

Parameters
runOnceThe new "run once" state.
void IlvTimer::setProc ( IlvTimerProc  proc,
IlAny  arg = 0 
)

Sets the user-defined function that will be called when the timer wakes up.

Parameters
procSpecifies the function to be called.
argSpecifies a user-defined argument for the function.
virtual void IlvTimer::suspend ( )
virtual

Stops the timer.

Stops the timer. The object is still valid but is quiet.


© Copyright 2015, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.