Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > 45a94e45036b4f2592a7e2c3922f90c7 > files > 7

adevs-doc-2.6-4.fc18.noarch.rpm

<!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>adevs: /home/rotten/adevs-2.6/include/adevs_cellspace.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</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">adevs
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</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 id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">/home/rotten/adevs-2.6/include/adevs_cellspace.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***************</span>
<a name="l00002"></a>00002 <span class="comment">Copyright (C) 2000-2006 by James Nutaro</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment">This library is free software; you can redistribute it and/or</span>
<a name="l00005"></a>00005 <span class="comment">modify it under the terms of the GNU Lesser General Public</span>
<a name="l00006"></a>00006 <span class="comment">License as published by the Free Software Foundation; either</span>
<a name="l00007"></a>00007 <span class="comment">version 2 of the License, or (at your option) any later version.</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment">This library is distributed in the hope that it will be useful,</span>
<a name="l00010"></a>00010 <span class="comment">but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00011"></a>00011 <span class="comment">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00012"></a>00012 <span class="comment">Lesser General Public License for more details.</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment">You should have received a copy of the GNU Lesser General Public</span>
<a name="l00015"></a>00015 <span class="comment">License along with this library; if not, write to the Free Software</span>
<a name="l00016"></a>00016 <span class="comment">Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<a name="l00017"></a>00017 <span class="comment"></span>
<a name="l00018"></a>00018 <span class="comment">Bugs, comments, and questions can be sent to nutaro@gmail.com</span>
<a name="l00019"></a>00019 <span class="comment">***************/</span>
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef __adevs_cellspace_h_</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define __adevs_cellspace_h_</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#include &quot;adevs.h&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;cstdlib&gt;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="keyword">namespace </span>adevs
<a name="l00026"></a>00026 {
<a name="l00027"></a>00027 
<a name="l00033"></a>00033 <span class="keyword">template</span> &lt;<span class="keyword">class</span> X&gt; <span class="keyword">class </span>CellEvent
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035         <span class="keyword">public</span>:
<a name="l00037"></a><a class="code" href="classadevs_1_1CellEvent.html#acb53c86c39dd78023f589e4d602d946f">00037</a>                 <a class="code" href="classadevs_1_1CellEvent.html#acb53c86c39dd78023f589e4d602d946f" title="Default constructor. Sets x = y = z = 0.">CellEvent</a>(){ <a class="code" href="classadevs_1_1CellEvent.html#a5a62f8f94b9a6046bd525faeaddbee10" title="The x coordinate of the event target.">x</a> = <a class="code" href="classadevs_1_1CellEvent.html#ab81adf0c81a5ed98e46bc65cc9eebe7d" title="The y coordinate of the event target.">y</a> = <a class="code" href="classadevs_1_1CellEvent.html#a5ab6f45d3d7c3325ae458ced50bb9f79" title="The z coordinate of the event target.">z</a> = 0; }
<a name="l00039"></a><a class="code" href="classadevs_1_1CellEvent.html#ac70314017ebf21a159a09487820140ac">00039</a>                 <a class="code" href="classadevs_1_1CellEvent.html#acb53c86c39dd78023f589e4d602d946f" title="Default constructor. Sets x = y = z = 0.">CellEvent</a>(<span class="keyword">const</span> <a class="code" href="classadevs_1_1CellEvent.html">CellEvent&lt;X&gt;</a>&amp; src):
<a name="l00040"></a>00040                 <a class="code" href="classadevs_1_1CellEvent.html#a5a62f8f94b9a6046bd525faeaddbee10" title="The x coordinate of the event target.">x</a>(src.<a class="code" href="classadevs_1_1CellEvent.html#a5a62f8f94b9a6046bd525faeaddbee10" title="The x coordinate of the event target.">x</a>),<a class="code" href="classadevs_1_1CellEvent.html#ab81adf0c81a5ed98e46bc65cc9eebe7d" title="The y coordinate of the event target.">y</a>(src.<a class="code" href="classadevs_1_1CellEvent.html#ab81adf0c81a5ed98e46bc65cc9eebe7d" title="The y coordinate of the event target.">y</a>),<a class="code" href="classadevs_1_1CellEvent.html#a5ab6f45d3d7c3325ae458ced50bb9f79" title="The z coordinate of the event target.">z</a>(src.<a class="code" href="classadevs_1_1CellEvent.html#a5ab6f45d3d7c3325ae458ced50bb9f79" title="The z coordinate of the event target.">z</a>),<a class="code" href="classadevs_1_1CellEvent.html#ad5a56f6ff5823725e466d6747b47f80a" title="The event value.">value</a>(src.<a class="code" href="classadevs_1_1CellEvent.html#ad5a56f6ff5823725e466d6747b47f80a" title="The event value.">value</a>){}
<a name="l00042"></a><a class="code" href="classadevs_1_1CellEvent.html#a528ab5a7fae6dca91fc41d6d877e72de">00042</a>                 <span class="keyword">const</span> <a class="code" href="classadevs_1_1CellEvent.html">CellEvent</a>&amp; <a class="code" href="classadevs_1_1CellEvent.html#a528ab5a7fae6dca91fc41d6d877e72de" title="Assignment operator.">operator=</a>(<span class="keyword">const</span> <a class="code" href="classadevs_1_1CellEvent.html">CellEvent&lt;X&gt;</a>&amp; src)
<a name="l00043"></a>00043                 {
<a name="l00044"></a>00044                         <a class="code" href="classadevs_1_1CellEvent.html#a5a62f8f94b9a6046bd525faeaddbee10" title="The x coordinate of the event target.">x</a> = src.x; <a class="code" href="classadevs_1_1CellEvent.html#ab81adf0c81a5ed98e46bc65cc9eebe7d" title="The y coordinate of the event target.">y</a> = src.y; <a class="code" href="classadevs_1_1CellEvent.html#a5ab6f45d3d7c3325ae458ced50bb9f79" title="The z coordinate of the event target.">z</a> = src.z; <a class="code" href="classadevs_1_1CellEvent.html#ad5a56f6ff5823725e466d6747b47f80a" title="The event value.">value</a> = src.value;
<a name="l00045"></a>00045                         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00046"></a>00046                 }
<a name="l00048"></a><a class="code" href="classadevs_1_1CellEvent.html#a5a62f8f94b9a6046bd525faeaddbee10">00048</a>                 <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classadevs_1_1CellEvent.html#a5a62f8f94b9a6046bd525faeaddbee10" title="The x coordinate of the event target.">x</a>;
<a name="l00050"></a><a class="code" href="classadevs_1_1CellEvent.html#ab81adf0c81a5ed98e46bc65cc9eebe7d">00050</a>                 <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classadevs_1_1CellEvent.html#ab81adf0c81a5ed98e46bc65cc9eebe7d" title="The y coordinate of the event target.">y</a>;
<a name="l00052"></a><a class="code" href="classadevs_1_1CellEvent.html#a5ab6f45d3d7c3325ae458ced50bb9f79">00052</a>                 <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classadevs_1_1CellEvent.html#a5ab6f45d3d7c3325ae458ced50bb9f79" title="The z coordinate of the event target.">z</a>;
<a name="l00054"></a><a class="code" href="classadevs_1_1CellEvent.html#ad5a56f6ff5823725e466d6747b47f80a">00054</a>                 X <a class="code" href="classadevs_1_1CellEvent.html#ad5a56f6ff5823725e466d6747b47f80a" title="The event value.">value</a>;
<a name="l00055"></a>00055 };
<a name="l00056"></a>00056 
<a name="l00068"></a>00068 <span class="keyword">template</span> &lt;<span class="keyword">class</span> X, <span class="keyword">class</span> T = <span class="keywordtype">double</span>&gt; <span class="keyword">class </span><a class="code" href="classadevs_1_1CellSpace.html">CellSpace</a>: <span class="keyword">public</span> <a class="code" href="classadevs_1_1Network.html">Network</a>&lt;CellEvent&lt;X&gt;,T&gt;
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070         <span class="keyword">public</span>:
<a name="l00072"></a><a class="code" href="classadevs_1_1CellSpace.html#a903b316b945f4d23850e1995f011787a">00072</a>                 <span class="keyword">typedef</span> <a class="code" href="classadevs_1_1Devs.html">Devs&lt;CellEvent&lt;X&gt;</a>,T&gt; <a class="code" href="classadevs_1_1CellSpace.html#a903b316b945f4d23850e1995f011787a" title="A component model in the CellSpace.">Cell</a>;
<a name="l00074"></a>00074                 <a class="code" href="classadevs_1_1CellSpace.html#a8af87869490b49ca5a52e28bcfed2fb3" title="Create an Width x Height x Depth CellSpace with NULL entries in the cell locations.">CellSpace</a>(<span class="keywordtype">long</span> <span class="keywordtype">int</span> width, <span class="keywordtype">long</span> <span class="keywordtype">int</span> height = 1, <span class="keywordtype">long</span> <span class="keywordtype">int</span> depth = 1);
<a name="l00076"></a><a class="code" href="classadevs_1_1CellSpace.html#a3cefd9adadf43e66160cb3c985348d39">00076</a>                 <span class="keywordtype">void</span> <a class="code" href="classadevs_1_1CellSpace.html#a3cefd9adadf43e66160cb3c985348d39" title="Insert a model at the x,y,z position.">add</a>(<a class="code" href="classadevs_1_1Devs.html">Cell</a>* model, <span class="keywordtype">long</span> <span class="keywordtype">int</span> x, <span class="keywordtype">long</span> <span class="keywordtype">int</span> y = 0, <span class="keywordtype">long</span> <span class="keywordtype">int</span> z = 0) 
<a name="l00077"></a>00077                 {
<a name="l00078"></a>00078                         space[x][y][z] = model;
<a name="l00079"></a>00079                         model-&gt;<a class="code" href="classadevs_1_1Devs.html#afc67a3b478a4873f88456a1606857184">setParent</a>(<span class="keyword">this</span>);
<a name="l00080"></a>00080                 }
<a name="l00082"></a><a class="code" href="classadevs_1_1CellSpace.html#a504c431c483da16974c534cdfab6d1e8">00082</a>                 <span class="keyword">const</span> <a class="code" href="classadevs_1_1Devs.html">Cell</a>* <a class="code" href="classadevs_1_1CellSpace.html#a504c431c483da16974c534cdfab6d1e8" title="Get the model at location x,y,z.">getModel</a>(<span class="keywordtype">long</span> <span class="keywordtype">int</span> x, <span class="keywordtype">long</span> <span class="keywordtype">int</span> y = 0, <span class="keywordtype">long</span> <span class="keywordtype">int</span> z = 0)<span class="keyword"> const</span>
<a name="l00083"></a>00083 <span class="keyword">                </span>{
<a name="l00084"></a>00084                         <span class="keywordflow">return</span> space[x][y][z];
<a name="l00085"></a>00085                 }
<a name="l00087"></a><a class="code" href="classadevs_1_1CellSpace.html#a914df37bb16b7ced432afa637ff0ae36">00087</a>                 <a class="code" href="classadevs_1_1Devs.html">Cell</a>* <a class="code" href="classadevs_1_1CellSpace.html#a504c431c483da16974c534cdfab6d1e8" title="Get the model at location x,y,z.">getModel</a>(<span class="keywordtype">long</span> <span class="keywordtype">int</span> x, <span class="keywordtype">long</span> <span class="keywordtype">int</span> y = 0, <span class="keywordtype">long</span> <span class="keywordtype">int</span> z = 0)
<a name="l00088"></a>00088                 {
<a name="l00089"></a>00089                         <span class="keywordflow">return</span> space[x][y][z];
<a name="l00090"></a>00090                 }
<a name="l00092"></a><a class="code" href="classadevs_1_1CellSpace.html#aba8c76bec87476a1176ba031d3e8b592">00092</a>                 <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classadevs_1_1CellSpace.html#aba8c76bec87476a1176ba031d3e8b592" title="Get the width of the CellSpace.">getWidth</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> w; }
<a name="l00094"></a><a class="code" href="classadevs_1_1CellSpace.html#aad7b4f1f277db09768ae647f4fc062b4">00094</a>                 <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classadevs_1_1CellSpace.html#aad7b4f1f277db09768ae647f4fc062b4" title="Get the height of the CellSpace.">getHeight</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> h; }
<a name="l00096"></a><a class="code" href="classadevs_1_1CellSpace.html#a74a3136ba844a36178ceb4fd48f921a2">00096</a>                 <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classadevs_1_1CellSpace.html#a74a3136ba844a36178ceb4fd48f921a2" title="Get the depth of the CellSpace.">getDepth</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> d; }
<a name="l00098"></a>00098                 <span class="keywordtype">void</span> <a class="code" href="classadevs_1_1CellSpace.html#a9ed691f62b84e4af3dfdac07cabd197d" title="Get the model&#39;s set of components.">getComponents</a>(<a class="code" href="classadevs_1_1Set.html">Set&lt;Cell*&gt;</a>&amp; c);
<a name="l00100"></a>00100                 <span class="keywordtype">void</span> <a class="code" href="classadevs_1_1CellSpace.html#a96b6bf760cd53cb0efec9f44a12f3383" title="Route events within the Cellspace.">route</a>(<span class="keyword">const</span> <a class="code" href="classadevs_1_1CellEvent.html">CellEvent&lt;X&gt;</a>&amp; event, <a class="code" href="classadevs_1_1CellSpace.html#a903b316b945f4d23850e1995f011787a" title="A component model in the CellSpace.">Cell</a>* model, 
<a name="l00101"></a>00101                 <a class="code" href="classadevs_1_1Bag.html">Bag</a>&lt;<a class="code" href="classadevs_1_1Event.html">Event</a>&lt;<a class="code" href="classadevs_1_1CellEvent.html">CellEvent&lt;X&gt;</a>,T&gt; &gt;&amp; r);
<a name="l00103"></a>00103                 <a class="code" href="classadevs_1_1CellSpace.html#af2e8ac27734cdd84bdc939ff4bdeeea6" title="Destructor; this destroys the components as well.">~CellSpace</a>();
<a name="l00104"></a>00104         <span class="keyword">private</span>:        
<a name="l00105"></a>00105                 <span class="keywordtype">long</span> <span class="keywordtype">int</span> w, h, d;
<a name="l00106"></a>00106                 <a class="code" href="classadevs_1_1CellSpace.html#a903b316b945f4d23850e1995f011787a" title="A component model in the CellSpace.">Cell</a>**** space;
<a name="l00107"></a>00107 };
<a name="l00108"></a>00108 
<a name="l00109"></a>00109 <span class="comment">// Implementation of constructor</span>
<a name="l00110"></a>00110 <span class="keyword">template</span> &lt;<span class="keyword">class</span> X, <span class="keyword">class</span> T&gt;
<a name="l00111"></a><a class="code" href="classadevs_1_1CellSpace.html#a8af87869490b49ca5a52e28bcfed2fb3">00111</a> <a class="code" href="classadevs_1_1CellSpace.html#a8af87869490b49ca5a52e28bcfed2fb3" title="Create an Width x Height x Depth CellSpace with NULL entries in the cell locations.">CellSpace&lt;X,T&gt;::CellSpace</a>(<span class="keywordtype">long</span> <span class="keywordtype">int</span> width, <span class="keywordtype">long</span> <span class="keywordtype">int</span> height, <span class="keywordtype">long</span> <span class="keywordtype">int</span> depth):
<a name="l00112"></a>00112 <a class="code" href="classadevs_1_1Network.html">Network</a>&lt;<a class="code" href="classadevs_1_1CellEvent.html">CellEvent</a>&lt;X&gt;,T&gt;()
<a name="l00113"></a>00113 {
<a name="l00114"></a>00114         w = width;
<a name="l00115"></a>00115         h = height;
<a name="l00116"></a>00116         d = depth;
<a name="l00117"></a>00117         <span class="comment">// Allocate space for the cells and set the entries to NULL</span>
<a name="l00118"></a>00118         space = <span class="keyword">new</span> <a class="code" href="classadevs_1_1Devs.html">Cell</a>***[w];
<a name="l00119"></a>00119         <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> x = 0; x &lt; w; x++)
<a name="l00120"></a>00120         {
<a name="l00121"></a>00121                 space[x] = <span class="keyword">new</span> <a class="code" href="classadevs_1_1Devs.html">Cell</a>**[h];
<a name="l00122"></a>00122                 <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> y = 0; y &lt; h; y++)
<a name="l00123"></a>00123                 {
<a name="l00124"></a>00124                         space[x][y] = <span class="keyword">new</span> <a class="code" href="classadevs_1_1Devs.html">Cell</a>*[h];
<a name="l00125"></a>00125                         <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> z = 0; z &lt; d; z++)
<a name="l00126"></a>00126                         {
<a name="l00127"></a>00127                                 space[x][y][z] = NULL;
<a name="l00128"></a>00128                         }
<a name="l00129"></a>00129                 }
<a name="l00130"></a>00130         }
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 
<a name="l00133"></a>00133 <span class="comment">// Implementation of destructor</span>
<a name="l00134"></a>00134 <span class="keyword">template</span> &lt;<span class="keyword">class</span> X, <span class="keyword">class</span> T&gt;
<a name="l00135"></a><a class="code" href="classadevs_1_1CellSpace.html#af2e8ac27734cdd84bdc939ff4bdeeea6">00135</a> <a class="code" href="classadevs_1_1CellSpace.html#af2e8ac27734cdd84bdc939ff4bdeeea6" title="Destructor; this destroys the components as well.">CellSpace&lt;X,T&gt;::~CellSpace</a>()
<a name="l00136"></a>00136 {
<a name="l00137"></a>00137         <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> x = 0; x &lt; w; x++)
<a name="l00138"></a>00138         {
<a name="l00139"></a>00139                 <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> y = 0; y &lt; h; y++)
<a name="l00140"></a>00140                 {
<a name="l00141"></a>00141                         <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> z = 0; z &lt; d; z++)
<a name="l00142"></a>00142                         {
<a name="l00143"></a>00143                                 <span class="keywordflow">if</span> (space[x][y][z] != NULL)
<a name="l00144"></a>00144                                 {
<a name="l00145"></a>00145                                         <span class="keyword">delete</span> space[x][y][z];
<a name="l00146"></a>00146                                 }
<a name="l00147"></a>00147                         }
<a name="l00148"></a>00148                         <span class="keyword">delete</span> [] space[x][y];
<a name="l00149"></a>00149                 }
<a name="l00150"></a>00150                 <span class="keyword">delete</span> [] space[x];
<a name="l00151"></a>00151         }
<a name="l00152"></a>00152         <span class="keyword">delete</span> [] space;
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154 
<a name="l00155"></a>00155 <span class="comment">// Implementation of the getComponents() method</span>
<a name="l00156"></a>00156 <span class="keyword">template</span> &lt;<span class="keyword">class</span> X, <span class="keyword">class</span> T&gt;
<a name="l00157"></a><a class="code" href="classadevs_1_1CellSpace.html#a9ed691f62b84e4af3dfdac07cabd197d">00157</a> <span class="keywordtype">void</span> <a class="code" href="classadevs_1_1CellSpace.html#a9ed691f62b84e4af3dfdac07cabd197d" title="Get the model&#39;s set of components.">CellSpace&lt;X,T&gt;::getComponents</a>(<a class="code" href="classadevs_1_1Set.html">Set&lt;Cell*&gt;</a>&amp; c)
<a name="l00158"></a>00158 {
<a name="l00159"></a>00159         <span class="comment">// Add all non-null entries to the set c</span>
<a name="l00160"></a>00160         <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> x = 0; x &lt; w; x++)
<a name="l00161"></a>00161         {
<a name="l00162"></a>00162                 <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> y = 0; y &lt; h; y++)
<a name="l00163"></a>00163                 {
<a name="l00164"></a>00164                         <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">int</span> z = 0; z &lt; d; z++)
<a name="l00165"></a>00165                         {
<a name="l00166"></a>00166                                 <span class="keywordflow">if</span> (space[x][y][z] != NULL)
<a name="l00167"></a>00167                                 {
<a name="l00168"></a>00168                                         c.insert(space[x][y][z]);
<a name="l00169"></a>00169                                 }
<a name="l00170"></a>00170                         }
<a name="l00171"></a>00171                 }
<a name="l00172"></a>00172         }
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 <span class="comment">// Event routing function for the net_exec</span>
<a name="l00176"></a>00176 <span class="keyword">template</span> &lt;<span class="keyword">class</span> X, <span class="keyword">class</span> T&gt;
<a name="l00177"></a><a class="code" href="classadevs_1_1CellSpace.html#a96b6bf760cd53cb0efec9f44a12f3383">00177</a> <span class="keywordtype">void</span> <a class="code" href="classadevs_1_1CellSpace.html#a96b6bf760cd53cb0efec9f44a12f3383" title="Route events within the Cellspace.">CellSpace&lt;X,T&gt;::route</a>(
<a name="l00178"></a>00178 <span class="keyword">const</span> <a class="code" href="classadevs_1_1CellEvent.html">CellEvent&lt;X&gt;</a>&amp; event, <a class="code" href="classadevs_1_1Devs.html">Cell</a>* model, <a class="code" href="classadevs_1_1Bag.html">Bag</a>&lt;<a class="code" href="classadevs_1_1Event.html">Event</a>&lt;<a class="code" href="classadevs_1_1CellEvent.html">CellEvent&lt;X&gt;</a>,T&gt; &gt;&amp; r)
<a name="l00179"></a>00179 {
<a name="l00180"></a>00180         <a class="code" href="classadevs_1_1Devs.html">Cell</a>* target = NULL;
<a name="l00181"></a>00181         <span class="comment">// If the target cell is inside of the cellspace</span>
<a name="l00182"></a>00182         <span class="keywordflow">if</span> (event.x &gt;= 0 &amp;&amp; event.x &lt; w &amp;&amp;  <span class="comment">// check x dimension</span>
<a name="l00183"></a>00183         event.y &gt;= 0 &amp;&amp; event.y &lt; h &amp;&amp; <span class="comment">// check y dimension</span>
<a name="l00184"></a>00184         event.z &gt;= 0 &amp;&amp; event.z &lt; d) <span class="comment">// check z dimension</span>
<a name="l00185"></a>00185         {
<a name="l00186"></a>00186                 <span class="comment">// Get the interior target</span>
<a name="l00187"></a>00187                 target = space[<span class="keyword">event</span>.x][<span class="keyword">event</span>.y][<span class="keyword">event</span>.z];
<a name="l00188"></a>00188         }
<a name="l00189"></a>00189         <span class="keywordflow">else</span>
<a name="l00190"></a>00190         {
<a name="l00191"></a>00191                 <span class="comment">// Otherwise, the event becomes an external output from the cellspace</span>
<a name="l00192"></a>00192                 target = <span class="keyword">this</span>;
<a name="l00193"></a>00193         }
<a name="l00194"></a>00194         <span class="comment">// If the target exists</span>
<a name="l00195"></a>00195         <span class="keywordflow">if</span> (target != NULL)
<a name="l00196"></a>00196         {
<a name="l00197"></a>00197                 <span class="comment">// Add an appropriate event to the receiver bag</span>
<a name="l00198"></a>00198                 <a class="code" href="classadevs_1_1Event.html">Event&lt;CellEvent&lt;X&gt;</a> &gt; io(target,event);
<a name="l00199"></a>00199                 r.insert(io);
<a name="l00200"></a>00200         }
<a name="l00201"></a>00201 }
<a name="l00202"></a>00202 
<a name="l00203"></a>00203 } <span class="comment">// end of namespace</span>
<a name="l00204"></a>00204 
<a name="l00205"></a>00205 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>


<hr class="footer"/><address class="footer"><small>
Generated on Sun Jun 10 2012 18:42:49 for adevs by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5
</small></address>

</body>
</html>