Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 995

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Crystal Space 1.2.1: csSchedule Class Reference (Crystal Space 1.2.1 Public API Reference)</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="head">
 <tr height="59">
  <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td>
  <td class="head"><h2>Public API Reference</h2></td>
 </tr>
 <tr height="11">
  <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td>
 </tr>
</table>
<div class="content">
<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</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="classes.html"><span>Classes</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<div class="tabs">
  <ul>
    <li><a href="classes.html"><span>Alphabetical&nbsp;List</span></a></li>
    <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
    <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
    <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
  </ul>
</div>
<h1>csSchedule Class Reference</h1><!-- doxytag: class="csSchedule" -->The <a class="el" href="classcsSchedule.html" title="The csSchedule class provides an easy way to get timers in applications.">csSchedule</a> class provides an easy way to get timers in applications.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="schedule_8h-source.html">csutil/schedule.h</a>&gt;</code>
<p>

<p>
<a href="classcsSchedule-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">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsSchedule.html#3fcf02237c2a3b135787876656c1a5f9">AddCallback</a> (void(*func)(void *), void *arg, int delay)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Add a single-shot callback the function must be of type: void function(void *arg) arg is passed as argument to the function.  <a href="#3fcf02237c2a3b135787876656c1a5f9"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsSchedule.html#1cff671b31220abc1e6b99cc36e5dac8">AddRepeatCallback</a> (void(*func)(void *), void *arg, int period)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Add a repeating callback the function must be of type: void function(void *arg) arg is passed as argument to the function.  <a href="#1cff671b31220abc1e6b99cc36e5dac8"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsSchedule.html#ac571e4d768d47fb29969a2652e0bf2a">csSchedule</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">create an empty schedule  <a href="#ac571e4d768d47fb29969a2652e0bf2a"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsSchedule.html#bb817db71f9af3e3afa7d2404df0c304">RemoveCallback</a> (void *arg)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Remove a single-shot or repeating callback.  <a href="#bb817db71f9af3e3afa7d2404df0c304"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsSchedule.html#54f28e1f5deffb1eb994ff4d0923b44f">RemoveCallback</a> (void(*func)(void *), void *arg)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Remove a single-shot callback.  <a href="#54f28e1f5deffb1eb994ff4d0923b44f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsSchedule.html#1d2d154d88fb3fe67d1f02b3a74e9c8e">RemoveCallback</a> (void(*func)(void *), void *arg, int period)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Remove a repeating callback.  <a href="#1d2d154d88fb3fe67d1f02b3a74e9c8e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcsSchedule.html#199869be48ccd5d6a3248dff7c2c90de">TimePassed</a> (int elapsed_time)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Notify the schedule that time has passed, elapsed_time is in msec.  <a href="#199869be48ccd5d6a3248dff7c2c90de"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The <a class="el" href="classcsSchedule.html" title="The csSchedule class provides an easy way to get timers in applications.">csSchedule</a> class provides an easy way to get timers in applications. 
<p>
It can handle both repeating and single-shot callbacks. It is useful for handling time in 3D virtual worlds. <p>
Use it like this: <div class="fragment"><pre class="fragment"> <span class="keyword">class </span>myEntity 
 {
   <span class="keyword">public</span>:
   <span class="keyword">virtual</span> <span class="keywordtype">void</span> Update();
 };
</pre></div> <p>
Suppose you have an object of class myEntity, which looks like a button in your virtual world, and you want the button to blink. Calling Update every NextFrame would look bad, and handling the timing yourself is a hassle (and can be lots slower then mass-handling by <a class="el" href="classcsSchedule.html" title="The csSchedule class provides an easy way to get timers in applications.">csSchedule</a>). So you can use the <a class="el" href="classcsSchedule.html" title="The csSchedule class provides an easy way to get timers in applications.">csSchedule</a> to call the myEntity::Update method every second. <p>
You can do it this way: <div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> call_entity_update(<span class="keywordtype">void</span> *arg)
 {
   myEntity *mp = (myEntity*)arg;
   mp-&gt;Update();
 }
</pre></div> <p>
You would then use the <a class="el" href="classcsSchedule.html" title="The csSchedule class provides an easy way to get timers in applications.">csSchedule</a> method AddCallback(call_entity_update, (void*)my_entity, 1000); to have it call the function with the object pointer as argument after 1000 milliseconds (= 1 second) once. or you can use: AddRepeatCallback(call_entity_update, (void*)my_entity, 1000); to have the function called repeatedly, every 1000 msec (= second). <p>
To notify the schedule that time has passed, each frame, for example in the NextFrame() method, you must call the TimePassed(elapsed_time) function. <p>
This class is useful for callbacks in 3D virtual worlds, but the callbacks can have some jitter due to framerates. For mission-critical hardware IO calls (like controlling a floppy drive or controlling the UART) this jitter will be too big. In those cases use interrupt-driven callbacks, and place the controlling code in some platform-specific implementation file, since this type of use is typically platform-dependent. However, although this class cannot give callbacks inside a single frame, it will behave as best as possible using callbacks every frame. 
<p>Definition at line <a class="el" href="schedule_8h-source.html#l00081">81</a> of file <a class="el" href="schedule_8h-source.html">schedule.h</a>.</p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="ac571e4d768d47fb29969a2652e0bf2a"></a><!-- doxytag: member="csSchedule::csSchedule" ref="ac571e4d768d47fb29969a2652e0bf2a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">csSchedule::csSchedule           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
create an empty schedule 
<p>

</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="3fcf02237c2a3b135787876656c1a5f9"></a><!-- doxytag: member="csSchedule::AddCallback" ref="3fcf02237c2a3b135787876656c1a5f9" args="(void(*func)(void *), void *arg, int delay)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csSchedule::AddCallback           </td>
          <td>(</td>
          <td class="paramtype">void(*)(void *)&nbsp;</td>
          <td class="paramname"> <em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>delay</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Add a single-shot callback the function must be of type: void function(void *arg) arg is passed as argument to the function. 
<p>
delay: the function is called this many msec have passed. 
</div>
</div><p>
<a class="anchor" name="1cff671b31220abc1e6b99cc36e5dac8"></a><!-- doxytag: member="csSchedule::AddRepeatCallback" ref="1cff671b31220abc1e6b99cc36e5dac8" args="(void(*func)(void *), void *arg, int period)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csSchedule::AddRepeatCallback           </td>
          <td>(</td>
          <td class="paramtype">void(*)(void *)&nbsp;</td>
          <td class="paramname"> <em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>period</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Add a repeating callback the function must be of type: void function(void *arg) arg is passed as argument to the function. 
<p>
period: the function is called every time this many msec pass. 
</div>
</div><p>
<a class="anchor" name="bb817db71f9af3e3afa7d2404df0c304"></a><!-- doxytag: member="csSchedule::RemoveCallback" ref="bb817db71f9af3e3afa7d2404df0c304" args="(void *arg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csSchedule::RemoveCallback           </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>arg</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Remove a single-shot or repeating callback. 
<p>
(if multiple identical calls exist, all are removed) removes all callbacks using given argument, whatever their function or period. Useful if the argument in question is an object that is destructed. So, in a class myEntity, in ~myEntity() you can call: schedule-&gt;RemoveCallback(this); 
</div>
</div><p>
<a class="anchor" name="54f28e1f5deffb1eb994ff4d0923b44f"></a><!-- doxytag: member="csSchedule::RemoveCallback" ref="54f28e1f5deffb1eb994ff4d0923b44f" args="(void(*func)(void *), void *arg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csSchedule::RemoveCallback           </td>
          <td>(</td>
          <td class="paramtype">void(*)(void *)&nbsp;</td>
          <td class="paramname"> <em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>arg</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Remove a single-shot callback. 
<p>
(if multiple identical calls exist, the first is removed) 
</div>
</div><p>
<a class="anchor" name="1d2d154d88fb3fe67d1f02b3a74e9c8e"></a><!-- doxytag: member="csSchedule::RemoveCallback" ref="1d2d154d88fb3fe67d1f02b3a74e9c8e" args="(void(*func)(void *), void *arg, int period)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csSchedule::RemoveCallback           </td>
          <td>(</td>
          <td class="paramtype">void(*)(void *)&nbsp;</td>
          <td class="paramname"> <em>func</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>period</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Remove a repeating callback. 
<p>
(if multiple identical calls exist, the first is removed) 
</div>
</div><p>
<a class="anchor" name="199869be48ccd5d6a3248dff7c2c90de"></a><!-- doxytag: member="csSchedule::TimePassed" ref="199869be48ccd5d6a3248dff7c2c90de" args="(int elapsed_time)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csSchedule::TimePassed           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>elapsed_time</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Notify the schedule that time has passed, elapsed_time is in msec. 
<p>
It will update the internal data and call any callbacks if necessary. 
</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>csutil/<a class="el" href="schedule_8h-source.html">schedule.h</a></ul>
<hr size="1"><address><small>Generated for Crystal Space 1.2.1 by 
<a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 
</small></address> </div></body> </html>