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
|
<!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> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><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="/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>
<!-- 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> </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:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>transport_class.cpp</h1><a href="transport__class_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2000-2002 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NeL Network Services.</font>
00010 <font class="comment"> * NEVRAX NeL Network Services 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 Network Services 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 Network Services; 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="comment">/*</font>
00027 <font class="comment"> * Limitations: Not threadsafe, not reentrant.</font>
00028 <font class="comment"> */</font>
00029
00030
00031 <font class="comment">//</font>
00032 <font class="comment">// Includes</font>
00033 <font class="comment">//</font>
00034
00035 <font class="preprocessor">#include "<a class="code" href="stdnet_8h.html">stdnet.h</a>"</font>
00036
00037 <font class="preprocessor">#include "<a class="code" href="types__nl_8h.html">nel/misc/types_nl.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
00039 <font class="preprocessor">#include "<a class="code" href="entity__id_8h.html">nel/misc/entity_id.h</a>"</font>
00040 <font class="preprocessor">#include "<a class="code" href="sheet__id_8h.html">nel/misc/sheet_id.h</a>"</font>
00041
00042 <font class="preprocessor">#include "<a class="code" href="unified__network_8h.html">nel/net/unified_network.h</a>"</font>
00043
00044 <font class="preprocessor">#include "<a class="code" href="transport__class_8h.html">nel/net/transport_class.h</a>"</font>
00045
00046 <font class="comment">//</font>
00047 <font class="comment">// Namespace</font>
00048 <font class="comment">//</font>
00049
00050 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00051 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00052 <font class="keyword">using</font> <font class="keyword">namespace </font>NLNET;
00053
00054 <font class="keyword">namespace </font>NLNET {
00055
00056 <font class="comment">//</font>
00057 <font class="comment">// Variables</font>
00058 <font class="comment">//</font>
00059
00060 uint CTransportClass::Mode = 0; <font class="comment">// 0=nothing 1=read 2=write 3=register</font>
00061
00062 map<string, CTransportClass::CRegisteredClass> CTransportClass::LocalRegisteredClass; <font class="comment">// registered class that are in my program</font>
00063
00064 CTransportClass::CRegisteredClass CTransportClass::TempRegisteredClass;
00065
00066 <a class="code" href="classNLNET_1_1CMessage.html">NLNET::CMessage</a> CTransportClass::TempMessage;
00067
00068 vector<CTransportClass::CRegisteredBaseProp *> CTransportClass::DummyProp;
00069
00070 <font class="keywordtype">bool</font> CTransportClass::Init = <font class="keyword">false</font>;
00071
00072
00073 <font class="comment">//</font>
00074 <font class="comment">// Functions</font>
00075 <font class="comment">//</font>
00076
00077 string <a class="code" href="namespaceNLNET.html#a136">typeToString</a> (CTransportClass::TProp <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>)
00078 {
00079 string conv[] = {
00080 <font class="stringliteral">"PropUInt8"</font>, <font class="stringliteral">"PropUInt16"</font>, <font class="stringliteral">"PropUInt32"</font>, <font class="stringliteral">"PropUInt64"</font>,
00081 <font class="stringliteral">"PropSInt8"</font>, <font class="stringliteral">"PropSInt16"</font>, <font class="stringliteral">"PropSInt32"</font>, <font class="stringliteral">"PropSInt64"</font>,
00082 <font class="stringliteral">"PropBool"</font>, <font class="stringliteral">"PropFloat"</font>, <font class="stringliteral">"PropDouble"</font>, <font class="stringliteral">"PropString"</font>, <font class="stringliteral">"PropEntityId"</font>, <font class="stringliteral">"PropSheetId"</font>, <font class="stringliteral">"PropUKN"</font> };
00083
00084 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> > CTransportClass::PropUKN)
00085 <font class="keywordflow">return</font> <font class="stringliteral">"<InvalidType>"</font>;
00086 <font class="keywordflow">return</font> conv[<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>];
00087 }
00088
00089 <font class="keywordtype">void</font> CTransportClass::displayDifferentClass (uint8 sid, <font class="keyword">const</font> string &className, <font class="keyword">const</font> vector<CRegisteredBaseProp> &otherClass, <font class="keyword">const</font> vector<CRegisteredBaseProp *> &myClass)
00090 {
00091 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Service with sid %u send me the TransportClass '%s' with differents properties:"</font>, sid, className.c_str());
00092 uint i;
00093 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">" My local TransportClass is:"</font>);
00094 <font class="keywordflow">for</font> (i = 0; i < myClass.size(); i++)
00095 {
00096 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">" Property: %d Name: '%s' type: '%s'"</font>, i, myClass[i]->Name.c_str(), <a class="code" href="namespaceNLNET.html#a136">typeToString</a>(myClass[i]->Type).c_str());
00097 }
00098
00099 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">" The other side TransportClass is:"</font>);
00100 <font class="keywordflow">for</font> (i = 0; i < otherClass.size(); i++)
00101 {
00102 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">" Property: %d Name: '%s' type: '%s'"</font>, i, otherClass[i].Name.c_str(), <a class="code" href="namespaceNLNET.html#a136">typeToString</a>(otherClass[i].Type).c_str());
00103 }
00104 }
00105
00106 <font class="keywordtype">void</font> CTransportClass::registerOtherSideClass (uint8 sid, TOtherSideRegisteredClass &osrc)
00107 {
00108 <font class="keywordflow">for</font> (TOtherSideRegisteredClass::iterator it = osrc.begin(); it != osrc.end (); it++)
00109 {
00110 <font class="comment">// find the class name in the map</font>
00111
00112 TRegisteredClass::iterator <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a> = LocalRegisteredClass.find ((*it).first);
00113 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a> == LocalRegisteredClass.end ())
00114 {
00115 <font class="comment">// it s a class that the other side have but not me, can't send this class</font>
00116 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CTransportClass::registerOtherSideClass(): the other side class '%s' is not registered in my system, skip it"</font>, (*it).first.c_str());
00117 <font class="keywordflow">continue</font>;
00118 }
00119
00120 <font class="keywordflow">if</font> (sid >= (*res).second.Instance->States.size ())
00121 (*res).second.Instance->States.resize (sid+1);
00122
00123 (*res).second.Instance->States[sid].clear ();
00124
00125 <font class="keywordflow">for</font> (sint j = 0; j < (sint)(*it).second.size (); j++)
00126 {
00127 <font class="comment">// check each prop to see the correspondance</font>
00128
00129 <font class="comment">// try to find the prop name in the array</font>
00130 uint k;
00131 <font class="keywordflow">for</font> (k = 0; k < (*res).second.Instance->Prop.size(); k++)
00132 {
00133 <font class="keywordflow">if</font> ((*it).second[j].Name == (*res).second.Instance->Prop[k]->Name)
00134 {
00135 <font class="keywordflow">if</font> ((*it).second[j].Type != (*res).second.Instance->Prop[k]->Type)
00136 {
00137 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Property '%s' of the class '%s' have not the same type in the 2 sides (%s %s)"</font>, (*it).second[j].Name.c_str(), (*it).first.c_str(), <a class="code" href="namespaceNLNET.html#a136">typeToString</a>((*it).second[j].Type).c_str(), <a class="code" href="namespaceNLNET.html#a136">typeToString</a>((*res).second.Instance->Prop[k]->Type).c_str());
00138 }
00139 <font class="keywordflow">break</font>;
00140 }
00141 }
00142 <font class="keywordflow">if</font> (k == (*res).second.Instance->Prop.size())
00143 {
00144 <font class="comment">// not found, put -1</font>
00145 (*res).second.Instance->States[sid].push_back (make_pair (-1, (*it).second[j].Type));
00146 }
00147 <font class="keywordflow">else</font>
00148 {
00149 <font class="comment">// same, store the index</font>
00150 (*res).second.Instance->States[sid].push_back (make_pair (k, PropUKN));
00151 }
00152 }
00153
00154 <font class="comment">// check if the version are the same</font>
00155 <font class="keywordflow">if</font> ((*it).second.size () != (*res).second.Instance->Prop.size ())
00156 {
00157 <font class="comment">// 2 class don't have the same number of prop => different class => display class</font>
00158 displayDifferentClass (sid, (*it).first.c_str(), (*it).second, (*res).second.Instance->Prop);
00159 }
00160 <font class="keywordflow">else</font>
00161 {
00162 <font class="comment">// check if the prop are same</font>
00163 <font class="keywordflow">for</font> (uint i = 0; i < (*res).second.Instance->Prop.size (); i++)
00164 {
00165 <font class="keywordflow">if</font> ((*res).second.Instance->Prop[i]->Name != (*it).second[i].Name)
00166 {
00167 <font class="comment">// different name => different class => display class</font>
00168 displayDifferentClass (sid, (*it).first.c_str(), (*it).second, (*res).second.Instance->Prop);
00169 <font class="keywordflow">break</font>;
00170 }
00171 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*res).second.Instance->Prop[i]->Type != (*it).second[i].Type)
00172 {
00173 <font class="comment">// different type => different class => display class</font>
00174 displayDifferentClass (sid, (*it).first.c_str(), (*it).second, (*res).second.Instance->Prop);
00175 <font class="keywordflow">break</font>;
00176 }
00177 }
00178 }
00179 }
00180
00181 displayLocalRegisteredClass ();
00182 }
00183
00184
<a name="l00185"></a><a class="code" href="classNLNET_1_1CTransportClass.html#d2">00185</a> <font class="keywordtype">void</font> CTransportClass::registerClass (CTransportClass &instance)
00186 {
00187 <a class="code" href="debug_8h.html#a6">nlassert</a> (Init);
00188 <a class="code" href="debug_8h.html#a6">nlassert</a> (Mode == 0);
00189
00190 <font class="comment">// set the mode to register</font>
00191 Mode = 3;
00192
00193 <font class="comment">// clear the current class</font>
00194 TempRegisteredClass.clear ();
00195
00196 <font class="comment">// set the instance pointer</font>
00197 TempRegisteredClass.Instance = &instance;
00198
00199 <font class="comment">// fill name and props</font>
00200 TempRegisteredClass.Instance->description ();
00201
00202 <font class="comment">// add the new registered class in the array</font>
00203 LocalRegisteredClass[TempRegisteredClass.Instance->Name] = TempRegisteredClass;
00204
00205 <font class="comment">// set to mode none</font>
00206 Mode = 0;
00207 }
00208
00209 <font class="keywordtype">void</font> CTransportClass::unregisterClass ()
00210 {
00211 <font class="keywordflow">for</font> (TRegisteredClass::iterator it = LocalRegisteredClass.begin(); it != LocalRegisteredClass.end (); it++)
00212 {
00213 <font class="keywordflow">for</font> (uint j = 0; j < (*it).second.Instance->Prop.size (); j++)
00214 {
00215 <font class="keyword">delete</font> (*it).second.Instance->Prop[j];
00216 }
00217 (*it).second.Instance->Prop.clear ();
00218 (*it).second.Instance = NULL;
00219 }
00220 LocalRegisteredClass.clear ();
00221 }
00222
00223 <font class="keywordtype">void</font> CTransportClass::displayLocalRegisteredClass (CRegisteredClass &c)
00224 {
00225 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: > %s"</font>, c.Instance->Name.c_str());
00226 <font class="keywordflow">for</font> (uint j = 0; j < c.Instance->Prop.size (); j++)
00227 {
00228 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: > %s %s"</font>, c.Instance->Prop[j]->Name.c_str(), <a class="code" href="namespaceNLNET.html#a136">typeToString</a>(c.Instance->Prop[j]->Type).c_str());
00229 }
00230
00231 <font class="keywordflow">for</font> (uint <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < c.Instance->States.size (); <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>++)
00232 {
00233 <font class="keywordflow">if</font> (c.Instance->States[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>].size () != 0)
00234 {
00235 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: > sid: %u"</font>, <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>);
00236 <font class="keywordflow">for</font> (uint k = 0; k < c.Instance->States[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>].size (); k++)
00237 {
00238 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: - %d type : %s"</font>, c.Instance->States[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>][k].first, <a class="code" href="namespaceNLNET.html#a136">typeToString</a>(c.Instance->States[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>][k].second).c_str());
00239 }
00240 }
00241 }
00242 }
00243
<a name="l00244"></a><a class="code" href="classNLNET_1_1CTransportClass.html#d3">00244</a> <font class="keywordtype">void</font> CTransportClass::displayLocalRegisteredClass ()
00245 {
00246 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC:> LocalRegisteredClass:"</font>);
00247 <font class="keywordflow">for</font> (TRegisteredClass::iterator it = LocalRegisteredClass.begin(); it != LocalRegisteredClass.end (); it++)
00248 {
00249 <a class="code" href="classNLNET_1_1CTransportClass.html#d3">displayLocalRegisteredClass</a> ((*it).second);
00250 }
00251 }
00252
00253 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a137">cbTCReceiveMessage</a> (CMessage &msgin, <font class="keyword">const</font> string &name, uint16 sid)
00254 {
00255 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: cbReceiveMessage"</font>);
00256
00257 CTransportClass::TempMessage = msgin;
00258
00259 string className;
00260 CTransportClass::TempMessage.<a class="code" href="classNLMISC_1_1CMemStream.html#a22">serial</a> (className);
00261
00262 CTransportClass::TRegisteredClass::iterator it = CTransportClass::LocalRegisteredClass.find (className);
00263 <font class="keywordflow">if</font> (it == CTransportClass::LocalRegisteredClass.end ())
00264 {
00265 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"receive unknown class '%s', skip it"</font>, className.c_str());
00266 <font class="keywordflow">return</font>;
00267 }
00268
00269 <a class="code" href="debug_8h.html#a6">nlassert</a> ((*it).second.Instance != NULL);
00270 (*it).second.Instance->read (name, (uint8)sid);
00271 }
00272
00273 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a138">cbTCReceiveOtherSideClass</a> (CMessage &msgin, <font class="keyword">const</font> string &name, uint16 sid)
00274 {
00275 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: cbReceiveOtherSideClass"</font>);
00276
00277 CTransportClass::TOtherSideRegisteredClass osrc;
00278
00279 uint32 nbClass;
00280 msgin.serial (nbClass);
00281
00282 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: %d class"</font>, nbClass);
00283
00284 <font class="keywordflow">for</font> (uint i = 0; i < nbClass; i++)
00285 {
00286 string className;
00287 msgin.serial (className);
00288
00289 osrc.push_back(make_pair (className, vector<CTransportClass::CRegisteredBaseProp>()));
00290
00291 uint32 nbProp;
00292 msgin.serial (nbProp);
00293
00294 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: %s (%d prop)"</font>, className.c_str(), nbProp);
00295
00296 <font class="keywordflow">for</font> (uint j = 0; j < nbProp; j++)
00297 {
00298 CTransportClass::CRegisteredBaseProp prop;
00299 msgin.serial (prop.Name);
00300 msgin.serialEnum (prop.Type);
00301 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: %s %s"</font>, prop.Name.c_str(), <a class="code" href="namespaceNLNET.html#a136">typeToString</a>(prop.Type).c_str());
00302 osrc[osrc.size()-1].second.push_back (prop);
00303 }
00304 }
00305
00306 <font class="comment">// we have the good structure</font>
00307 CTransportClass::registerOtherSideClass ((uint8)sid, osrc);
00308 }
00309
00310 <font class="keyword">static</font> TUnifiedCallbackItem <a class="code" href="namespaceNLNET.html#a64">CallbackArray</a>[] =
00311 {
00312 { <font class="stringliteral">"CT_LRC"</font>, <a class="code" href="namespaceNLNET.html#a138">cbTCReceiveOtherSideClass</a> },
00313 { <font class="stringliteral">"CT_MSG"</font>, <a class="code" href="namespaceNLNET.html#a137">cbTCReceiveMessage</a> },
00314 };
00315
00316 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a139">cbTCUpService</a> (<font class="keyword">const</font> std::string &serviceName, uint16 sid, <font class="keywordtype">void</font> *arg)
00317 {
00318 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: CTransportClass Service %s %d is up"</font>, serviceName.c_str(), sid);
00319 <font class="keywordflow">if</font> (sid >= 256)
00320 <font class="keywordflow">return</font>;
00321 CTransportClass::sendLocalRegisteredClass ((uint8)sid);
00322 }
00323
<a name="l00324"></a><a class="code" href="classNLNET_1_1CTransportClass.html#d0">00324</a> <font class="keywordtype">void</font> CTransportClass::init ()
00325 {
00326 <font class="comment">// this isn't an error!</font>
00327 <font class="keywordflow">if</font> (Init) <font class="keywordflow">return</font>;
00328
00329 <font class="comment">// filter all my debug stuffs</font>
00330 <a class="code" href="namespaceNLMISC.html#a11">DebugLog</a>->addNegativeFilter (<font class="stringliteral">"NETTC"</font>);
00331
00332
00333 CUnifiedNetwork::getInstance()->addCallbackArray (<a class="code" href="namespaceNLNET.html#a64">CallbackArray</a>, <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a64">CallbackArray</a>) / <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a64">CallbackArray</a>[0]));
00334
00335 <font class="comment">// create an instance of all d'ifferent prop types</font>
00336
00337 DummyProp.resize (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>);
00338
00339 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s0">PropUInt8</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s0">PropUInt8</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<uint8>;
00340 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s1">PropUInt16</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s1">PropUInt16</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<uint16>;
00341 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s2">PropUInt32</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s2">PropUInt32</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<uint32>;
00342 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s3">PropUInt64</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s3">PropUInt64</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<uint64>;
00343 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s4">PropSInt8</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s4">PropSInt8</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<sint8>;
00344 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s5">PropSInt16</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s5">PropSInt16</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<sint16>;
00345 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s6">PropSInt32</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s6">PropSInt32</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<sint32>;
00346 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s7">PropSInt64</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s7">PropSInt64</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<sint64>;
00347 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s8">PropBool</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s8">PropBool</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<bool>;
00348 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s9">PropFloat</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s9">PropFloat</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<float>;
00349 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s10">PropDouble</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s10">PropDouble</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<double>;
00350 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s11">PropString</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s11">PropString</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<string>;
00351 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s12">PropEntityId</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s12">PropEntityId</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<CEntityId>;
00352 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CTransportClass.html#s15s13">PropSheetId</a> < <a class="code" href="classNLNET_1_1CTransportClass.html#s15s14">PropUKN</a>); DummyProp[<a class="code" href="classNLNET_1_1CTransportClass.html#s15s13">PropSheetId</a>] = <font class="keyword">new</font> CTransportClass::CRegisteredProp<CSheetId>;
00353
00354 <font class="comment">// we have to know when a service comes, so add callback (put the callback before all other one because we have to send this message first)</font>
00355 CUnifiedNetwork::getInstance()->setServiceUpCallback(<font class="stringliteral">"*"</font>, <a class="code" href="namespaceNLNET.html#a139">cbTCUpService</a>, NULL, <font class="keyword">false</font>);
00356
00357 Init = <font class="keyword">true</font>;
00358 }
00359
<a name="l00360"></a><a class="code" href="classNLNET_1_1CTransportClass.html#d1">00360</a> <font class="keywordtype">void</font> CTransportClass::release ()
00361 {
00362 unregisterClass ();
00363
00364 <font class="keywordflow">for</font> (uint i = 0; i < DummyProp.size (); i++)
00365 {
00366 <font class="keyword">delete</font> DummyProp[i];
00367 }
00368 DummyProp.clear ();
00369 }
00370
00371 <font class="keywordtype">void</font> CTransportClass::createLocalRegisteredClassMessage ()
00372 {
00373 TempMessage.clear ();
00374 <font class="keywordflow">if</font> (TempMessage.isReading())
00375 TempMessage.invert();
00376 TempMessage.setType (<font class="stringliteral">"CT_LRC"</font>);
00377
00378 uint32 nbClass = LocalRegisteredClass.size ();
00379 TempMessage.serial (nbClass);
00380
00381 <font class="keywordflow">for</font> (TRegisteredClass::iterator it = LocalRegisteredClass.begin(); it != LocalRegisteredClass.end (); it++)
00382 {
00383 <a class="code" href="debug_8h.html#a6">nlassert</a> ((*it).first == (*it).second.Instance->Name);
00384
00385 TempMessage.serial ((*it).second.Instance->Name);
00386
00387 uint32 nbProp = (*it).second.Instance->Prop.size ();
00388 TempMessage.serial (nbProp);
00389
00390 <font class="keywordflow">for</font> (uint j = 0; j < (*it).second.Instance->Prop.size (); j++)
00391 {
00392 <font class="comment">// send the name and the type of the prop</font>
00393 TempMessage.serial ((*it).second.Instance->Prop[j]->Name);
00394 TempMessage.serialEnum ((*it).second.Instance->Prop[j]->Type);
00395 }
00396 }
00397 }
00398
00399 } <font class="comment">// NLNET</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|