<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Wt: Wt::WTimer Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <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> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceWt.html">Wt</a> </li> <li class="navelem"><a class="el" href="classWt_1_1WTimer.html">WTimer</a> </li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="#pub-static-methods">Static Public Member Functions</a> </div> <div class="headertitle"> <div class="title">Wt::WTimer Class Reference</div> </div> </div> <div class="contents"> <!-- doxytag: class="Wt::WTimer" --><!-- doxytag: inherits="Wt::WObject" --> <p>A utility class which provides timer signals and single-shot timers. <a href="classWt_1_1WTimer.html#details">More...</a></p> <p><code>#include <Wt/WTimer></code></p> <div class="dynheader"> Inheritance diagram for Wt::WTimer:</div> <div class="dyncontent"> <div class="center"><img src="classWt_1_1WTimer__inherit__graph.png" border="0" usemap="#Wt_1_1WTimer_inherit__map" alt="Inheritance graph"/></div> <map name="Wt_1_1WTimer_inherit__map" id="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><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div> <p><a href="classWt_1_1WTimer-members.html">List of all members.</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1fb659aac40b49b3ec7631d558884847"></a><!-- doxytag: member="Wt::WTimer::WTimer" ref="a1fb659aac40b49b3ec7631d558884847" args="(WObject *parent=0)" -->  </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#a1fb659aac40b49b3ec7631d558884847">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" align="right" valign="top"><a class="anchor" id="a6b983b4aa0a3594cad4a236f5a4acd0b"></a><!-- doxytag: member="Wt::WTimer::~WTimer" ref="a6b983b4aa0a3594cad4a236f5a4acd0b" args="()" -->  </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#a6b983b4aa0a3594cad4a236f5a4acd0b">~WTimer</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Destuctor. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3aedc0ad65a5d57bea4b805a92d7736d"></a><!-- doxytag: member="Wt::WTimer::interval" ref="a3aedc0ad65a5d57bea4b805a92d7736d" args="() const " --> int </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#a3aedc0ad65a5d57bea4b805a92d7736d">interval</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the interval (msec). <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3a4070540a6b0e10bf1ee7bd607334fc"></a><!-- doxytag: member="Wt::WTimer::setInterval" ref="a3a4070540a6b0e10bf1ee7bd607334fc" args="(int msec)" --> void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#a3a4070540a6b0e10bf1ee7bd607334fc">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" align="right" valign="top"><a class="anchor" id="aeabde106e48ea67e10c4043609b85493"></a><!-- doxytag: member="Wt::WTimer::isActive" ref="aeabde106e48ea67e10c4043609b85493" args="() const " --> bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#aeabde106e48ea67e10c4043609b85493">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" align="right" valign="top"><a class="anchor" id="a61dd8a5ac6fc6d9bd995e08ff7fae83c"></a><!-- doxytag: member="Wt::WTimer::isSingleShot" ref="a61dd8a5ac6fc6d9bd995e08ff7fae83c" args="() const " --> bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#a61dd8a5ac6fc6d9bd995e08ff7fae83c">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" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#a92ae68d15de600174afdd2e443397604">setSingleShot</a> (bool singleShot)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Configures this timer to fire only once. <a href="#a92ae68d15de600174afdd2e443397604"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#ae167fbd3eb981a2fce52e9a4b3b6e0af">start</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Starts the timer. <a href="#ae167fbd3eb981a2fce52e9a4b3b6e0af"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#a73c5d1b882af4835384ccdc07a650e34">stop</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Stops the timer. <a href="#a73c5d1b882af4835384ccdc07a650e34"></a><br/></td></tr> <tr><td class="memItemLeft" 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#a2a66c6a51df2b0ab42258abf2ebd0399">timeout</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Signal emitted when the timer timeouts. <a href="#a2a66c6a51df2b0ab42258abf2ebd0399"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="pub-static-methods"></a> Static Public Member Functions</h2></td></tr> <tr><td class="memTemplParams" colspan="2">template<class T , class V > </td></tr> <tr><td class="memTemplItemLeft" align="right" valign="top">static void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#ac35c02164f78de697258197c5c9202c9">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="#ac35c02164f78de697258197c5c9202c9"></a><br/></td></tr> <tr><td class="memTemplParams" colspan="2">template<class F > </td></tr> <tr><td class="memTemplItemLeft" align="right" valign="top">static void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classWt_1_1WTimer.html#ae0aa0f3402520831531f03f76056e63c">singleShot</a> (int msec, const F &f)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">This static function calls a function after a given time interval. <a href="#ae0aa0f3402520831531f03f76056e63c"></a><br/></td></tr> </table> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><p>A utility class which provides timer signals and single-shot timers. </p> <p>To use a timer, create a WTimer instance, set the timer interval using <a class="el" href="classWt_1_1WTimer.html#a3a4070540a6b0e10bf1ee7bd607334fc" 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#ae167fbd3eb981a2fce52e9a4b3b6e0af" title="Starts the timer.">start()</a>. An active timer may be cancelled at any time using <a class="el" href="classWt_1_1WTimer.html#a73c5d1b882af4835384ccdc07a650e34" title="Stops the timer.">stop()</a>.</p> <p>By default, a timer will continue to generate events until you <a class="el" href="classWt_1_1WTimer.html#a73c5d1b882af4835384ccdc07a650e34" 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#a92ae68d15de600174afdd2e443397604" title="Configures this timer to fire only once.">setSingleShot()</a>. There is also a convience static method <a class="el" href="classWt_1_1WTimer.html#ac35c02164f78de697258197c5c9202c9" title="This static function calls a slot after a given time interval.">singleShot()</a>.</p> <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> <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> <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. If you want to create a timer outside the Wt event loop, take a look at asio deadline_timer.</p> <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#ad9631ca64e68d30d40cb49c90e55223d" title="Enables server-initiated updates.">WApplication::enableUpdates()</a>.</p> <p>Usage example: </p> <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#a1fb659aac40b49b3ec7631d558884847" title="Construct a new timer with the given parent.">Wt::WTimer</a>(); timer-><a class="code" href="classWt_1_1WTimer.html#a3a4070540a6b0e10bf1ee7bd607334fc" title="Sets the interval (msec).">setInterval</a>(2000); timer-><a class="code" href="classWt_1_1WTimer.html#a2a66c6a51df2b0ab42258abf2ebd0399" title="Signal emitted when the timer timeouts.">timeout</a>().connect(<span class="keyword">this</span>, &MyClass::timeout); timer-><a class="code" href="classWt_1_1WTimer.html#ae167fbd3eb981a2fce52e9a4b3b6e0af" title="Starts the timer.">start</a>(); </pre></div> </div><hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a92ae68d15de600174afdd2e443397604"></a><!-- doxytag: member="Wt::WTimer::setSingleShot" ref="a92ae68d15de600174afdd2e443397604" 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> <p>A Timer is by default not single shot, and will fire continuously, until it is stopped.</p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTimer.html#ac35c02164f78de697258197c5c9202c9" title="This static function calls a slot after a given time interval.">singleShot()</a> </dd></dl> </div> </div> <a class="anchor" id="ac35c02164f78de697258197c5c9202c9"></a><!-- doxytag: member="Wt::WTimer::singleShot" ref="ac35c02164f78de697258197c5c9202c9" 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> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>This static function calls a slot after a given time interval. </p> <p>For example, the following code will call this->doSome() after 2 seconds: </p> <div class="fragment"><pre class="fragment"> <a class="code" href="classWt_1_1WTimer.html#ac35c02164f78de697258197c5c9202c9" title="This static function calls a slot after a given time interval.">WTimer::singleShot</a>(2000, <span class="keyword">this</span>, &MyClass::doSome); </pre></div> </div> </div> <a class="anchor" id="ae0aa0f3402520831531f03f76056e63c"></a><!-- doxytag: member="Wt::WTimer::singleShot" ref="ae0aa0f3402520831531f03f76056e63c" args="(int msec, const F &f)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<class F > </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">const F & </td> <td class="paramname"><em>f</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>This static function calls a function after a given time interval. </p> <p>This variant of the overloaded <a class="el" href="classWt_1_1WTimer.html#ac35c02164f78de697258197c5c9202c9" title="This static function calls a slot after a given time interval.">singleShot()</a> method supports a template function object (which supports operator ()). </p> </div> </div> <a class="anchor" id="ae167fbd3eb981a2fce52e9a4b3b6e0af"></a><!-- doxytag: member="Wt::WTimer::start" ref="ae167fbd3eb981a2fce52e9a4b3b6e0af" 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> <p>The timer will be <a class="el" href="classWt_1_1WTimer.html#aeabde106e48ea67e10c4043609b85493" 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#a73c5d1b882af4835384ccdc07a650e34" title="Stops the timer.">stop()</a> is called. </p> </div> </div> <a class="anchor" id="a73c5d1b882af4835384ccdc07a650e34"></a><!-- doxytag: member="Wt::WTimer::stop" ref="a73c5d1b882af4835384ccdc07a650e34" 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> <p>You may stop the timer during its <a class="el" href="classWt_1_1WTimer.html#a2a66c6a51df2b0ab42258abf2ebd0399" title="Signal emitted when the timer timeouts.">timeout()</a>, or cancel a running timer at any other time.</p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1WTimer.html#ae167fbd3eb981a2fce52e9a4b3b6e0af" title="Starts the timer.">start()</a> </dd></dl> </div> </div> <a class="anchor" id="a2a66c6a51df2b0ab42258abf2ebd0399"></a><!-- doxytag: member="Wt::WTimer::timeout" ref="a2a66c6a51df2b0ab42258abf2ebd0399" 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> <p>The WMouseEvent does not provide any meaningful information but is an implementation artefact. </p> </div> </div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>