1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt: Wt::WTimer Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<div class="navpath"><a class="el" href="namespaceWt.html">Wt</a>::<a class="el" href="classWt_1_1WTimer.html">WTimer</a>
</div>
</div>
<div class="contents">
<h1>Wt::WTimer Class Reference</h1><!-- doxytag: class="Wt::WTimer" --><!-- doxytag: inherits="Wt::WObject" -->A utility class which provides timer signals and single-shot timers.
<a href="#_details">More...</a>
<p>
<code>#include <Wt/WTimer></code>
<p>
<div class="dynheader">
Inheritance diagram for Wt::WTimer:</div>
<div class="dynsection">
<p><center><img src="classWt_1_1WTimer__inherit__graph.png" border="0" usemap="#Wt_1_1WTimer__inherit__map" alt="Inheritance graph"></center>
<map name="Wt_1_1WTimer__inherit__map">
<area shape="rect" href="classWt_1_1WObject.html" title="A base class for objects that participate in the signal/slot system." alt="" coords="5,5,101,32"></map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div>
<p>
<a href="classWt_1_1WTimer-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="1fb659aac40b49b3ec7631d558884847"></a><!-- doxytag: member="Wt::WTimer::WTimer" ref="1fb659aac40b49b3ec7631d558884847" args="(WObject *parent=0)" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#1fb659aac40b49b3ec7631d558884847">WTimer</a> (<a class="el" href="classWt_1_1WObject.html">WObject</a> *parent=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Construct a new timer with the given parent. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="6b983b4aa0a3594cad4a236f5a4acd0b"></a><!-- doxytag: member="Wt::WTimer::~WTimer" ref="6b983b4aa0a3594cad4a236f5a4acd0b" args="()" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#6b983b4aa0a3594cad4a236f5a4acd0b">~WTimer</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destuctor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="3aedc0ad65a5d57bea4b805a92d7736d"></a><!-- doxytag: member="Wt::WTimer::interval" ref="3aedc0ad65a5d57bea4b805a92d7736d" args="() const " -->
int </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#3aedc0ad65a5d57bea4b805a92d7736d">interval</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the interval (msec). <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="3a4070540a6b0e10bf1ee7bd607334fc"></a><!-- doxytag: member="Wt::WTimer::setInterval" ref="3a4070540a6b0e10bf1ee7bd607334fc" args="(int msec)" -->
void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#3a4070540a6b0e10bf1ee7bd607334fc">setInterval</a> (int msec)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets the interval (msec). <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="eabde106e48ea67e10c4043609b85493"></a><!-- doxytag: member="Wt::WTimer::isActive" ref="eabde106e48ea67e10c4043609b85493" args="() const " -->
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#eabde106e48ea67e10c4043609b85493">isActive</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns if the timer is running. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="61dd8a5ac6fc6d9bd995e08ff7fae83c"></a><!-- doxytag: member="Wt::WTimer::isSingleShot" ref="61dd8a5ac6fc6d9bd995e08ff7fae83c" args="() const " -->
bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#61dd8a5ac6fc6d9bd995e08ff7fae83c">isSingleShot</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Is this timer set to fire only once. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#92ae68d15de600174afdd2e443397604">setSingleShot</a> (bool singleShot)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Configures this timer to fire only once. <a href="#92ae68d15de600174afdd2e443397604"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#e167fbd3eb981a2fce52e9a4b3b6e0af">start</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Starts the timer. <a href="#e167fbd3eb981a2fce52e9a4b3b6e0af"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#73c5d1b882af4835384ccdc07a650e34">stop</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Stops the timer. <a href="#73c5d1b882af4835384ccdc07a650e34"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classWt_1_1EventSignal.html">EventSignal</a>< <a class="el" href="classWt_1_1WMouseEvent.html">WMouseEvent</a> > & </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#2a66c6a51df2b0ab42258abf2ebd0399">timeout</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Signal emitted when the timer timeouts. <a href="#2a66c6a51df2b0ab42258abf2ebd0399"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr>
<tr><td class="memTemplParams" nowrap colspan="2">template<class T, class V> </td></tr>
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">static void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#47340f28a1c9d284f8b085ee4ed5924a">singleShot</a> (int msec, T *receiver, void(V::*method)())</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">This static function calls a slot after a given time interval. <a href="#47340f28a1c9d284f8b085ee4ed5924a"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A utility class which provides timer signals and single-shot timers.
<p>
To use a timer, create a WTimer instance, set the timer interval using <a class="el" href="classWt_1_1WTimer.html#3a4070540a6b0e10bf1ee7bd607334fc" title="Sets the interval (msec).">setInterval()</a> and connect a slot to the timeout signal. Then, start the timer using <a class="el" href="classWt_1_1WTimer.html#e167fbd3eb981a2fce52e9a4b3b6e0af" title="Starts the timer.">start()</a>. An active timer may be cancelled at any time using <a class="el" href="classWt_1_1WTimer.html#73c5d1b882af4835384ccdc07a650e34" title="Stops the timer.">stop()</a>.<p>
By default, a timer will continue to generate events until you <a class="el" href="classWt_1_1WTimer.html#73c5d1b882af4835384ccdc07a650e34" title="Stops the timer.">stop()</a> it. To create a timer that will fire only once, use <a class="el" href="classWt_1_1WTimer.html#92ae68d15de600174afdd2e443397604" title="Configures this timer to fire only once.">setSingleShot()</a>.<p>
There is also a convience static method <a class="el" href="classWt_1_1WTimer.html#47340f28a1c9d284f8b085ee4ed5924a" title="This static function calls a slot after a given time interval.">singleShot()</a>.<p>
When connecting stateless slot implementations to the timeout signal, these stateless slot implementations will be used as for any other signal (when Ajax is available).<p>
In clients without (enabled) JavaScript support, the minimum resolution of the timer is one second (1000 milli-seconds), and it is probably wise to use timers sparingly.<p>
A <a class="el" href="classWt_1_1WTimer.html" title="A utility class which provides timer signals and single-shot timers.">WTimer</a> is only usable inside of a Wt event loop.<p>
If you want to create a timer outside the Wt event loop, take a look at asio deadline_timer.<p>
Timers are one way to provide updates of a web page without the user generating an event. Alternatively you may consider server-initiated updates, see <a class="el" href="classWt_1_1WApplication.html#d9631ca64e68d30d40cb49c90e55223d" title="Enables server-initiated updates.">WApplication::enableUpdates()</a>.<p>
Usage example: <div class="fragment"><pre class="fragment"> <span class="comment">// setup a timer which calls MyClass::timeout() every 2 seconds, until timer->stop() is called.</span>
<a class="code" href="classWt_1_1WTimer.html" title="A utility class which provides timer signals and single-shot timers.">Wt::WTimer</a> *timer = <span class="keyword">new</span> <a class="code" href="classWt_1_1WTimer.html" title="A utility class which provides timer signals and single-shot timers.">Wt::WTimer</a>();
timer-><a class="code" href="classWt_1_1WTimer.html#3a4070540a6b0e10bf1ee7bd607334fc" title="Sets the interval (msec).">setInterval</a>(2000);
timer-><a class="code" href="classWt_1_1WTimer.html#2a66c6a51df2b0ab42258abf2ebd0399" title="Signal emitted when the timer timeouts.">timeout</a>().connect(SLOT(<span class="keyword">this</span>, MyClass::timeout));
timer-><a class="code" href="classWt_1_1WTimer.html#e167fbd3eb981a2fce52e9a4b3b6e0af" title="Starts the timer.">start</a>();
</pre></div> <hr><h2>Member Function Documentation</h2>
<a class="anchor" name="92ae68d15de600174afdd2e443397604"></a><!-- doxytag: member="Wt::WTimer::setSingleShot" ref="92ae68d15de600174afdd2e443397604" args="(bool singleShot)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::WTimer::setSingleShot </td>
<td>(</td>
<td class="paramtype">bool </td>
<td class="paramname"> <em>singleShot</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Configures this timer to fire only once.
<p>
A Timer is by default not single shot, and will fire continuously, until it is stopped.<p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTimer.html#47340f28a1c9d284f8b085ee4ed5924a" title="This static function calls a slot after a given time interval.">singleShot()</a> </dd></dl>
</div>
</div><p>
<a class="anchor" name="47340f28a1c9d284f8b085ee4ed5924a"></a><!-- doxytag: member="Wt::WTimer::singleShot" ref="47340f28a1c9d284f8b085ee4ed5924a" args="(int msec, T *receiver, void(V::*method)())" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template<class T, class V> </div>
<table class="memname">
<tr>
<td class="memname">void Wt::WTimer::singleShot </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"> <em>msec</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">T * </td>
<td class="paramname"> <em>receiver</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void(V::*)() </td>
<td class="paramname"> <em>method</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [inline, static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This static function calls a slot after a given time interval.
<p>
For example, the following code will call this->doSome() after 2 seconds: <div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WTimer.html#47340f28a1c9d284f8b085ee4ed5924a" title="This static function calls a slot after a given time interval.">WTimer::singleShot</a>(2000, SLOT(<span class="keyword">this</span>, MyClass::doSome));
</pre></div>
</div>
</div><p>
<a class="anchor" name="e167fbd3eb981a2fce52e9a4b3b6e0af"></a><!-- doxytag: member="Wt::WTimer::start" ref="e167fbd3eb981a2fce52e9a4b3b6e0af" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::WTimer::start </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Starts the timer.
<p>
The timer will be <a class="el" href="classWt_1_1WTimer.html#eabde106e48ea67e10c4043609b85493" title="Returns if the timer is running.">isActive()</a>, until either the interval has elapsed, after which the timeout signal is activated, or until <a class="el" href="classWt_1_1WTimer.html#73c5d1b882af4835384ccdc07a650e34" title="Stops the timer.">stop()</a> is called.
</div>
</div><p>
<a class="anchor" name="73c5d1b882af4835384ccdc07a650e34"></a><!-- doxytag: member="Wt::WTimer::stop" ref="73c5d1b882af4835384ccdc07a650e34" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::WTimer::stop </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Stops the timer.
<p>
You may stop the timer during its <a class="el" href="classWt_1_1WTimer.html#2a66c6a51df2b0ab42258abf2ebd0399" title="Signal emitted when the timer timeouts.">timeout()</a>, or cancel a running timer at any other time.<p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTimer.html#e167fbd3eb981a2fce52e9a4b3b6e0af" title="Starts the timer.">start()</a> </dd></dl>
</div>
</div><p>
<a class="anchor" name="2a66c6a51df2b0ab42258abf2ebd0399"></a><!-- doxytag: member="Wt::WTimer::timeout" ref="2a66c6a51df2b0ab42258abf2ebd0399" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classWt_1_1EventSignal.html">EventSignal</a>< <a class="el" href="classWt_1_1WMouseEvent.html">WMouseEvent</a> > & Wt::WTimer::timeout </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Signal emitted when the timer timeouts.
<p>
The WMouseEvent does not provide any meaningful information but is an implementation artefact.
</div>
</div><p>
</div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:07 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>
|