diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/mot_8cpp-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'docs/doxygen/nel/mot_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/mot_8cpp-source.html | 780 |
1 files changed, 780 insertions, 0 deletions
diff --git a/docs/doxygen/nel/mot_8cpp-source.html b/docs/doxygen/nel/mot_8cpp-source.html new file mode 100644 index 00000000..278e2bff --- /dev/null +++ b/docs/doxygen/nel/mot_8cpp-source.html @@ -0,0 +1,780 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>mot.cpp</h1><a href="mot_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="mot_8h.html">3d/mot.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font> +00031 <font class="preprocessor">#include <algorithm></font> +00032 <font class="preprocessor">#include <list></font> +00033 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00034 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC; +00035 +00036 +00037 <font class="keyword">namespace </font>NL3D +00038 { +00039 +00040 +00041 <font class="comment">// ***************************************************************************</font> +00042 <font class="comment">// ***************************************************************************</font> +00043 <font class="comment">// CMOT static.</font> +00044 <font class="comment">// ***************************************************************************</font> +00045 <font class="comment">// ***************************************************************************</font> +00046 +00047 +00048 <font class="comment">// ***************************************************************************</font> +<a name="l00049"></a><a class="code" href="classNL3D_1_1CMOT.html#r0">00049</a> set<CMOT::CModelEntry> CMOT::RegModels; +<a name="l00050"></a><a class="code" href="classNL3D_1_1CMOT.html#r1">00050</a> set<CMOT::CObsEntry> CMOT::RegObservers; +00051 +00052 <font class="comment">// ***************************************************************************</font> +<a name="l00053"></a><a class="code" href="classNL3D_1_1CMOT.html#z612_0">00053</a> <font class="keywordtype">void</font> CMOT::registerModel(<font class="keyword">const</font> CClassId &idModel, <font class="keyword">const</font> CClassId &idModelBase, IModel* (*creator)()) +00054 { +00055 <a class="code" href="debug_8h.html#a6">nlassert</a>(idModel!=CClassId::Null); +00056 <a class="code" href="debug_8h.html#a6">nlassert</a>(creator); +00057 <font class="comment">// idModelBase may be Null...</font> +00058 +00059 CModelEntry e; +00060 e.BaseModelId= idModelBase; +00061 e.ModelId= idModel; +00062 e.Creator= creator; +00063 +00064 <font class="comment">// Insert/replace e.</font> +00065 <a class="code" href="classNL3D_1_1CMOT.html#r0">RegModels</a>.erase(e); +00066 <a class="code" href="classNL3D_1_1CMOT.html#r0">RegModels</a>.insert(e); +00067 } +00068 <font class="comment">// ***************************************************************************</font> +<a name="l00069"></a><a class="code" href="classNL3D_1_1CMOT.html#z612_1">00069</a> <font class="keywordtype">void</font> CMOT::registerObs(<font class="keyword">const</font> CClassId &idTrav, <font class="keyword">const</font> CClassId &idModel, IObs* (*creator)()) +00070 { +00071 <a class="code" href="debug_8h.html#a6">nlassert</a>(idTrav!=CClassId::Null); +00072 <a class="code" href="debug_8h.html#a6">nlassert</a>(idModel!=CClassId::Null); +00073 <a class="code" href="debug_8h.html#a6">nlassert</a>(creator); +00074 +00075 CObsEntry e; +00076 e.ModelId= idModel; +00077 e.TravId= idTrav; +00078 e.Creator= creator; +00079 +00080 <font class="comment">// Insert/replace e.</font> +00081 <a class="code" href="classNL3D_1_1CMOT.html#r1">RegObservers</a>.erase(e); +00082 <a class="code" href="classNL3D_1_1CMOT.html#r1">RegObservers</a>.insert(e); +00083 } +00084 +00085 +00086 <font class="comment">// ***************************************************************************</font> +00087 <font class="comment">// ***************************************************************************</font> +00088 <font class="comment">// CMOT.</font> +00089 <font class="comment">// ***************************************************************************</font> +00090 <font class="comment">// ***************************************************************************</font> +00091 +00092 +00093 <font class="comment">// ***************************************************************************</font> +<a name="l00094"></a><a class="code" href="classNL3D_1_1CMOT.html#a0">00094</a> CMOT::CMOT() +00095 { +00096 <a class="code" href="classNL3D_1_1CMOT.html#o2">_ValidateModelList</a>= NULL; +00097 } +00098 <font class="comment">// ***************************************************************************</font> +<a name="l00099"></a><a class="code" href="classNL3D_1_1CMOT.html#a1">00099</a> CMOT::~CMOT() +00100 { +00101 <a class="code" href="classNL3D_1_1CMOT.html#a2">release</a>(); +00102 } +00103 +00104 <font class="comment">// ***************************************************************************</font> +<a name="l00105"></a><a class="code" href="classNL3D_1_1CMOT.html#z613_0">00105</a> <font class="keywordtype">void</font> CMOT::addTrav(ITrav *<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>) +00106 { +00107 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); +00108 CClassId idTrav= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>->getClassId(); +00109 <a class="code" href="debug_8h.html#a6">nlassert</a>(idTrav!=CClassId::Null); +00110 +00111 CTravEntry e; +00112 e.TravId= idTrav; +00113 e.Trav= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>; +00114 +00115 <a class="code" href="classNL3D_1_1CMOT.html#o0">Traversals</a>.push_back(e); +00116 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>->addedToMOT(<font class="keyword">this</font>); +00117 } +00118 <font class="comment">// ***************************************************************************</font> +<a name="l00119"></a><a class="code" href="classNL3D_1_1CMOT.html#z613_3">00119</a> ITrav *CMOT::getTrav(<font class="keyword">const</font> CClassId &idTrav)<font class="keyword"> const </font> +00120 <font class="keyword"></font>{ +00121 std::vector<CTravEntry>::const_iterator it; +00122 +00123 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CMOT.html#o0">Traversals</a>.begin(); it!= <a class="code" href="classNL3D_1_1CMOT.html#o0">Traversals</a>.end(); it++) +00124 { +00125 <font class="keywordflow">if</font>(idTrav== (*it).TravId) +00126 <font class="keywordflow">return</font> (*it).Trav; +00127 } +00128 +00129 <font class="keywordflow">return</font> NULL; +00130 } +00131 <font class="comment">// ***************************************************************************</font> +<a name="l00132"></a><a class="code" href="classNL3D_1_1CMOT.html#a2">00132</a> <font class="keywordtype">void</font> CMOT::release() +00133 { +00134 <font class="comment">// First, release all the models.</font> +00135 set<IModel*>::iterator it; +00136 it= <a class="code" href="classNL3D_1_1CMOT.html#o1">Models</a>.begin(); +00137 <font class="keywordflow">while</font>( it!=<a class="code" href="classNL3D_1_1CMOT.html#o1">Models</a>.end()) +00138 { +00139 <a class="code" href="classNL3D_1_1CMOT.html#z614_1">deleteModel</a>(*it); +00140 it= <a class="code" href="classNL3D_1_1CMOT.html#o1">Models</a>.begin(); +00141 } +00142 <font class="comment">// No models at all.</font> +00143 <a class="code" href="classNL3D_1_1CMOT.html#o2">_ValidateModelList</a>= NULL; +00144 +00145 <font class="comment">// Then release the traversals ptrs.</font> +00146 <a class="code" href="classNL3D_1_1CMOT.html#o0">Traversals</a>.clear(); +00147 } +00148 +00149 +00150 <font class="comment">// ***************************************************************************</font> +<a name="l00151"></a><a class="code" href="classNL3D_1_1CMOT.html#z614_0">00151</a> IModel *CMOT::createModel(<font class="keyword">const</font> CClassId &idModel) +00152 { +00153 <a class="code" href="debug_8h.html#a6">nlassert</a>(idModel!=CClassId::Null); +00154 +00155 CModelEntry e; +00156 e.ModelId= idModel; +00157 set<CModelEntry>::iterator itModel; +00158 itModel= <a class="code" href="classNL3D_1_1CMOT.html#r0">RegModels</a>.find(e); +00159 +00160 <font class="keywordflow">if</font>(itModel==<a class="code" href="classNL3D_1_1CMOT.html#r0">RegModels</a>.end()) +00161 { +00162 <a class="code" href="debug_8h.html#a12">nlstop</a>; <font class="comment">// Warning, CScene::registerBasics () has not been called !</font> +00163 <font class="keywordflow">return</font> NULL; +00164 } +00165 <font class="keywordflow">else</font> +00166 { +00167 <a class="code" href="classNL3D_1_1CMOT.html#l0">IModel</a> *m= (*itModel).Creator(); +00168 <font class="keywordflow">if</font>(!m) <font class="keywordflow">return</font> NULL; +00169 +00170 <font class="comment">// Set the owner for the model.</font> +00171 m->_OwnerMot= <font class="keyword">this</font>; +00172 +00173 <font class="comment">// create observer for each trav.</font> +00174 std::vector<CTravEntry>::const_iterator itTrav; +00175 <font class="keywordflow">for</font>(itTrav= <a class="code" href="classNL3D_1_1CMOT.html#o0">Traversals</a>.begin(); itTrav!=<a class="code" href="classNL3D_1_1CMOT.html#o0">Traversals</a>.end(); itTrav++) +00176 { +00177 <font class="comment">// Create observer.</font> +00178 IObs *obs= <a class="code" href="classNL3D_1_1CMOT.html#c0">createObs</a>((*itTrav).Trav, idModel); +00179 <a class="code" href="debug_8h.html#a6">nlassert</a>(obs); +00180 <font class="comment">// Init model.</font> +00181 obs->Model= m; +00182 obs->Trav= (*itTrav).Trav; +00183 <font class="comment">// Attach it to Model.</font> +00184 m->Observers.insert(IModel::CObsMap::value_type((*itTrav).TravId, obs)); +00185 <font class="comment">// Attach them to traversal's root.</font> +00186 <font class="keywordflow">if</font>((*itTrav).Trav->getRoot()) +00187 (*itTrav).Trav->link(NULL, m); +00188 } +00189 +00190 <font class="comment">// After m finished, init the observers.</font> +00191 IModel::CObsMap::const_iterator itObs; +00192 <font class="keywordflow">for</font>(itObs= m->Observers.begin(); itObs!=m->Observers.end(); itObs++) +00193 { +00194 IObs *o= (*itObs).second; +00195 o->init(); +00196 } +00197 +00198 <font class="comment">// Insert the model into the set.</font> +00199 <a class="code" href="classNL3D_1_1CMOT.html#o1">Models</a>.insert(m); +00200 +00201 <font class="comment">// By default the model is validate() in CMOT::validateModels().</font> +00202 m->linkToValidateList(); +00203 +00204 <font class="comment">// Once the model is correclty created, finish init him.</font> +00205 m->initModel(); +00206 +00207 <font class="keywordflow">return</font> m; +00208 } +00209 } +00210 <font class="comment">// ***************************************************************************</font> +<a name="l00211"></a><a class="code" href="classNL3D_1_1CMOT.html#z614_1">00211</a> <font class="keywordtype">void</font> CMOT::deleteModel(IModel *model) +00212 { +00213 <font class="keywordflow">if</font>(model==NULL) +00214 <font class="keywordflow">return</font>; +00215 set<IModel*>::iterator it= <a class="code" href="classNL3D_1_1CMOT.html#o1">Models</a>.find(model); +00216 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CMOT.html#o1">Models</a>.end()) +00217 { +00218 <font class="keyword">delete</font> *it; +00219 <a class="code" href="classNL3D_1_1CMOT.html#o1">Models</a>.erase(it); +00220 } +00221 } +00222 +00223 +00224 <font class="comment">// ***************************************************************************</font> +<a name="l00225"></a><a class="code" href="classNL3D_1_1CMOT.html#z614_2">00225</a> <font class="keywordtype">void</font> CMOT::validateModels() +00226 { +00227 <font class="comment">// check all the models which must be checked.</font> +00228 <a class="code" href="classNL3D_1_1CMOT.html#l0">IModel</a> *model= <a class="code" href="classNL3D_1_1CMOT.html#o2">_ValidateModelList</a>; +00229 <a class="code" href="classNL3D_1_1CMOT.html#l0">IModel</a> *next; +00230 <font class="keywordflow">while</font>( model ) +00231 { +00232 <font class="comment">// next to validate. get next now, because model->validate() may remove model from the list.</font> +00233 next= model->_NextModelToValidate; +00234 +00235 <font class="comment">// chek / validate the model.</font> +00236 model->validate(); +00237 +00238 <font class="comment">// next.</font> +00239 model= next; +00240 } +00241 } +00242 +00243 +00244 <font class="comment">// ***************************************************************************</font> +<a name="l00245"></a><a class="code" href="classNL3D_1_1CMOT.html#c0">00245</a> IObs *CMOT::createObs(<font class="keyword">const</font> ITrav *trav, <font class="keyword">const</font> CClassId &idModel)<font class="keyword"> const</font> +00246 <font class="keyword"></font>{ +00247 <a class="code" href="debug_8h.html#a6">nlassert</a>(trav); +00248 CClassId idTrav= trav->getClassId(); +00249 <a class="code" href="debug_8h.html#a6">nlassert</a>(idTrav!=CClassId::Null); +00250 +00251 <font class="keywordflow">if</font>(idModel==CClassId::Null) +00252 { +00253 <font class="comment">// Use trav to create default observer.</font> +00254 <font class="keywordflow">return</font> trav->createDefaultObs(); +00255 } +00256 +00257 CObsEntry e; +00258 e.TravId= idTrav; +00259 e.ModelId= idModel; +00260 std::set<CObsEntry>::iterator it; +00261 it= <a class="code" href="classNL3D_1_1CMOT.html#r1">RegObservers</a>.find(e); +00262 +00263 <font class="keywordflow">if</font>(it==<a class="code" href="classNL3D_1_1CMOT.html#r1">RegObservers</a>.end()) +00264 { +00265 <font class="comment">// Try the father of the model.</font> +00266 CModelEntry e; +00267 e.ModelId= idModel; +00268 set<CModelEntry>::iterator it; +00269 it= <a class="code" href="classNL3D_1_1CMOT.html#r0">RegModels</a>.find(e); +00270 +00271 <a class="code" href="debug_8h.html#a6">nlassert</a>(it!=<a class="code" href="classNL3D_1_1CMOT.html#r0">RegModels</a>.end()); +00272 +00273 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CMOT.html#c0">createObs</a>(trav, (*it).BaseModelId); +00274 } +00275 <font class="keywordflow">else</font> +00276 { +00277 <font class="comment">// Register with the specified observer.</font> +00278 <font class="keywordflow">return</font> (*it).Creator(); +00279 } +00280 } +00281 +00282 +00283 <font class="comment">// ***************************************************************************</font> +<a name="l00284"></a><a class="code" href="classNL3D_1_1CMOT.html#b0">00284</a> IObs *CMOT::getModelObs(IModel *m, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CClassId.html">NLMISC::CClassId</a> &idTrav)<font class="keyword"> const</font> +00285 <font class="keyword"></font>{ +00286 <font class="keywordflow">if</font>(!m) +00287 <font class="keywordflow">return</font> NULL; +00288 <font class="keywordflow">return</font> m->getObs(idTrav); +00289 } +00290 +00291 +00292 <font class="comment">// ***************************************************************************</font> +00293 <font class="comment">// ***************************************************************************</font> +00294 <font class="comment">// ITrav.</font> +00295 <font class="comment">// ***************************************************************************</font> +00296 <font class="comment">// ***************************************************************************</font> +00297 +00298 +00299 <font class="comment">// ***************************************************************************</font> +<a name="l00300"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_0">00300</a> <font class="keywordtype">void</font> ITrav::setRoot(IModel *root) +00301 { +00302 <font class="keywordflow">if</font>(root) +00303 <a class="code" href="classNL3D_1_1ITrav.html#n0">Root</a>= root->getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>()); +00304 <font class="keywordflow">else</font> +00305 <a class="code" href="classNL3D_1_1ITrav.html#n0">Root</a>= NULL; +00306 } +00307 <font class="comment">// ***************************************************************************</font> +<a name="l00308"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_1">00308</a> IModel *ITrav::getRoot()<font class="keyword"> const</font> +00309 <font class="keyword"></font>{ +00310 <font class="keywordflow">if</font>(Root) +00311 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1ITrav.html#n0">Root</a>->Model; +00312 <font class="keywordflow">else</font> +00313 <font class="keywordflow">return</font> NULL; +00314 } +00315 +00316 <font class="comment">// ***************************************************************************</font> +<a name="l00317"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_2">00317</a> <font class="keywordtype">void</font> ITrav::link(IModel *m1, IModel *m2)<font class="keyword"> const</font> +00318 <font class="keyword"></font>{ +00319 IObs *o1,*o2; +00320 +00321 <a class="code" href="debug_8h.html#a6">nlassert</a>(m2); +00322 CClassId travId= <a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>(); +00323 +00324 <font class="keywordflow">if</font>(m1) +00325 { +00326 o1= m1->getObs(travId); +00327 <a class="code" href="debug_8h.html#a6">nlassert</a>(o1); +00328 } +00329 <font class="keywordflow">else</font> +00330 { +00331 o1= <a class="code" href="classNL3D_1_1ITrav.html#n0">Root</a>; +00332 <font class="comment">// If his one is NULL, return.</font> +00333 <font class="comment">// NB: this may not be an error. eg: in CScene::release(), when all models are deleted, </font> +00334 <font class="comment">// a ~CSkeletonModel() call link() to Root, but Root model may have been deleted first!!!</font> +00335 <font class="keywordflow">if</font>(!o1) +00336 <font class="keywordflow">return</font>; +00337 } +00338 o2= m2->getObs(travId); +00339 <a class="code" href="debug_8h.html#a6">nlassert</a>(o1); +00340 <a class="code" href="debug_8h.html#a6">nlassert</a>(o2); +00341 o2->addParent(o1); +00342 o1->addChild(o2); +00343 } +00344 <font class="comment">// ***************************************************************************</font> +<a name="l00345"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_3">00345</a> <font class="keywordtype">void</font> ITrav::unlink(IModel *m1, IModel *m2)<font class="keyword"> const</font> +00346 <font class="keyword"></font>{ +00347 IObs *o1,*o2; +00348 +00349 <a class="code" href="debug_8h.html#a6">nlassert</a>(m2); +00350 CClassId travId= <a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>(); +00351 +00352 <font class="keywordflow">if</font>(m1) +00353 { +00354 o1= m1->getObs(travId); +00355 <a class="code" href="debug_8h.html#a6">nlassert</a>(o1); +00356 } +00357 <font class="keywordflow">else</font> +00358 { +00359 o1= <a class="code" href="classNL3D_1_1ITrav.html#n0">Root</a>; +00360 <font class="comment">// If his one is NULL, return.</font> +00361 <font class="comment">// NB: this may not be an error. eg: in CScene::release(), when all models are deleted, </font> +00362 <font class="comment">// a ~CSkeletonModel() call link() to Root, but Root model may have been deleted first!!!</font> +00363 <font class="keywordflow">if</font>(!o1) +00364 <font class="keywordflow">return</font>; +00365 } +00366 o2= m2->getObs(travId); +00367 <a class="code" href="debug_8h.html#a6">nlassert</a>(o1); +00368 <a class="code" href="debug_8h.html#a6">nlassert</a>(o2); +00369 o2->delParent(o1); +00370 o1->delChild(o2); +00371 } +00372 +00373 <font class="comment">// ***************************************************************************</font> +<a name="l00374"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_4">00374</a> <font class="keywordtype">void</font> ITrav::moveChildren(IModel *parentFrom, IModel *parentTo)<font class="keyword"> const</font> +00375 <font class="keyword"></font>{ +00376 <font class="comment">// Make a local list of children (since link() modify the list).</font> +00377 list<IModel *> children; +00378 <font class="keywordflow">for</font>(IModel *c= <a class="code" href="classNL3D_1_1ITrav.html#z623_7">getFirstChild</a>(parentFrom); c!=NULL; c= <a class="code" href="classNL3D_1_1ITrav.html#z623_8">getNextChild</a>(parentFrom)) +00379 children.push_back(c); +00380 +00381 <font class="keywordflow">for</font>(list<IModel *>::iterator it= children.begin(); it!= children.end();it++) +00382 { +00383 <a class="code" href="classNL3D_1_1ITrav.html#z623_3">unlink</a>(parentFrom, *it); +00384 <a class="code" href="classNL3D_1_1ITrav.html#z623_2">link</a>(parentTo, *it); +00385 } +00386 } +00387 <font class="comment">// ***************************************************************************</font> +<a name="l00388"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_5">00388</a> <font class="keywordtype">void</font> ITrav::copyChildren(IModel *parentFrom, IModel *parentTo)<font class="keyword"> const</font> +00389 <font class="keyword"></font>{ +00390 <font class="comment">// Make a local list of children (since link() modify the list).</font> +00391 list<IModel *> children; +00392 <font class="keywordflow">for</font>(IModel *c= <a class="code" href="classNL3D_1_1ITrav.html#z623_7">getFirstChild</a>(parentFrom); c!=NULL; c= <a class="code" href="classNL3D_1_1ITrav.html#z623_8">getNextChild</a>(parentFrom)) +00393 children.push_back(c); +00394 +00395 <font class="keywordflow">for</font>(list<IModel *>::iterator it= children.begin(); it!= children.end();it++) +00396 { +00397 <a class="code" href="classNL3D_1_1ITrav.html#z623_2">link</a>(parentTo, *it); +00398 } +00399 } +00400 +00401 +00402 <font class="comment">// ***************************************************************************</font> +<a name="l00403"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_6">00403</a> sint ITrav::getNumChildren (IModel *m)<font class="keyword"> const</font> +00404 <font class="keyword"></font>{ +00405 IObs *o = m->getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>()); +00406 <font class="keywordflow">return</font> o->getNumChildren(); +00407 } +00408 <font class="comment">// ***************************************************************************</font> +<a name="l00409"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_7">00409</a> IModel* ITrav::getFirstChild (IModel *m)<font class="keyword"> const</font> +00410 <font class="keyword"></font>{ +00411 IObs *o = m->getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>()); +00412 IObs *child = o->getFirstChild(); +00413 <font class="keywordflow">if</font> (child != NULL) +00414 <font class="keywordflow">return</font> child->Model; +00415 <font class="keywordflow">return</font> NULL; +00416 } +00417 <font class="comment">// ***************************************************************************</font> +<a name="l00418"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_8">00418</a> IModel* ITrav::getNextChild (IModel *m)<font class="keyword"> const</font> +00419 <font class="keyword"></font>{ +00420 IObs *o = m->getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>()); +00421 IObs *child = o->getNextChild(); +00422 <font class="keywordflow">if</font> (child != NULL) +00423 <font class="keywordflow">return</font> child->Model; +00424 <font class="keywordflow">return</font> NULL; +00425 } +00426 +00427 <font class="comment">// ***************************************************************************</font> +<a name="l00428"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_9">00428</a> sint ITrav::getNumParents (IModel *m)<font class="keyword"> const</font> +00429 <font class="keyword"></font>{ +00430 IObs *o = m->getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>()); +00431 <font class="keywordflow">return</font> o->getNumParents(); +00432 } +00433 <font class="comment">// ***************************************************************************</font> +<a name="l00434"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_10">00434</a> IModel* ITrav::getFirstParent (IModel *m)<font class="keyword"> const</font> +00435 <font class="keyword"></font>{ +00436 IObs *o = m->getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>()); +00437 IObs *father = o->getFirstParent(); +00438 <font class="keywordflow">if</font> (father != NULL) +00439 <font class="keywordflow">return</font> father->Model; +00440 <font class="keywordflow">return</font> NULL; +00441 +00442 } +00443 <font class="comment">// ***************************************************************************</font> +<a name="l00444"></a><a class="code" href="classNL3D_1_1ITrav.html#z623_11">00444</a> IModel* ITrav::getNextParent (IModel *m)<font class="keyword"> const</font> +00445 <font class="keyword"></font>{ +00446 IObs *o = m->getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>()); +00447 IObs *father = o->getNextParent(); +00448 <font class="keywordflow">if</font> (father != NULL) +00449 <font class="keywordflow">return</font> father->Model; +00450 <font class="keywordflow">return</font> NULL; +00451 } +00452 +00453 +00454 +00455 +00456 <font class="comment">// ***************************************************************************</font> +00457 <font class="comment">// ***************************************************************************</font> +00458 <font class="comment">// IModel.</font> +00459 <font class="comment">// ***************************************************************************</font> +00460 <font class="comment">// ***************************************************************************</font> +00461 +00462 +00463 <font class="comment">// ***************************************************************************</font> +<a name="l00464"></a><a class="code" href="classNL3D_1_1IModel.html#b0">00464</a> IModel::IModel() +00465 { +00466 <a class="code" href="classNL3D_1_1IModel.html#z615_3">TouchObs</a>.<a class="code" href="classNLMISC_1_1CBitSet.html#z272_0">resize</a>(<a class="code" href="classNL3D_1_1IModel.html#z615_0s1">Last</a>); +00467 <a class="code" href="classNL3D_1_1IModel.html#n1">LastClassId</a>= 0; +00468 <a class="code" href="classNL3D_1_1IModel.html#n2">LastObs</a>= NULL; +00469 +00470 <a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>= NULL; +00471 <a class="code" href="classNL3D_1_1IModel.html#n4">_PrecModelToValidate</a>= NULL; +00472 <a class="code" href="classNL3D_1_1IModel.html#n5">_NextModelToValidate</a>= NULL; +00473 } +00474 <font class="comment">// ***************************************************************************</font> +<a name="l00475"></a><a class="code" href="classNL3D_1_1IModel.html#b2">00475</a> IModel::~IModel() +00476 { +00477 <font class="comment">// ensure the model is no more linked to the validateList.</font> +00478 <a class="code" href="classNL3D_1_1IModel.html#z616_3">unlinkFromValidateList</a>(); +00479 +00480 <font class="comment">// delte observers.</font> +00481 CObsMap::iterator it; +00482 <font class="keywordflow">for</font>(it=<a class="code" href="classNL3D_1_1IModel.html#n0">Observers</a>.begin();it!=<a class="code" href="classNL3D_1_1IModel.html#n0">Observers</a>.end();it++) +00483 { +00484 <font class="keyword">delete</font> (*it).second; +00485 (*it).second=NULL; +00486 } +00487 } +00488 <font class="comment">// ***************************************************************************</font> +<a name="l00489"></a><a class="code" href="classNL3D_1_1IModel.html#b3">00489</a> IObs *IModel::getObs(<font class="keyword">const</font> CClassId &idTrav)<font class="keyword"> const </font> +00490 <font class="keyword"></font>{ +00491 CObsMap::const_iterator it; +00492 +00493 <font class="keywordflow">if</font>(idTrav==<a class="code" href="classNL3D_1_1IModel.html#n1">LastClassId</a>) +00494 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1IModel.html#n2">LastObs</a>; +00495 +00496 <a class="code" href="classNL3D_1_1IModel.html#n1">LastClassId</a>= idTrav; +00497 it= <a class="code" href="classNL3D_1_1IModel.html#n0">Observers</a>.find(idTrav); +00498 <font class="keywordflow">if</font>(it==<a class="code" href="classNL3D_1_1IModel.html#n0">Observers</a>.end()) +00499 <a class="code" href="classNL3D_1_1IModel.html#n2">LastObs</a>= NULL; +00500 <font class="keywordflow">else</font> +00501 <a class="code" href="classNL3D_1_1IModel.html#n2">LastObs</a>= (*it).second; +00502 +00503 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1IModel.html#n2">LastObs</a>; +00504 } +00505 +00506 +00507 <font class="comment">// ***************************************************************************</font> +<a name="l00508"></a><a class="code" href="classNL3D_1_1IModel.html#z615_2">00508</a> <font class="keywordtype">void</font> IModel::validate() +00509 { +00510 <a class="code" href="classNL3D_1_1IModel.html#z616_0">update</a>(); +00511 +00512 <font class="comment">// If the model is newer than observers.</font> +00513 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IModel.html#z615_3">TouchObs</a>[IModel::Dirty]) +00514 { +00515 <font class="comment">// update all model's observers.</font> +00516 IModel::CObsMap::iterator it; +00517 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1IModel.html#n0">Observers</a>.begin(); it!= <a class="code" href="classNL3D_1_1IModel.html#n0">Observers</a>.end(); it++) +00518 { +00519 <a class="code" href="classNL3D_1_1IModel.html#l1">IObs</a> *o= (*it).second; +00520 o->update(); +00521 } +00522 +00523 <font class="comment">// Must clear all dirty falgs.</font> +00524 <a class="code" href="classNL3D_1_1IModel.html#z616_1">cleanTouch</a>(); +00525 } +00526 } +00527 +00528 +00529 <font class="comment">// ***************************************************************************</font> +<a name="l00530"></a><a class="code" href="classNL3D_1_1IModel.html#z616_2">00530</a> <font class="keywordtype">void</font> IModel::linkToValidateList() +00531 { +00532 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>) +00533 <font class="keywordflow">return</font>; +00534 +00535 <font class="comment">// If the model is not already inserted.</font> +00536 <font class="keywordflow">if</font>( ! (<a class="code" href="classNL3D_1_1IModel.html#n4">_PrecModelToValidate</a>!=NULL || <a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>->_ValidateModelList==<font class="keyword">this</font>) ) +00537 { +00538 <font class="comment">// insert it.</font> +00539 <a class="code" href="classNL3D_1_1IModel.html#n5">_NextModelToValidate</a>= <a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>->_ValidateModelList; +00540 <a class="code" href="classNL3D_1_1IModel.html#n4">_PrecModelToValidate</a>= NULL; +00541 <font class="keywordflow">if</font>(_NextModelToValidate) +00542 <a class="code" href="classNL3D_1_1IModel.html#n5">_NextModelToValidate</a>->_PrecModelToValidate= <font class="keyword">this</font>; +00543 <a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>->_ValidateModelList= <font class="keyword">this</font>; +00544 } +00545 } +00546 +00547 +00548 <font class="comment">// ***************************************************************************</font> +<a name="l00549"></a><a class="code" href="classNL3D_1_1IModel.html#z616_3">00549</a> <font class="keywordtype">void</font> IModel::unlinkFromValidateList() +00550 { +00551 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>) +00552 <font class="keywordflow">return</font>; +00553 +00554 <font class="comment">// If the model is inserted.</font> +00555 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1IModel.html#n4">_PrecModelToValidate</a>!=NULL || <a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>->_ValidateModelList==<font class="keyword">this</font> ) +00556 { +00557 <font class="comment">// update prec.</font> +00558 <font class="keywordflow">if</font>(_PrecModelToValidate) +00559 <a class="code" href="classNL3D_1_1IModel.html#n4">_PrecModelToValidate</a>->_NextModelToValidate= <a class="code" href="classNL3D_1_1IModel.html#n5">_NextModelToValidate</a>; +00560 <font class="keywordflow">else</font> +00561 <a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>->_ValidateModelList= <a class="code" href="classNL3D_1_1IModel.html#n5">_NextModelToValidate</a>; +00562 +00563 <font class="comment">// update next.</font> +00564 <font class="keywordflow">if</font>(_NextModelToValidate) +00565 <a class="code" href="classNL3D_1_1IModel.html#n5">_NextModelToValidate</a>->_PrecModelToValidate= <a class="code" href="classNL3D_1_1IModel.html#n4">_PrecModelToValidate</a>; +00566 +00567 <font class="comment">// End.</font> +00568 <a class="code" href="classNL3D_1_1IModel.html#n4">_PrecModelToValidate</a>= NULL; +00569 <a class="code" href="classNL3D_1_1IModel.html#n5">_NextModelToValidate</a>= NULL; +00570 } +00571 } +00572 +00573 +00574 +00575 <font class="comment">// ***************************************************************************</font> +00576 <font class="comment">// ***************************************************************************</font> +00577 <font class="comment">// IObs.</font> +00578 <font class="comment">// ***************************************************************************</font> +00579 <font class="comment">// ***************************************************************************</font> +00580 +00581 +00582 +00583 <font class="comment">// ***************************************************************************</font> +<a name="l00584"></a><a class="code" href="classNL3D_1_1IObs.html#a0">00584</a> IObs::IObs() +00585 { +00586 <a class="code" href="classNL3D_1_1IObs.html#m0">Model</a>= NULL; +00587 <a class="code" href="classNL3D_1_1IObs.html#m1">Trav</a>= NULL; +00588 +00589 <a class="code" href="classNL3D_1_1IObs.html#n4">NumFathers</a>= 0; +00590 <a class="code" href="classNL3D_1_1IObs.html#n5">NumSons</a>= 0; +00591 <a class="code" href="classNL3D_1_1IObs.html#n6">CurSonIt</a>= <a class="code" href="classNL3D_1_1IObs.html#n0">SonList</a>.end(); +00592 <a class="code" href="classNL3D_1_1IObs.html#n7">CurFatherIt</a>= <a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.end(); +00593 } +00594 <font class="comment">// ***************************************************************************</font> +<a name="l00595"></a><a class="code" href="classNL3D_1_1IObs.html#a1">00595</a> IObs::~IObs() +00596 { +00597 <a class="code" href="classNL3D_1_1IObs.html#t1">ItObsList</a> it; +00598 +00599 <font class="comment">// delete map of Its.</font> +00600 <a class="code" href="classNL3D_1_1IObs.html#n2">SonMap</a>.clear(); +00601 <a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.clear(); +00602 +00603 <font class="comment">// Delete link from fathers.</font> +00604 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.begin(); it!=<a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.end(); it++) +00605 { +00606 <a class="code" href="classNL3D_1_1IObs.html#a0">IObs</a> *father= (*it); +00607 <font class="comment">// Must use delChild() since don't know what father is.</font> +00608 father->delChild(<font class="keyword">this</font>); +00609 } +00610 +00611 <font class="comment">// Delete link from sons.</font> +00612 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1IObs.html#n0">SonList</a>.begin(); it!=<a class="code" href="classNL3D_1_1IObs.html#n0">SonList</a>.end(); it++) +00613 { +00614 <a class="code" href="classNL3D_1_1IObs.html#a0">IObs</a> *son= (*it); +00615 <font class="comment">// Must use delParent() since don't know what son is.</font> +00616 son->delParent(<font class="keyword">this</font>); +00617 } +00618 +00619 <font class="comment">// And so delete lists.</font> +00620 <a class="code" href="classNL3D_1_1IObs.html#n0">SonList</a>.clear(); +00621 <a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.clear(); +00622 <a class="code" href="classNL3D_1_1IObs.html#n4">NumFathers</a>= 0; +00623 <a class="code" href="classNL3D_1_1IObs.html#n5">NumSons</a>= 0; +00624 } +00625 <font class="comment">// ***************************************************************************</font> +<a name="l00626"></a><a class="code" href="classNL3D_1_1IObs.html#z620_1">00626</a> IObs *IObs::getObs(<font class="keyword">const</font> CClassId &idTrav)<font class="keyword"> const</font> +00627 <font class="keyword"></font>{ +00628 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1IObs.html#m0">Model</a>->getObs(idTrav); +00629 } +00630 +00631 +00632 <font class="comment">// ***************************************************************************</font> +<a name="l00633"></a><a class="code" href="classNL3D_1_1IObs.html#z617_1">00633</a> <font class="keywordtype">void</font> IObs::addChild(IObs *son) +00634 { +00635 <a class="code" href="debug_8h.html#a6">nlassert</a>(son); +00636 +00637 <font class="comment">// insert (if not exist).</font> +00638 <a class="code" href="classNL3D_1_1IObs.html#t4">ItObsMap</a> it= <a class="code" href="classNL3D_1_1IObs.html#n2">SonMap</a>.find(son); +00639 <font class="keywordflow">if</font>(it==<a class="code" href="classNL3D_1_1IObs.html#n2">SonMap</a>.end()) +00640 { +00641 <font class="comment">// insert in the map and in the list.</font> +00642 <a class="code" href="classNL3D_1_1IObs.html#n2">SonMap</a>[son]= <a class="code" href="classNL3D_1_1IObs.html#n0">SonList</a>.insert(<a class="code" href="classNL3D_1_1IObs.html#n0">SonList</a>.end(), son); +00643 <a class="code" href="classNL3D_1_1IObs.html#n5">NumSons</a>++; +00644 } +00645 } +00646 <font class="comment">// ***************************************************************************</font> +<a name="l00647"></a><a class="code" href="classNL3D_1_1IObs.html#z617_2">00647</a> <font class="keywordtype">void</font> IObs::delChild(IObs *son) +00648 { +00649 <a class="code" href="debug_8h.html#a6">nlassert</a>(son); +00650 +00651 <font class="comment">// Just erase (if possible).</font> +00652 <a class="code" href="classNL3D_1_1IObs.html#t4">ItObsMap</a> it= <a class="code" href="classNL3D_1_1IObs.html#n2">SonMap</a>.find(son); +00653 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1IObs.html#n2">SonMap</a>.end()) +00654 { +00655 <font class="comment">// erase from list, then from mapt</font> +00656 <a class="code" href="classNL3D_1_1IObs.html#n0">SonList</a>.erase(it->second); +00657 <a class="code" href="classNL3D_1_1IObs.html#n2">SonMap</a>.erase(it); +00658 <a class="code" href="classNL3D_1_1IObs.html#n5">NumSons</a>--; +00659 } +00660 } +00661 <font class="comment">// ***************************************************************************</font> +<a name="l00662"></a><a class="code" href="classNL3D_1_1IObs.html#z617_3">00662</a> <font class="keywordtype">void</font> IObs::addParent(IObs *father) +00663 { +00664 <a class="code" href="debug_8h.html#a6">nlassert</a>(father); +00665 +00666 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1IObs.html#z617_0">isTreeNode</a>()) +00667 { +00668 <font class="comment">// Must test if father is already linked.</font> +00669 <a class="code" href="classNL3D_1_1IObs.html#t4">ItObsMap</a> itMap; +00670 itMap= <a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.find(father); +00671 <font class="keywordflow">if</font>(itMap!=<a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.end()) +00672 <font class="keywordflow">return</font>; <font class="comment">// father is already a parent of this.</font> +00673 +00674 <font class="comment">// Tree node, so delete fathers, and fathers links to me.</font> +00675 <font class="keywordflow">for</font>(<a class="code" href="classNL3D_1_1IObs.html#t1">ItObsList</a> it= <a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.begin(); it!=<a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.end();it++) +00676 { +00677 <font class="comment">// Must use delChild() since don't know what father is.</font> +00678 (*it)->delChild(<font class="keyword">this</font>); +00679 } +00680 <a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.clear(); +00681 <a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.clear(); +00682 } +00683 +00684 <font class="comment">// insert (if not exist).</font> +00685 <a class="code" href="classNL3D_1_1IObs.html#t4">ItObsMap</a> it= <a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.find(father); +00686 <font class="keywordflow">if</font>(it==<a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.end()) +00687 { +00688 <font class="comment">// insert in the map and in the list.</font> +00689 <a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>[father]= <a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.insert(<a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.end(), father); +00690 <a class="code" href="classNL3D_1_1IObs.html#n4">NumFathers</a>++; +00691 } +00692 } +00693 <font class="comment">// ***************************************************************************</font> +<a name="l00694"></a><a class="code" href="classNL3D_1_1IObs.html#z617_4">00694</a> <font class="keywordtype">void</font> IObs::delParent(IObs *father) +00695 { +00696 <a class="code" href="debug_8h.html#a6">nlassert</a>(father); +00697 +00698 <font class="comment">// Just erase (if possible).</font> +00699 <a class="code" href="classNL3D_1_1IObs.html#t4">ItObsMap</a> it= <a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.find(father); +00700 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.end()) +00701 { +00702 <font class="comment">// erase from list, then from mapt</font> +00703 <a class="code" href="classNL3D_1_1IObs.html#n1">FatherList</a>.erase(it->second); +00704 <a class="code" href="classNL3D_1_1IObs.html#n3">FatherMap</a>.erase(it); +00705 <a class="code" href="classNL3D_1_1IObs.html#n4">NumFathers</a>--; +00706 } +00707 } +00708 +00709 +00710 +00711 } +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |