aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/mot_8cpp-source.html
blob: df9e6abacfd25c2a70538a3159fae365238f7966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
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="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/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="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/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="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- 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="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </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 &lt;algorithm&gt;</font>
00032 <font class="preprocessor">#include &lt;list&gt;</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&lt;CMOT::CModelEntry&gt;          CMOT::RegModels;
<a name="l00050"></a><a class="code" href="classNL3D_1_1CMOT.html#r1">00050</a> set&lt;CMOT::CObsEntry&gt;            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 &amp;idModel, <font class="keyword">const</font> CClassId &amp;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 &amp;idTrav, <font class="keyword">const</font> CClassId &amp;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>-&gt;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>-&gt;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 &amp;idTrav)<font class="keyword"> const </font>
00120 <font class="keyword"></font>{
00121         std::vector&lt;CTravEntry&gt;::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&lt;IModel*&gt;::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 &amp;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&lt;CModelEntry&gt;::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-&gt;_OwnerMot= <font class="keyword">this</font>;
00172 
00173                 <font class="comment">// create observer for each trav.</font>
00174                 std::vector&lt;CTravEntry&gt;::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-&gt;Model= m;
00182                         obs-&gt;Trav= (*itTrav).Trav;
00183                         <font class="comment">// Attach it to Model.</font>
00184                         m-&gt;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-&gt;getRoot())
00187                                 (*itTrav).Trav-&gt;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-&gt;Observers.begin(); itObs!=m-&gt;Observers.end(); itObs++)
00193                 {
00194                         IObs    *o= (*itObs).second;
00195                         o-&gt;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-&gt;linkToValidateList();
00203 
00204                 <font class="comment">// Once the model is correclty created, finish init him.</font>
00205                 m-&gt;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&lt;IModel*&gt;::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-&gt;validate() may remove model from the list.</font>
00233                 next= model-&gt;_NextModelToValidate;
00234 
00235                 <font class="comment">// chek / validate the model.</font>
00236                 model-&gt;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 &amp;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-&gt;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-&gt;createDefaultObs();
00255         }
00256 
00257         CObsEntry       e;
00258         e.TravId= idTrav;
00259         e.ModelId= idModel;
00260         std::set&lt;CObsEntry&gt;::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&lt;CModelEntry&gt;::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> &amp;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-&gt;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-&gt;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>-&gt;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-&gt;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-&gt;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-&gt;addParent(o1);
00342         o1-&gt;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-&gt;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-&gt;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-&gt;delParent(o1);
00370         o1-&gt;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&lt;IModel     *&gt;      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&lt;IModel *&gt;::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&lt;IModel     *&gt;      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&lt;IModel *&gt;::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-&gt;getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>());
00406         <font class="keywordflow">return</font> o-&gt;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-&gt;getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>());
00412         IObs *child = o-&gt;getFirstChild();
00413         <font class="keywordflow">if</font> (child != NULL)
00414                 <font class="keywordflow">return</font> child-&gt;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-&gt;getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>());
00421         IObs *child = o-&gt;getNextChild();
00422         <font class="keywordflow">if</font> (child != NULL)
00423                 <font class="keywordflow">return</font> child-&gt;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-&gt;getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>());
00431         <font class="keywordflow">return</font> o-&gt;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-&gt;getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>());
00437         IObs *father = o-&gt;getFirstParent();
00438         <font class="keywordflow">if</font> (father != NULL)
00439                 <font class="keywordflow">return</font> father-&gt;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-&gt;getObs(<a class="code" href="classNL3D_1_1ITrav.html#z622_1">getClassId</a>());
00447         IObs *father = o-&gt;getNextParent();
00448         <font class="keywordflow">if</font> (father != NULL)
00449                 <font class="keywordflow">return</font> father-&gt;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 &amp;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-&gt;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>-&gt;_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>-&gt;_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>-&gt;_PrecModelToValidate= <font class="keyword">this</font>;
00543                 <a class="code" href="classNL3D_1_1IModel.html#n3">_OwnerMot</a>-&gt;_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>-&gt;_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>-&gt;_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>-&gt;_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>-&gt;_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-&gt;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-&gt;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 &amp;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>-&gt;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-&gt;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)-&gt;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-&gt;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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>