aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/transport__class_8h-source.html
blob: 784c3564e1ecc796eb3f9fb00c6b2502ea6c8f1d (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
<!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=http://www.nevrax.com><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>transport_class.h</h1><a href="transport__class_8h.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="preprocessor">#ifndef NL_TRANSPORT_CLASS_H</font>
00027 <font class="preprocessor"></font><font class="preprocessor">#define NL_TRANSPORT_CLASS_H</font>
00028 <font class="preprocessor"></font>
00029 
00030 <font class="comment">//</font>
00031 <font class="comment">// Includes</font>
00032 <font class="comment">//</font>
00033 
00034 <font class="preprocessor">#include "<a class="code" href="types__nl_8h.html">nel/misc/types_nl.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="entity__id_8h.html">nel/misc/entity_id.h</a>"</font>
00037 
00038 <font class="preprocessor">#include "<a class="code" href="unified__network_8h.html">nel/net/unified_network.h</a>"</font>
00039 <font class="preprocessor">#include "<a class="code" href="message_8h.html">nel/net/message.h</a>"</font>
00040 
00041 <font class="preprocessor">#include &lt;vector&gt;</font>
00042 <font class="preprocessor">#include &lt;string&gt;</font>
00043 
00044 
00045 <font class="comment">//</font>
00046 <font class="comment">// Macros</font>
00047 <font class="comment">//</font>
00048 
<a name="l00053"></a><a class="code" href="transport__class_8h.html#a0">00053</a> <font class="preprocessor">#define TRANSPORT_CLASS_REGISTER(_c) \</font>
00054 <font class="preprocessor">        static _c _c##Instance; \</font>
00055 <font class="preprocessor">        CTransportClass::registerClass (_c##Instance);</font>
00056 <font class="preprocessor"></font>
00057 
00058 <font class="comment">//</font>
00059 <font class="comment">// Classes</font>
00060 <font class="comment">//</font>
00061 
<a name="l00069"></a><a class="code" href="classCTransportClass.html">00069</a> <font class="keyword">class </font><a class="code" href="classCTransportClass.html">CTransportClass</a>
00070 {
00071 <font class="keyword">public</font>:
00072 
<a name="l00077"></a><a class="code" href="classCTransportClass.html#s14">00077</a>         <font class="keyword">enum</font> <a class="code" href="classCTransportClass.html#s14">TProp</a> {
00078                 <a class="code" href="classCTransportClass.html#s14s0">PropUInt8</a>, <a class="code" href="classCTransportClass.html#s14s1">PropUInt16</a>, <a class="code" href="classCTransportClass.html#s14s2">PropUInt32</a>, <a class="code" href="classCTransportClass.html#s14s3">PropUInt64</a>,
00079                 <a class="code" href="classCTransportClass.html#s14s4">PropSInt8</a>, <a class="code" href="classCTransportClass.html#s14s5">PropSInt16</a>, <a class="code" href="classCTransportClass.html#s14s6">PropSInt32</a>, <a class="code" href="classCTransportClass.html#s14s7">PropSInt64</a>,
00080                 <a class="code" href="classCTransportClass.html#s14s8">PropBool</a>, <a class="code" href="classCTransportClass.html#s14s9">PropFloat</a>, <a class="code" href="classCTransportClass.html#s14s10">PropDouble</a>, <a class="code" href="classCTransportClass.html#s14s11">PropString</a>, <a class="code" href="classCTransportClass.html#s14s12">PropEntityId</a>, <a class="code" href="classCTransportClass.html#s14s13">PropUKN</a> };
00081 
00082 
00083         <font class="comment">//</font>
00084         <font class="comment">// Static methods</font>
00085         <font class="comment">//</font>
00086 
00088         <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classCTransportClass.html#d0">init</a> ();
00089 
00091         <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classCTransportClass.html#d1">release</a> ();
00092 
00096         <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classCTransportClass.html#d2">registerClass</a> (<a class="code" href="classCTransportClass.html">CTransportClass</a> &amp;instance);
00097 
00099         <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classCTransportClass.html#d3">displayLocalRegisteredClass</a> ();
00100 
00101 
00102         <font class="comment">//</font>
00103         <font class="comment">// Virtual methods</font>
00104         <font class="comment">//</font>
00105 
00118         <font class="keyword">virtual</font> <font class="keywordtype">void</font> description () = 0;
00119 
00123         <font class="keyword">virtual</font> <font class="keywordtype">void</font> callback (<font class="keyword">const</font> std::string &amp;name, <a class="code" href="types__nl_8h.html#a5">uint8</a> sid) { };
00124 
00125 
00126         <font class="comment">//</font>
00127         <font class="comment">// Other methods</font>
00128         <font class="comment">//</font>
00129 
00131         <font class="keywordtype">void</font> send (<a class="code" href="types__nl_8h.html#a5">uint8</a> sid);
00132 
00134         <font class="keywordtype">void</font> send (std::string serviceName);
00135 
00138         <font class="keywordtype">void</font> className (<font class="keyword">const</font> std::string &amp;name);
00139 
00146         <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; <font class="keywordtype">void</font> property (<font class="keyword">const</font> std::string &amp;name, <a class="code" href="classCTransportClass.html#s14">TProp</a> <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, T defaultValue, T &amp;value)
00147         {
00148                 <font class="keywordflow">switch</font> (type)
00149                 {
00150                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s0">PropUInt8</a>: <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s4">PropSInt8</a>: <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s8">PropBool</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (<a class="code" href="types__nl_8h.html#a5">uint8</a>)); <font class="keywordflow">break</font>;
00151                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s1">PropUInt16</a>: <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s5">PropSInt16</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (<a class="code" href="types__nl_8h.html#a7">uint16</a>)); <font class="keywordflow">break</font>;
00152                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s2">PropUInt32</a>: <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s6">PropSInt32</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (<a class="code" href="types__nl_8h.html#a9">uint32</a>)); <font class="keywordflow">break</font>;
00153                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s3">PropUInt64</a>: <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s7">PropSInt64</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (<a class="code" href="types__nl_8h.html#a11">uint64</a>)); <font class="keywordflow">break</font>;
00154                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s9">PropFloat</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (<font class="keywordtype">float</font>)); <font class="keywordflow">break</font>;
00155                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s10">PropDouble</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (<font class="keywordtype">double</font>)); <font class="keywordflow">break</font>;
00156                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s11">PropString</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (std::string)); <font class="keywordflow">break</font>;
00157                 <font class="keywordflow">case</font> <a class="code" href="classCTransportClass.html#s14s12">PropEntityId</a>: <a class="code" href="debug_8h.html#a6">nlassert</a>(<font class="keyword">sizeof</font>(T) == <font class="keyword">sizeof</font> (<a class="code" href="structNLMISC_1_1CEntityId.html">NLMISC::CEntityId</a>)); <font class="keywordflow">break</font>;
00158                 <font class="keywordflow">default</font>: <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"property %s have unknown type %d"</font>, name.c_str(), <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>);
00159                 }
00160 
00161                 <font class="keywordflow">if</font> (Mode == 2)                  <font class="comment">// write</font>
00162                 {
00163                         <font class="comment">// send only if needed</font>
00164                         <font class="comment">// todo manage unknown prop</font>
00165                         TempMessage.serial (value);
00166                 }
00167                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (Mode == 3)     <font class="comment">// register</font>
00168                 {
00169                         <font class="comment">// add a new prop to the current class</font>
00170                         <a class="code" href="debug_8h.html#a6">nlassert</a> (TempRegisteredClass.Instance != NULL);
00171                         TempRegisteredClass.Instance-&gt;Prop.push_back (<font class="keyword">new</font> CRegisteredProp&lt;T&gt; (name, <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, defaultValue, &amp;value));
00172                 }
00173                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (Mode == 4)     <font class="comment">// display</font>
00174                 {
00175                         std::string val;
00176                         val = <font class="stringliteral">"defval: "</font>;
00177                         val += <a class="code" href="namespaceNLMISC.html#a213">NLMISC::toString</a> (defaultValue);
00178                         val += <font class="stringliteral">" val: "</font>;
00179                         val += <a class="code" href="namespaceNLMISC.html#a213">NLMISC::toString</a> (value);
00180                         <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC:   prop %s %d: %s"</font>, name.c_str(), <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, val.c_str());
00181                 }
00182                 <font class="keywordflow">else</font>
00183                 {
00184                         <a class="code" href="debug_8h.html#a12">nlstop</a>;
00185                 }
00186         }
00187         
00188         <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; <font class="keywordtype">void</font> propertyCont (<font class="keyword">const</font> std::string &amp;name, <a class="code" href="classCTransportClass.html#s14">TProp</a> <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, T &amp;value)
00189         {
00190                 <font class="keywordflow">if</font> (Mode == 2)                  <font class="comment">// write</font>
00191                 {
00192                         <font class="comment">// send only if needed</font>
00193                         <font class="comment">// todo manage unknown prop</font>
00194                         TempMessage.serialCont (value);
00195                 }
00196                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (Mode == 3)     <font class="comment">// register</font>
00197                 {
00198                         <font class="comment">// add a new prop to the current class</font>
00199                         <a class="code" href="debug_8h.html#a6">nlassert</a> (TempRegisteredClass.Instance != NULL);
00200                         TempRegisteredClass.Instance-&gt;Prop.push_back (<font class="keyword">new</font> CRegisteredPropCont&lt;T&gt; (name, <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, &amp;value));
00201                 }
00202                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (Mode == 4)     <font class="comment">// display</font>
00203                 {
00204                         <font class="keyword">typedef</font> <font class="keyword">typename</font> T::iterator __iterator;
00205                         std::string val;
00206                         <font class="keywordflow">for</font> (__iterator it = value.begin (); it != value.end(); it++)
00207                         {
00208                                 val += <a class="code" href="namespaceNLMISC.html#a213">NLMISC::toString</a> (*it);
00209                                 val += <font class="stringliteral">" "</font>;
00210                         }
00211                         <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC:   prop %s %d: %d elements ( %s)"</font>, name.c_str(), <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, value.size(), val.c_str());
00212                 }
00213                 <font class="keywordflow">else</font>
00214                 {
00215                         <a class="code" href="debug_8h.html#a12">nlstop</a>;
00216                 }
00217         }
00218 
00219         
00221         <font class="keywordtype">void</font> display ();
00222 
00223 <font class="keyword">private</font>:
00224 
00225         <font class="comment">//</font>
00226         <font class="comment">// Structures</font>
00227         <font class="comment">//</font>
00228 
00229         <font class="keyword">struct </font>CRegisteredBaseProp
00230         {
00231                 CRegisteredBaseProp () : Type(PropUKN) { }
00232 
00233                 CRegisteredBaseProp (<font class="keyword">const</font> std::string &amp;name, TProp <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>) : Name(name), Type(<a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>) { }
00234                 
00235                 std::string     Name;
00236                 TProp Type;
00237 
00238                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> serialDefaultValue (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) { }
00239 
00240                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> serialValue (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) { }
00241 
00242                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> setDefaultValue () { }
00243         };
00244 
00245         <font class="keyword">typedef</font> std::vector&lt;std::pair&lt;std::string, std::vector &lt;CRegisteredBaseProp&gt; &gt; &gt; TOtherSideRegisteredClass;
00246 
00247         <font class="keyword">struct </font>CRegisteredClass
00248         {
00249                 <a class="code" href="classCTransportClass.html">CTransportClass</a> *Instance;
00250 
00251                 CRegisteredClass () { clear (); }
00252 
00253                 <font class="keywordtype">void</font> clear () { Instance = NULL; }
00254         };
00255 
00256         <font class="keyword">typedef</font> std::map&lt;std::string, CRegisteredClass&gt; TRegisteredClass;
00257 
00258         <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; <font class="keyword">struct </font>CRegisteredProp : <font class="keyword">public</font> CRegisteredBaseProp
00259         {
00260                 CRegisteredProp () : Value(NULL) { }
00261 
00262                 CRegisteredProp (<font class="keyword">const</font> std::string &amp;name, TProp <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, T defaultValue, T *value = NULL) :
00263                         CRegisteredBaseProp (name, <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>), DefaultValue(defaultValue), Value (value) { }
00264                 
00265                 T DefaultValue, *Value;
00266 
00267                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> serialDefaultValue (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
00268                 {
00269                         f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a> (DefaultValue);
00270                 }
00271 
00272                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> serialValue (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
00273                 {
00274                         <a class="code" href="debug_8h.html#a6">nlassert</a> (Value != NULL);
00275                         f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a> (*Value);
00276                 }
00277 
00278                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> setDefaultValue ()
00279                 {
00280                         <a class="code" href="debug_8h.html#a6">nlassert</a> (Value != NULL);
00281                         *Value = DefaultValue;
00282                 }
00283         };
00284 
00285         <font class="keyword">template</font> &lt;<font class="keyword">class</font> T&gt; <font class="keyword">struct </font>CRegisteredPropCont : <font class="keyword">public</font> CRegisteredBaseProp
00286         {
00287                 CRegisteredPropCont () : Value(NULL) { }
00288 
00289                 CRegisteredPropCont (<font class="keyword">const</font> std::string &amp;name, TProp <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>, T *value = NULL) :
00290                         CRegisteredBaseProp (name, <a class="code" href="driver__opengl__extension__def_8h.html#a240">type</a>), Value (value) { }
00291                 
00292                 T *Value;
00293 
00294                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> serialDefaultValue (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
00295                 {
00296                         <font class="comment">// nothing</font>
00297                 }
00298 
00299                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> serialValue (<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f)
00300                 {
00301                         <a class="code" href="debug_8h.html#a6">nlassert</a> (Value != NULL);
00302                         f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a> (*Value);
00303                 }
00304 
00305                 <font class="keyword">virtual</font> <font class="keywordtype">void</font> setDefaultValue ()
00306                 {
00307                         <a class="code" href="debug_8h.html#a6">nlassert</a> (Value != NULL);
00308                         Value-&gt;clear ();
00309                 }
00310         };
00311 
00312 
00313         <font class="comment">//</font>
00314         <font class="comment">// Variables</font>
00315         <font class="comment">//</font>
00316 
00317         <font class="comment">// Name of the class</font>
00318         std::string     Name;
00319 
00320         <font class="comment">// States to decode the stream from the network</font>
00321         std::vector&lt;std::vector&lt;std::pair&lt;sint, TProp&gt; &gt; &gt; States;
00322 
00323         <font class="comment">// Contains all propterties for this class</font>
00324         std::vector&lt;CRegisteredBaseProp *&gt; Prop;
00325 
00326 
00327         <font class="comment">//</font>
00328         <font class="comment">// Methods</font>
00329         <font class="comment">//</font>
00330         
00331         <font class="comment">// Read the TempMessage and call the callback</font>
00332         <font class="keywordtype">void</font> read (<font class="keyword">const</font> std::string &amp;name, <a class="code" href="types__nl_8h.html#a5">uint8</a> sid);
00333 
00334         <font class="comment">// Used to create a TempMessage with this class</font>
00335         <a class="code" href="classNLNET_1_1CMessage.html">NLNET::CMessage</a> &amp;write ();
00336         
00337 
00338         <font class="comment">//</font>
00339         <font class="comment">// Static Variables</font>
00340         <font class="comment">//</font>
00341 
00342         <font class="comment">// Used to serialize unused properties from the TempMessage</font>
00343         <font class="keyword">static</font> std::vector&lt;CRegisteredBaseProp *&gt;       DummyProp;
00344 
00345         <font class="comment">// Select what the description() must do</font>
00346         <font class="keyword">static</font> <a class="code" href="types__nl_8h.html#a13">uint</a>                                                                     Mode;   <font class="comment">// 0=nothing 1=read 2=write 3=register 4=display</font>
00347 
00348         <font class="comment">// Contains all registered transport class</font>
00349         <font class="keyword">static</font> TRegisteredClass                                         LocalRegisteredClass;   <font class="comment">// registered class that are in my program</font>
00350 
00351         <font class="comment">// The registered class that is currently filled (before put in LocalRegisteredClass)</font>
00352         <font class="keyword">static</font> CRegisteredClass                                         TempRegisteredClass;
00353 
00354         <font class="comment">// The message that is currently filled/emptyed</font>
00355         <font class="keyword">static</font> <a class="code" href="classNLNET_1_1CMessage.html">NLNET::CMessage</a>                                          TempMessage;
00356 
00357         <font class="keyword">static</font> <font class="keywordtype">bool</font>                                                                     Init;
00358 
00359         <font class="comment">//</font>
00360         <font class="comment">// Static methods</font>
00361         <font class="comment">//</font>
00362 
00363         <font class="comment">// Called by release() to delete all structures</font>
00364         <font class="keyword">static</font> <font class="keywordtype">void</font> unregisterClass ();
00365 
00366         <font class="comment">// Fill the States merging local and other side class</font>
00367         <font class="keyword">static</font> <font class="keywordtype">void</font> registerOtherSideClass (<a class="code" href="types__nl_8h.html#a5">uint8</a> sid, TOtherSideRegisteredClass &amp;osrc);
00368 
00369         <font class="comment">// Create a message with local transport classes to send to the other side</font>
00370         <font class="keyword">static</font> <font class="keywordtype">void</font> createLocalRegisteredClassMessage ();
00371 
00372         <font class="comment">// Send the local transport classes to another service using the service id</font>
00373         <font class="keyword">static</font> <font class="keywordtype">void</font> sendLocalRegisteredClass (<a class="code" href="types__nl_8h.html#a5">uint8</a> sid)
00374         {
00375                 <a class="code" href="debug_8h.html#a6">nlassert</a> (Init);
00376                 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: sendLocalRegisteredClass to %d"</font>, sid);
00377                 createLocalRegisteredClassMessage ();
00378                 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#d0">NLNET::CUnifiedNetwork::getInstance</a>()-&gt;send (sid, TempMessage);
00379         }
00380 
00381         <font class="comment">// Display a specific registered class (debug purpose)</font>
00382         <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="classCTransportClass.html#d3">displayLocalRegisteredClass</a> (CRegisteredClass &amp;c);
00383         <font class="keyword">static</font> <font class="keywordtype">void</font> displayDifferentClass (<a class="code" href="types__nl_8h.html#a5">uint8</a> sid, <font class="keyword">const</font> std::string &amp;className, <font class="keyword">const</font> std::vector&lt;CRegisteredBaseProp&gt; &amp;otherClass, <font class="keyword">const</font> std::vector&lt;CRegisteredBaseProp *&gt; &amp;myClass);
00384 
00385 
00386         <font class="comment">//</font>
00387         <font class="comment">// Friends</font>
00388         <font class="comment">//</font>
00389 
00390         <font class="keyword">friend</font> <font class="keywordtype">void</font> <a class="code" href="transport__class_8cpp.html#a2">cbTCReceiveMessage</a> (<a class="code" href="classNLNET_1_1CMessage.html">NLNET::CMessage</a> &amp;msgin, <font class="keyword">const</font> std::string &amp;name, <a class="code" href="types__nl_8h.html#a7">uint16</a> sid);
00391         <font class="keyword">friend</font> <font class="keywordtype">void</font> <a class="code" href="transport__class_8cpp.html#a4">cbTCUpService</a> (<font class="keyword">const</font> std::string &amp;serviceName, <a class="code" href="types__nl_8h.html#a7">uint16</a> sid, <font class="keywordtype">void</font> *arg);
00392         <font class="keyword">friend</font> <font class="keywordtype">void</font> <a class="code" href="transport__class_8cpp.html#a3">cbTCReceiveOtherSideClass</a> (<a class="code" href="classNLNET_1_1CMessage.html">NLNET::CMessage</a> &amp;msgin, <font class="keyword">const</font> std::string &amp;name, <a class="code" href="types__nl_8h.html#a7">uint16</a> sid);
00393 };
00394 
00395 
00396 <font class="comment">//</font>
00397 <font class="comment">// Inlines</font>
00398 <font class="comment">//</font>
00399 
00400 <font class="keyword">inline</font> <font class="keywordtype">void</font> CTransportClass::className (<font class="keyword">const</font> std::string &amp;name)
00401 {
00402         <font class="keywordflow">if</font> (Mode == 2)          <font class="comment">// write</font>
00403         {
00404                 TempMessage.serial (const_cast&lt;std::string &amp;&gt; (name));
00405         }
00406         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (Mode == 3) <font class="comment">// register</font>
00407         {
00408                 <font class="comment">// add a new entry in my registered class</font>
00409                 <a class="code" href="debug_8h.html#a6">nlassert</a> (TempRegisteredClass.Instance != NULL);
00410                 TempRegisteredClass.Instance-&gt;Name = name;
00411         }
00412         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (Mode == 4) <font class="comment">// display</font>
00413         {
00414                 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"NETTC: class %s:"</font>, name.c_str());
00415         }
00416         <font class="keywordflow">else</font>
00417         {
00418                 <a class="code" href="debug_8h.html#a12">nlstop</a>;
00419         }
00420 }
00421 
00422 
00423 <font class="keyword">inline</font> <font class="keywordtype">void</font> CTransportClass::send (<a class="code" href="types__nl_8h.html#a5">uint8</a> sid)
00424 {
00425         <a class="code" href="debug_8h.html#a6">nlassert</a> (Init);
00426         <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#d0">NLNET::CUnifiedNetwork::getInstance</a>()-&gt;send (sid, write ());
00427 }
00428 
00429 
00430 <font class="keyword">inline</font> <font class="keywordtype">void</font> CTransportClass::send (std::string serviceName)
00431 {
00432         <a class="code" href="debug_8h.html#a6">nlassert</a> (Init);
00433         <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#d0">NLNET::CUnifiedNetwork::getInstance</a>()-&gt;send (serviceName, write ());
00434 }
00435 
00436 <font class="keyword">inline</font> <font class="keywordtype">void</font> CTransportClass::display ()
00437 {
00438         <a class="code" href="debug_8h.html#a6">nlassert</a> (Mode == 0);
00439 
00440         <font class="comment">// set the mode to register</font>
00441         Mode = 4;
00442         
00443         description ();
00444 
00445         <font class="comment">// set to mode none</font>
00446         Mode = 0;
00447 }
00448 
00449 <font class="keyword">inline</font> <a class="code" href="classNLNET_1_1CMessage.html">NLNET::CMessage</a> &amp;CTransportClass::write ()
00450 {
00451         <a class="code" href="debug_8h.html#a6">nlassert</a> (Init);
00452         <a class="code" href="debug_8h.html#a6">nlassert</a> (Mode == 0);
00453 
00454         <font class="comment">// set the mode to register</font>
00455         Mode = 2;
00456 
00457         TempMessage.clear ();
00458         <font class="keywordflow">if</font> (TempMessage.isReading())
00459                 TempMessage.invert();
00460         TempMessage.setType (<font class="stringliteral">"CT_MSG"</font>);
00461 
00462         description ();
00463 
00464         <font class="comment">// set to mode none</font>
00465         Mode = 0;
00466 
00467         display ();
00468 
00469         <font class="keywordflow">return</font> TempMessage;
00470 }
00471 
00472 <font class="keyword">inline</font> <font class="keywordtype">void</font> CTransportClass::read (<font class="keyword">const</font> std::string &amp;name, <a class="code" href="types__nl_8h.html#a5">uint8</a> sid)
00473 {
00474         <a class="code" href="debug_8h.html#a6">nlassert</a> (Init);
00475         <a class="code" href="debug_8h.html#a6">nlassert</a> (Mode == 0);
00476         <a class="code" href="debug_8h.html#a6">nlassert</a> (States.size() &gt; sid);
00477 
00478         <font class="comment">// set flag of all prop</font>
00479 
00480         std::vector&lt;uint8&gt; bitfield;
00481         bitfield.resize (Prop.size(), 0);
00482 
00483         <font class="comment">// init prop from the stream</font>
00484         <a class="code" href="types__nl_8h.html#a13">uint</a> i;
00485         <font class="keywordflow">for</font> (i = 0; i &lt; States[sid].size(); i++)
00486         {
00487                 <font class="keywordflow">if</font> (States[sid][i].first == -1)
00488                 {
00489                         <font class="comment">// skip the value from the stream</font>
00490                         DummyProp[States[sid][i].second]-&gt;serialDefaultValue (TempMessage);
00491                 }
00492                 <font class="keywordflow">else</font>
00493                 {
00494                         <font class="comment">// get the good value</font>
00495                         Prop[States[sid][i].first]-&gt;serialValue (TempMessage);
00496                         bitfield[States[sid][i].first] = 1;
00497                 }
00498         }
00499 
00500         <font class="comment">// set default value for unknown prop</font>
00501         <font class="keywordflow">for</font> (i = 0; i &lt; Prop.size(); i++)
00502         {
00503                 <font class="keywordflow">if</font> (bitfield[i] == 0)
00504                 {
00505                         Prop[i]-&gt;setDefaultValue ();
00506                 }
00507         }
00508 
00509         display ();
00510 
00511         <font class="comment">// call the user callback</font>
00512         callback (name, sid);
00513 }
00514 
00515 
00516 <font class="preprocessor">#endif // NL_TRANSPORT_CLASS_H</font>
00517 <font class="preprocessor"></font>
00518 <font class="comment">/* End of transport_class.h */</font>
</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>