diff options
Diffstat (limited to 'docs/doxygen/nel/transport__class_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/transport__class_8cpp-source.html | 468 |
1 files changed, 468 insertions, 0 deletions
diff --git a/docs/doxygen/nel/transport__class_8cpp-source.html b/docs/doxygen/nel/transport__class_8cpp-source.html new file mode 100644 index 00000000..90f530fa --- /dev/null +++ b/docs/doxygen/nel/transport__class_8cpp-source.html @@ -0,0 +1,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="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>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=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |