Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 29c369053a983cc5d8c880dc6e0a2237 > files > 666

libdtn-devel-2.6.0-2mdv2009.1.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: Simulator.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>Simulator.h</h1><a href="Simulator_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *    Copyright 2004-2006 Intel Corporation</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> * </span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;queue&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;oasys/debug/DebugUtils.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;oasys/debug/Log.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;oasys/util/Singleton.h&gt;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="SimEvent_8h.html">SimEvent.h</a>"</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="SimEventHandler_8h.html">SimEventHandler.h</a>"</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="keyword">namespace </span>dtnsim {
<a name="l00026"></a>00026 
<a name="l00030"></a><a class="code" href="classdtnsim_1_1Simulator.html">00030</a> <span class="keyword">class </span><a class="code" href="classdtnsim_1_1Simulator.html" title="The main simulator class.">Simulator</a> : <span class="keyword">public</span> oasys::Singleton&lt;Simulator, false&gt;,
<a name="l00031"></a>00031                   <span class="keyword">public</span> <a class="code" href="classdtnsim_1_1SimEventHandler.html" title="Interface implemented by all objects that handle simulator events.">SimEventHandler</a>,
<a name="l00032"></a>00032                   <span class="keyword">public</span> oasys::<a class="code" href="classoasys_1_1Logger.html">Logger</a>
<a name="l00033"></a>00033 {
<a name="l00034"></a>00034 <span class="keyword">public</span>:
<a name="l00038"></a><a class="code" href="classdtnsim_1_1Simulator.html#e428d32758e9f94c855b43527d87bd84">00038</a>     <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classdtnsim_1_1Simulator.html#e428d32758e9f94c855b43527d87bd84" title="Return the current simulator time.">time</a>() { <span class="keywordflow">return</span> <a class="code" href="classdtnsim_1_1Simulator.html#726f668284f415ba7160cc8ebcc9a124" title="current time (static to avoid object)">time_</a>; }
<a name="l00039"></a>00039 
<a name="l00043"></a>00043     <a class="code" href="classdtnsim_1_1Simulator.html#5d17ae3f95414a283a1595fdd2cefb3e" title="Constructor.">Simulator</a>();
<a name="l00044"></a>00044         
<a name="l00048"></a><a class="code" href="classdtnsim_1_1Simulator.html#d8c5e1b1971e84c31f7937ae817a4851">00048</a>     <span class="keyword">virtual</span> <a class="code" href="classdtnsim_1_1Simulator.html#d8c5e1b1971e84c31f7937ae817a4851" title="Destructor.">~Simulator</a>() {}
<a name="l00049"></a>00049 
<a name="l00053"></a>00053     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#ebd17c1beaacc7f1f6e11e963d09e0ec" title="Add an event to the main event queue.">post</a>(<a class="code" href="classdtnsim_1_1SimEvent.html">SimEvent</a> *e);
<a name="l00054"></a>00054     
<a name="l00058"></a>00058     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#7acdfd3573abad2d862944e92bfca16d" title="Stops simulation and exits the loop.">exit</a>();
<a name="l00059"></a>00059 
<a name="l00063"></a>00063     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#02abc66ca653adfcc92d8aec68b183da" title="Main run loop.">run</a>();
<a name="l00064"></a>00064 
<a name="l00069"></a>00069     <span class="keywordtype">int</span> <a class="code" href="classdtnsim_1_1Simulator.html#f52eb7a2e5c0ee7343fcbd50dc2faef7" title="Handle all bundle events at nodes returning the amount of time (in ms) until the...">run_node_events</a>();
<a name="l00070"></a>00070 
<a name="l00075"></a>00075     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#e253c215d84b63068747ac94adb7b778" title="Pause execution of the simulator, running a console loop until it exits.">pause</a>();
<a name="l00076"></a>00076 
<a name="l00080"></a>00080     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#9a749bd8ace235e9e8cafb5a4d8fc9b1" title="Run the command loop.">run_console</a>(<span class="keywordtype">bool</span> complete);
<a name="l00081"></a>00081 
<a name="l00085"></a>00085     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#e37776c67ac6018b431382d0f02f5cad" title="Register a command to run at exit.">set_exit_event</a>(<a class="code" href="classdtnsim_1_1SimAtEvent.html">SimAtEvent</a>* event);
<a name="l00086"></a>00086 
<a name="l00087"></a><a class="code" href="classdtnsim_1_1Simulator.html#c3e483526794d4ccd4a3e9e78bc95b2f">00087</a>     <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classdtnsim_1_1Simulator.html#c3e483526794d4ccd4a3e9e78bc95b2f" title="time to end the simulation">runtill_</a>;             
<a name="l00088"></a>00088     
<a name="l00089"></a>00089 <span class="keyword">private</span>:
<a name="l00093"></a>00093     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#5e2a212a321fd812422ad8d824308fb8" title="Virtual from SimEventHandler.">process</a>(<a class="code" href="classdtnsim_1_1SimEvent.html">SimEvent</a>* e);
<a name="l00094"></a>00094 
<a name="l00095"></a>00095     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#045c83976fbabbc3494142e02e0820b1">log_inqueue_stats</a>();
<a name="l00096"></a>00096 
<a name="l00097"></a><a class="code" href="classdtnsim_1_1Simulator.html#726f668284f415ba7160cc8ebcc9a124">00097</a>     <span class="keyword">static</span> <span class="keywordtype">double</span> <a class="code" href="classdtnsim_1_1Simulator.html#726f668284f415ba7160cc8ebcc9a124" title="current time (static to avoid object)">time_</a>;                
<a name="l00098"></a>00098 
<a name="l00099"></a>00099     std::priority_queue&lt;<a class="code" href="classdtnsim_1_1SimEvent.html">SimEvent</a>*,
<a name="l00100"></a>00100                         std::vector&lt;SimEvent*&gt;,
<a name="l00101"></a><a class="code" href="classdtnsim_1_1Simulator.html#6aa1c59f30f934aa3201768eeab02b50">00101</a>                         <a class="code" href="classdtnsim_1_1SimEventCompare.html">SimEventCompare</a>&gt; <a class="code" href="classdtnsim_1_1Simulator.html#6aa1c59f30f934aa3201768eeab02b50">eventq_</a>;
<a name="l00102"></a>00102 
<a name="l00103"></a><a class="code" href="classdtnsim_1_1Simulator.html#8aaf01a69ac5f46847e396af564a0f45">00103</a>     <a class="code" href="classdtnsim_1_1SimAtEvent.html">SimAtEvent</a>* <a class="code" href="classdtnsim_1_1Simulator.html#8aaf01a69ac5f46847e396af564a0f45">exit_event_</a>;
<a name="l00104"></a>00104 
<a name="l00105"></a>00105     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#773551d739b93f1dc1ae063c623c7c29">run_at_event</a>(<a class="code" href="classdtnsim_1_1SimAtEvent.html">SimAtEvent</a>* evt);
<a name="l00106"></a>00106 
<a name="l00107"></a>00107     <span class="comment">/*</span>
<a name="l00108"></a>00108 <span class="comment">     * Handlers for SIGINT to pause the simulation while it's running.</span>
<a name="l00109"></a>00109 <span class="comment">     */</span>
<a name="l00110"></a>00110     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#079d73f7048d4371501d93e064bcf138">handle_interrupt</a>(<span class="keywordtype">int</span> sig);
<a name="l00111"></a>00111     <span class="keywordtype">void</span> <a class="code" href="classdtnsim_1_1Simulator.html#327cd35d3972508033443ffeaf9eb90d">check_interrupt</a>();
<a name="l00112"></a><a class="code" href="classdtnsim_1_1Simulator.html#2066f289b67cff4cd17baf93a8a12902">00112</a>     <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classdtnsim_1_1Simulator.html#2066f289b67cff4cd17baf93a8a12902">interrupted_</a>;
<a name="l00113"></a>00113 };
<a name="l00114"></a>00114 
<a name="l00115"></a>00115 } <span class="comment">// namespace dtnsim</span>
<a name="l00116"></a>00116     
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:58 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>