aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/nel/src/net/transport_class.cpp?rev=1.12&content-type=text/x-cvsweb-markup&sortby=date/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'cvs/cvsweb.cgi/code/nel/src/net/transport_class.cpp?rev=1.12&content-type=text/x-cvsweb-markup&sortby=date/index.html')
-rw-r--r--cvs/cvsweb.cgi/code/nel/src/net/transport_class.cpp?rev=1.12&content-type=text/x-cvsweb-markup&sortby=date/index.html414
1 files changed, 414 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/nel/src/net/transport_class.cpp?rev=1.12&content-type=text/x-cvsweb-markup&sortby=date/index.html b/cvs/cvsweb.cgi/code/nel/src/net/transport_class.cpp?rev=1.12&content-type=text/x-cvsweb-markup&sortby=date/index.html
new file mode 100644
index 00000000..cb3cf9c1
--- /dev/null
+++ b/cvs/cvsweb.cgi/code/nel/src/net/transport_class.cpp?rev=1.12&content-type=text/x-cvsweb-markup&sortby=date/index.html
@@ -0,0 +1,414 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
+<HEAD><style> A { color:black }</style>
+<!-- hennerik CVSweb $Revision: 1.93 $ -->
+<TITLE>code/nel/src/net/transport_class.cpp - view - 1.12</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="transport_class.cpp?sortby=date"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="transport_class.cpp?sortby=date">transport_class.cpp</A>
+ CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/?sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=date">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/?sortby=date">src</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/?sortby=date">net</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/?sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=date">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/?sortby=date">src</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/?sortby=date">net</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/transport_class.cpp?sortby=date">transport_class.cpp</a>&nbsp;(<A HREF="/cvs/cvsweb.cgi/~checkout~/code/nel/src/net/transport_class.cpp?rev=1.12&amp;sortby=date" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nel/src/net/transport_class.cpp?rev=1.12','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
+Revision <B>1.12</B>, <i>Tue Jul 2 17:27:30 2002 UTC</i> (3 weeks, 6 days ago) by <i>miller</i>
+<BR>Branch: <b>MAIN</b>
+<BR>CVS Tags: <b>HEAD</b><BR>Changes since <b>1.11: +3 -2
+ lines</b><PRE>
+bug fix by Vianney
+</PRE>
+</td></tr></table><HR noshade><PRE>/** \file transport_class.cpp
+ * &lt;File description&gt;
+ *
+ * $Id: transport_class.cpp,v 1.12 2002/07/02 17:27:30 miller Exp $
+ */
+
+/* Copyright, 2000-2002 Nevrax Ltd.
+ *
+ * This file is part of NEVRAX NeL Network Services.
+ * NEVRAX NeL Network Services is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+
+ * NEVRAX NeL Network Services is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with NEVRAX NeL Network Services; see the file COPYING. If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*
+ * Limitations: Not threadsafe, not reentrant.
+ */
+
+
+//
+// Includes
+//
+
+#include &quot;stdnet.h&quot;
+
+#include &quot;nel/misc/types_nl.h&quot;
+#include &quot;nel/misc/debug.h&quot;
+#include &quot;nel/misc/entity_id.h&quot;
+#include &quot;nel/misc/sheet_id.h&quot;
+
+#include &quot;nel/net/unified_network.h&quot;
+
+#include &quot;nel/net/transport_class.h&quot;
+
+//
+// Namespace
+//
+
+using namespace std;
+using namespace NLMISC;
+using namespace NLNET;
+
+namespace NLNET {
+
+//
+// Variables
+//
+
+uint CTransportClass::Mode = 0; // 0=nothing 1=read 2=write 3=register
+
+map&lt;string, CTransportClass::CRegisteredClass&gt; &nbsp;CTransportClass::LocalRegisteredClass; &nbsp; &nbsp; &nbsp; &nbsp;// registered class that are in my program
+
+CTransportClass::CRegisteredClass &nbsp; &nbsp; &nbsp; CTransportClass::TempRegisteredClass;
+
+NLNET::CMessage CTransportClass::TempMessage;
+
+vector&lt;CTransportClass::CRegisteredBaseProp *&gt; CTransportClass::DummyProp;
+
+bool CTransportClass::Init = false;
+
+
+//
+// Functions
+//
+
+string typeToString (CTransportClass::TProp type)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;string conv[] = {
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;PropUInt8&quot;, &quot;PropUInt16&quot;, &quot;PropUInt32&quot;, &quot;PropUInt64&quot;,
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;PropSInt8&quot;, &quot;PropSInt16&quot;, &quot;PropSInt32&quot;, &quot;PropSInt64&quot;,
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;PropBool&quot;, &quot;PropFloat&quot;, &quot;PropDouble&quot;, &quot;PropString&quot;, &quot;PropEntityId&quot;, &quot;PropSheetId&quot;, &quot;PropUKN&quot; };
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (type &gt; CTransportClass::PropUKN)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return &quot;&lt;InvalidType&gt;&quot;;
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return conv[type];
+}
+
+void CTransportClass::displayDifferentClass (uint8 sid, const string &amp;className, const vector&lt;CRegisteredBaseProp&gt; &amp;otherClass, const vector&lt;CRegisteredBaseProp *&gt; &amp;myClass)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot;Service with sid %u send me the TransportClass '%s' with differents properties:&quot;, sid, className.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;uint i;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot; &nbsp;My local TransportClass is:&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;for (i = 0; i &lt; myClass.size(); i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot; &nbsp; &nbsp;Property: %d Name: '%s' type: '%s'&quot;, i, myClass[i]-&gt;Name.c_str(), typeToString(myClass[i]-&gt;Type).c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot; &nbsp;The other side TransportClass is:&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;for (i = 0; i &lt; otherClass.size(); i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlinfo (&quot; &nbsp; &nbsp;Property: %d Name: '%s' type: '%s'&quot;, i, otherClass[i].Name.c_str(), typeToString(otherClass[i].Type).c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+void CTransportClass::registerOtherSideClass (uint8 sid, TOtherSideRegisteredClass &amp;osrc)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;for (TOtherSideRegisteredClass::iterator it = osrc.begin(); it != osrc.end (); it++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// find the class name in the map
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRegisteredClass::iterator res = LocalRegisteredClass.find ((*it).first);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (res == LocalRegisteredClass.end ())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// it s a class that the other side have but not me, can't send this class
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;CTransportClass::registerOtherSideClass(): the other side class '%s' is not registered in my system, skip it&quot;, (*it).first.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;continue;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (sid &gt;= (*res).second.Instance-&gt;States.size ())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*res).second.Instance-&gt;States.resize (sid+1);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*res).second.Instance-&gt;States[sid].clear ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (sint j = 0; j &lt; (sint)(*it).second.size (); j++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// check each prop to see the correspondance
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// try to find the prop name in the array
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint k;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (k = 0; k &lt; (*res).second.Instance-&gt;Prop.size(); k++)
+ &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;if ((*it).second[j].Name == (*res).second.Instance-&gt;Prop[k]-&gt;Name)
+ &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;if ((*it).second[j].Type != (*res).second.Instance-&gt;Prop[k]-&gt;Type)
+ &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;nlwarning (&quot;Property '%s' of the class '%s' have not the same type in the 2 sides (%s %s)&quot;, (*it).second[j].Name.c_str(), (*it).first.c_str(), typeToString((*it).second[j].Type).c_str(), typeToString((*res).second.Instance-&gt;Prop[k]-&gt;Type).c_str());
+ &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;break;
+ &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;if (k == (*res).second.Instance-&gt;Prop.size())
+ &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;// not found, put -1
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*res).second.Instance-&gt;States[sid].push_back (make_pair (-1, (*it).second[j].Type));
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &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;// same, store the index
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*res).second.Instance-&gt;States[sid].push_back (make_pair (k, PropUKN));
+ &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;// check if the version are the same
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((*it).second.size () != (*res).second.Instance-&gt;Prop.size ())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 2 class don't have the same number of prop =&gt; different class =&gt; display class
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;displayDifferentClass (sid, (*it).first.c_str(), (*it).second, (*res).second.Instance-&gt;Prop);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// check if the prop are same
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (uint i = 0; i &lt; (*res).second.Instance-&gt;Prop.size (); i++)
+ &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;if ((*res).second.Instance-&gt;Prop[i]-&gt;Name != (*it).second[i].Name)
+ &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;// different name =&gt; different class =&gt; display class
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;displayDifferentClass (sid, (*it).first.c_str(), (*it).second, (*res).second.Instance-&gt;Prop);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+ &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;else if ((*res).second.Instance-&gt;Prop[i]-&gt;Type != (*it).second[i].Type)
+ &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;// different type =&gt; different class =&gt; display class
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;displayDifferentClass (sid, (*it).first.c_str(), (*it).second, (*res).second.Instance-&gt;Prop);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+ &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;displayLocalRegisteredClass ();
+}
+
+
+void CTransportClass::registerClass (CTransportClass &amp;instance)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (Init);
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (Mode == 0);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// set the mode to register
+ &nbsp; &nbsp; &nbsp; &nbsp;Mode = 3;
+ &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;// clear the current class
+ &nbsp; &nbsp; &nbsp; &nbsp;TempRegisteredClass.clear ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// set the instance pointer
+ &nbsp; &nbsp; &nbsp; &nbsp;TempRegisteredClass.Instance = &amp;instance;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// fill name and props
+ &nbsp; &nbsp; &nbsp; &nbsp;TempRegisteredClass.Instance-&gt;description ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// add the new registered class in the array
+ &nbsp; &nbsp; &nbsp; &nbsp;LocalRegisteredClass[TempRegisteredClass.Instance-&gt;Name] = TempRegisteredClass;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// set to mode none
+ &nbsp; &nbsp; &nbsp; &nbsp;Mode = 0;
+}
+
+void CTransportClass::unregisterClass ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;for (TRegisteredClass::iterator it = LocalRegisteredClass.begin(); it != LocalRegisteredClass.end (); it++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (uint j = 0; j &lt; (*it).second.Instance-&gt;Prop.size (); j++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;delete (*it).second.Instance-&gt;Prop[j];
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*it).second.Instance-&gt;Prop.clear ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(*it).second.Instance = NULL;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;LocalRegisteredClass.clear ();
+}
+
+void CTransportClass::displayLocalRegisteredClass (CRegisteredClass &amp;c)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: &nbsp;&gt; %s&quot;, c.Instance-&gt;Name.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;for (uint j = 0; j &lt; c.Instance-&gt;Prop.size (); j++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: &nbsp; &nbsp;&gt; %s %s&quot;, c.Instance-&gt;Prop[j]-&gt;Name.c_str(), typeToString(c.Instance-&gt;Prop[j]-&gt;Type).c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (uint l = 0; l &lt; c.Instance-&gt;States.size (); l++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (c.Instance-&gt;States[l].size () != 0)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: &nbsp; &nbsp; &nbsp;&gt; sid: %u&quot;, l);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (uint k = 0; k &lt; c.Instance-&gt;States[l].size (); k++)
+ &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;nldebug (&quot;NETTC: &nbsp; &nbsp; &nbsp;- %d type : %s&quot;, c.Instance-&gt;States[l][k].first, typeToString(c.Instance-&gt;States[l][k].second).c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+void CTransportClass::displayLocalRegisteredClass ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC:&gt; LocalRegisteredClass:&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;for (TRegisteredClass::iterator it = LocalRegisteredClass.begin(); it != LocalRegisteredClass.end (); it++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;displayLocalRegisteredClass ((*it).second);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+void cbTCReceiveMessage (CMessage &amp;msgin, const string &amp;name, uint16 sid)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: cbReceiveMessage&quot;);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CTransportClass::TempMessage = msgin;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;string className;
+ &nbsp; &nbsp; &nbsp; &nbsp;CTransportClass::TempMessage.serial (className);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CTransportClass::TRegisteredClass::iterator it = CTransportClass::LocalRegisteredClass.find (className);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (it == CTransportClass::LocalRegisteredClass.end ())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;receive unknown class '%s', skip it&quot;, className.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert ((*it).second.Instance != NULL);
+ &nbsp; &nbsp; &nbsp; &nbsp;(*it).second.Instance-&gt;read (name, (uint8)sid);
+}
+
+void cbTCReceiveOtherSideClass (CMessage &amp;msgin, const string &amp;name, uint16 sid)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: cbReceiveOtherSideClass&quot;);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CTransportClass::TOtherSideRegisteredClass osrc;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbClass;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (nbClass);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: %d class&quot;, nbClass);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (uint i = 0; i &lt; nbClass; i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string className;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (className);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;osrc.push_back(make_pair (className, vector&lt;CTransportClass::CRegisteredBaseProp&gt;()));
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbProp;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (nbProp);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: &nbsp; %s (%d prop)&quot;, className.c_str(), nbProp);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (uint j = 0; j &lt; nbProp; j++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CTransportClass::CRegisteredBaseProp prop;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (prop.Name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serialEnum (prop.Type);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: &nbsp; &nbsp; %s %s&quot;, prop.Name.c_str(), typeToString(prop.Type).c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;osrc[osrc.size()-1].second.push_back (prop);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// we have the good structure
+ &nbsp; &nbsp; &nbsp; &nbsp;CTransportClass::registerOtherSideClass ((uint8)sid, osrc);
+}
+
+static TUnifiedCallbackItem CallbackArray[] =
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;CT_LRC&quot;, cbTCReceiveOtherSideClass },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;CT_MSG&quot;, cbTCReceiveMessage },
+};
+
+void cbTCUpService (const std::string &amp;serviceName, uint16 sid, void *arg)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;NETTC: CTransportClass Service %s %d is up&quot;, serviceName.c_str(), sid);
+ &nbsp; &nbsp; &nbsp; &nbsp;if (sid &gt;= 256)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;CTransportClass::sendLocalRegisteredClass ((uint8)sid);
+}
+
+void CTransportClass::init ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// this isn't an error!
+ &nbsp; &nbsp; &nbsp; &nbsp;if (Init) return;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// filter all my debug stuffs
+ &nbsp; &nbsp; &nbsp; &nbsp;DebugLog-&gt;addNegativeFilter (&quot;NETTC&quot;);
+
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CUnifiedNetwork::getInstance()-&gt;addCallbackArray (CallbackArray, sizeof (CallbackArray) / sizeof (CallbackArray[0]));
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// create an instance of all d'ifferent prop types
+
+ &nbsp; &nbsp; &nbsp; &nbsp;DummyProp.resize (PropUKN);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropUInt8 &lt; PropUKN); DummyProp[PropUInt8] = new CTransportClass::CRegisteredProp&lt;uint8&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropUInt16 &lt; PropUKN); DummyProp[PropUInt16] = new CTransportClass::CRegisteredProp&lt;uint16&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropUInt32 &lt; PropUKN); DummyProp[PropUInt32] = new CTransportClass::CRegisteredProp&lt;uint32&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropUInt64 &lt; PropUKN); DummyProp[PropUInt64] = new CTransportClass::CRegisteredProp&lt;uint64&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropSInt8 &lt; PropUKN); DummyProp[PropSInt8] = new CTransportClass::CRegisteredProp&lt;sint8&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropSInt16 &lt; PropUKN); DummyProp[PropSInt16] = new CTransportClass::CRegisteredProp&lt;sint16&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropSInt32 &lt; PropUKN); DummyProp[PropSInt32] = new CTransportClass::CRegisteredProp&lt;sint32&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropSInt64 &lt; PropUKN); DummyProp[PropSInt64] = new CTransportClass::CRegisteredProp&lt;sint64&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropBool &lt; PropUKN); DummyProp[PropBool] = new CTransportClass::CRegisteredProp&lt;bool&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropFloat &lt; PropUKN); DummyProp[PropFloat] = new CTransportClass::CRegisteredProp&lt;float&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropDouble &lt; PropUKN); DummyProp[PropDouble] = new CTransportClass::CRegisteredProp&lt;double&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropString &lt; PropUKN); DummyProp[PropString] = new CTransportClass::CRegisteredProp&lt;string&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropEntityId &lt; PropUKN); DummyProp[PropEntityId] = new CTransportClass::CRegisteredProp&lt;CEntityId&gt;;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (PropSheetId &lt; PropUKN); DummyProp[PropSheetId] = new CTransportClass::CRegisteredProp&lt;CSheetId&gt;;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// 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)
+ &nbsp; &nbsp; &nbsp; &nbsp;CUnifiedNetwork::getInstance()-&gt;setServiceUpCallback(&quot;*&quot;, cbTCUpService, NULL, false);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;Init = true;
+}
+
+void CTransportClass::release ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;unregisterClass ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (uint i = 0; i &lt; DummyProp.size (); i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;delete DummyProp[i];
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;DummyProp.clear ();
+}
+
+void CTransportClass::createLocalRegisteredClassMessage ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.clear ();
+ &nbsp; &nbsp; &nbsp; &nbsp;if (TempMessage.isReading())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.invert();
+ &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.setType (&quot;CT_LRC&quot;);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbClass = LocalRegisteredClass.size ();
+ &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.serial (nbClass);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (TRegisteredClass::iterator it = LocalRegisteredClass.begin(); it != LocalRegisteredClass.end (); it++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert ((*it).first == (*it).second.Instance-&gt;Name);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.serial ((*it).second.Instance-&gt;Name);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uint32 nbProp = (*it).second.Instance-&gt;Prop.size ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.serial (nbProp);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (uint j = 0; j &lt; (*it).second.Instance-&gt;Prop.size (); j++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// send the name and the type of the prop
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.serial ((*it).second.Instance-&gt;Prop[j]-&gt;Name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TempMessage.serialEnum ((*it).second.Instance-&gt;Prop[j]-&gt;Type);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+} // NLNET
+</PRE> \ No newline at end of file