aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a05477.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/a05477.html')
-rw-r--r--docs/doxygen/nel/a05477.html180
1 files changed, 180 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a05477.html b/docs/doxygen/nel/a05477.html
new file mode 100644
index 00000000..61faf96c
--- /dev/null
+++ b/docs/doxygen/nel/a05477.html
@@ -0,0 +1,180 @@
+<!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>NeL: basic_agent.cpp Source File</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.3.6 -->
+<div class="qindex"> <form class="search" action="search.php" method="get">
+<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
+<h1>basic_agent.cpp</h1><a href="a04054.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00006 <span class="comment">/* Copyright, 2000 Nevrax Ltd.</span>
+00007 <span class="comment"> *</span>
+00008 <span class="comment"> * This file is part of NEVRAX NEL.</span>
+00009 <span class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</span>
+00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
+00011 <span class="comment"> * the Free Software Foundation; either version 2, or (at your option)</span>
+00012 <span class="comment"> * any later version.</span>
+00013 <span class="comment"></span>
+00014 <span class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</span>
+00015 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span>
+00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
+00017 <span class="comment"> * General Public License for more details.</span>
+00018 <span class="comment"></span>
+00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
+00020 <span class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</span>
+00021 <span class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</span>
+00022 <span class="comment"> * MA 02111-1307, USA.</span>
+00023 <span class="comment"> */</span>
+00024 <span class="preprocessor">#include "<a class="code" href="a03970.html">nel/ai/agent/agent.h</a>"</span>
+00025
+00026 <span class="keyword">namespace </span>NLAIAGENT
+00027 {
+00028
+00029
+<a name="l00030"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentCompositeb1">00030</a> IAgentComposite::IAgentComposite(<span class="keyword">const</span> <a class="code" href="a02161.html">IAgentComposite</a> &amp;a): <a class="code" href="a02162.html">IBasicAgent</a>(a),_SizeChild(0)
+00031 {
+00032 std::list&lt;IBasicAgent *&gt;::const_iterator i = a.<a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.begin();
+00033 <span class="keywordflow">while</span>(i != a.<a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.end())
+00034 {
+00035 <a class="code" href="a02162.html">IBasicAgent</a> *b = ( *i++ );
+00036 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentz1611_0">addChild</a>( b );
+00037 }
+00038 }
+00039
+<a name="l00040"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentCompositea21">00040</a> IAgentComposite::IAgentComposite(<a class="code" href="a02162.html">IBasicAgent</a> *parent): <a class="code" href="a02162.html">IBasicAgent</a>(parent != NULL ? (<a class="code" href="a05333.html#a96">const</a> <a class="code" href="a03887.html">IWordNumRef</a> *) *parent:NULL),_SizeChild(0)
+00041 {
+00042 <span class="keywordflow">if</span>(parent) parent-&gt;<a class="code" href="a02162.html#NLAIAGENT_1_1IBasicAgenta0">addChild</a>(<span class="keyword">this</span>);
+00043 }
+00044
+<a name="l00045"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentCompositea20">00045</a> IAgentComposite::IAgentComposite(<a class="code" href="a02162.html">IBasicAgent</a> *parent,<a class="code" href="a02786.html">IMailBox</a> *m): <a class="code" href="a02162.html">IBasicAgent</a>(parent != NULL ? (<a class="code" href="a05333.html#a96">const</a> <a class="code" href="a03887.html">IWordNumRef</a> *) *parent:NULL,m),_SizeChild(0)
+00046 {
+00047 <span class="keywordflow">if</span>(parent) parent-&gt;<a class="code" href="a02162.html#NLAIAGENT_1_1IBasicAgenta0">addChild</a>(<span class="keyword">this</span>);
+00048 }
+00049
+<a name="l00050"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentCompositea50">00050</a> IAgentComposite::~IAgentComposite()
+00051 {
+00052 <span class="comment">/*std::list&lt;IBasicAgent *&gt;::iterator i = _AgentList.begin();</span>
+00053 <span class="comment"> while(i != _AgentList.end())</span>
+00054 <span class="comment"> { </span>
+00055 <span class="comment"> IBasicAgent *b = (*i++);</span>
+00056 <span class="comment"> }*/</span>
+00057 <a class="code" href="a02161.html#NLAIAGENT_1_1IAgentComposited0">deleteListe</a>();
+00058 }
+00059
+<a name="l00060"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentCompositea29">00060</a> <span class="keywordtype">void</span> IAgentComposite::onKill(<a class="code" href="a02164.html">IConnectIA</a> *a)
+00061 {
+00062 <span class="comment">//removeChild((const IBasicAgent *)a);</span>
+00063 IBasicAgent::onKill(a);
+00064 }
+00065
+00066 <span class="comment">// Ajoute un fils à l'agent.</span>
+<a name="l00067"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentz1611_0">00067</a> std::list&lt;IBasicAgent *&gt;::iterator IAgentComposite::addChild(<a class="code" href="a02162.html">IBasicAgent</a> *p)
+00068 {
+00069 p-&gt;<a class="code" href="a02145.html#NLAIAGENT_1_1VectorTypea16">incRef</a>();
+00070 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.push_front((<a class="code" href="a02162.html">IBasicAgent</a> *)p);
+00071 <span class="comment">// Donne au fils accès à la boite aux lettres du père</span>
+00072 p-&gt;<a class="code" href="a02162.html#NLAIAGENT_1_1IMainAgenta14">getMail</a>()-&gt;<a class="code" href="a02786.html#NLAIAGENT_1_1IMailBoxa0">addMailBox</a>( this-&gt;getMail() );
+00073 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp11">_SizeChild</a> ++;
+00074
+00075 <span class="keywordflow">return</span> <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.begin();
+00076 }
+00077
+<a name="l00078"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentz1611_1">00078</a> <span class="keywordtype">void</span> IAgentComposite::cpyChild(<span class="keyword">const</span> <a class="code" href="a02162.html">IBasicAgent</a> &amp;p)
+00079 {
+00080 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.push_front((<a class="code" href="a02162.html">IBasicAgent</a> *)p.<a class="code" href="a02151.html#NLAICHARACTER_1_1IZonea4">clone</a>());
+00081 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp11">_SizeChild</a> ++;
+00082 }
+00083
+<a name="l00084"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentz1611_2">00084</a> <span class="keywordtype">void</span> IAgentComposite::removeChild(std::list&lt;IBasicAgent *&gt;::iterator &amp;iter)
+00085 {
+00086 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.erase(iter);
+00087 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp11">_SizeChild</a> --;
+00088 }
+00089
+<a name="l00090"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentz1611_4">00090</a> <span class="keywordtype">void</span> IAgentComposite::removeChild(<span class="keyword">const</span> <a class="code" href="a02162.html">IBasicAgent</a> &amp;p)
+00091 {
+00092 std::list&lt;IBasicAgent *&gt;::iterator i = <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.begin();
+00093 <span class="keywordflow">while</span>(i != <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.end())
+00094 {
+00095 <span class="keywordflow">if</span>(*((*i)) == p)
+00096 {
+00097 (*i)-&gt;release();
+00098 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.erase(i);
+00099 <span class="comment">// Supprime chez l'ancien fils la boite au lettre du père</span>
+00100 p.<a class="code" href="a02162.html#NLAIAGENT_1_1IMainAgenta14">getMail</a>()-&gt;<a class="code" href="a02786.html#NLAIAGENT_1_1IMailBoxa41">removeMailBox</a>( this-&gt;getMail() );
+00101 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp11">_SizeChild</a> --;
+00102 <span class="keywordflow">return</span>;
+00103 }
+00104 i++;
+00105 }
+00106 }
+00107
+<a name="l00108"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentz1611_3">00108</a> <span class="keywordtype">void</span> IAgentComposite::removeChild(<span class="keyword">const</span> <a class="code" href="a02162.html">IBasicAgent</a> *p)
+00109 {
+00110 std::list&lt;IBasicAgent *&gt;::iterator i = <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.begin();
+00111 <span class="keywordflow">while</span>(i != <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.end())
+00112 {
+00113 <a class="code" href="a02162.html">IBasicAgent</a> *c = *i;
+00114 <span class="keywordflow">if</span>(c == p)
+00115 {
+00116 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.erase(i);
+00117 p-&gt;<a class="code" href="a02162.html#NLAIAGENT_1_1IMainAgenta14">getMail</a>()-&gt;<a class="code" href="a02786.html#NLAIAGENT_1_1IMailBoxa41">removeMailBox</a>( this-&gt;getMail() );
+00118 c-&gt;<a class="code" href="a02145.html#NLAIAGENT_1_1VectorTypea46">release</a>();
+00119 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp11">_SizeChild</a> --;
+00120 <span class="comment">// Supprime chez l'ancien fils la boite au lettre du père </span>
+00121 <span class="keywordflow">break</span>;
+00122 }
+00123 i++;
+00124 }
+00125 }
+<a name="l00126"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentComposited0">00126</a> <span class="keywordtype">void</span> IAgentComposite::deleteListe()
+00127 {
+00128 std::list&lt;IBasicAgent *&gt;::iterator i = <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.begin();
+00129 <span class="keywordflow">while</span>(i != <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.end())
+00130 {
+00131 <a class="code" href="a02162.html">IBasicAgent</a> *b = (*i++);
+00132 b-&gt;<a class="code" href="a02164.html#NLAIAGENT_1_1IMainAgenta41">setParent</a>(NULL);
+00133 b-&gt;<a class="code" href="a02145.html#NLAIAGENT_1_1VectorTypea46">release</a>();
+00134 }
+00135 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp11">_SizeChild</a> = 0;
+00136 }
+00137
+<a name="l00138"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentCompositez1613_1">00138</a> <span class="keywordtype">void</span> IAgentComposite::save(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;os)
+00139 {
+00140 IBasicAgent::save(os);
+00141
+00142 <a class="code" href="a04558.html#a10">sint32</a> <a class="code" href="a04223.html#a587">size</a> = <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.size();
+00143 os.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(<a class="code" href="a04223.html#a587">size</a>);
+00144 std::list&lt;IBasicAgent *&gt;::const_iterator i = <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.begin();
+00145 <span class="keywordflow">while</span>(i != <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp1">_AgentList</a>.end())
+00146 {
+00147 <a class="code" href="a02162.html">IBasicAgent</a> &amp;a = *(*i++);
+00148 os.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>( (<a class="code" href="a02650.html">NLAIC::CIdentType</a> &amp;) a.<a class="code" href="a02151.html#NLAICHARACTER_1_1IZonea20">getType</a>() );
+00149 a.<a class="code" href="a02162.html#NLAIAGENT_1_1IBasicAgentz1607_1">save</a>(os);
+00150 }
+00151 }
+00152
+<a name="l00153"></a><a class="code" href="a02161.html#NLAIAGENT_1_1IAgentCompositez1613_0">00153</a> <span class="keywordtype">void</span> IAgentComposite::load(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;is)
+00154 {
+00155 <a class="code" href="a02161.html#NLAIAGENT_1_1IAgentComposited0">deleteListe</a>();
+00156 IBasicAgent::load(is);
+00157 <a class="code" href="a02651.html">NLAIC::CIdentTypeAlloc</a> <span class="keywordtype">id</span>;
+00158 <a class="code" href="a04558.html#a10">sint32</a> i;
+00159
+00160 is.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>(i);
+00161 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentp11">_SizeChild</a> = 0;
+00162 <span class="keywordflow">while</span>(i--)
+00163 {
+00164 is.<a class="code" href="a02270.html#NLMISC_1_1IStreama5">serial</a>( <span class="keywordtype">id</span> );
+00165 <a class="code" href="a02162.html">IBasicAgent</a> &amp;a = *((<a class="code" href="a02162.html">IBasicAgent</a> *)<span class="keywordtype">id</span>.allocClass());
+00166 a.<a class="code" href="a02162.html#NLAIAGENT_1_1IBasicAgentz1607_0">load</a>(is);
+00167 <a class="code" href="a02161.html#NLAIAGENT_1_1IMainAgentz1611_0">addChild</a>(&amp;a);
+00168 }
+00169 }
+00170 }
+</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:22:39 2004 for NeL by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
+</a>1.3.6 </small></address>
+</body>
+</html>