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... | |
IlvDisplay * | getDisplay () 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... | |
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:
IlvTimerProc
type. In this case, you simply instantiate an IlvTimer
object, specifying this function, and an argument the function can use. IlvTimer
with overloading of the member function doIt
. A timer is attached to an instance of the IlvDisplay
class.
IlvTimerProc
. 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.
display | The display instance of this timer. |
secs | The number of seconds of this timer's period. |
millis | The number of milliseconds of this timer's period. |
proc | The procedure that is called regularly. |
arg | A user argument sent to proc. |
|
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.
IlvDisplay
object for which this object was created. IlUInt IlvTimer::getPeriod | ( | ) | const |
Gets the period of the object.
|
virtual |
Indicates whether the timer is currently running.
An IlBoolean
value that indicates whether the timer is currently running.
IlTrue
if the timer is currently running. If IlFalse
, the timer is suspended.
|
virtual |
Launches the timer.
Launches the timer with its internal time period.
|
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.
secs | The number of seconds of the period. |
millis | The 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.
runOnce | The 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.
proc | Specifies the function to be called. |
arg | Specifies a user-defined argument for the function. |
|
virtual |
Stops the timer.
Stops the timer. The object is still valid but is quiet.