NLNET::CTransportClass Class Reference

#include <transport_class.h>


Detailed Description

You have to inherit this class and implement description() and callback() method. For an example of use, take a look at nel/samples/class_transport sample.
Author:
Vianney Lecroart

Nevrax France

Date:
2002

Definition at line 71 of file transport_class.h.

Public Types

enum  TProp {
  PropUInt8, PropUInt16, PropUInt32, PropUInt64,
  PropSInt8, PropSInt16, PropSInt32, PropSInt64,
  PropBool, PropFloat, PropDouble, PropString,
  PropDataSetRow, PropSheetId, PropUKN
}

Public Member Functions

virtual ~CTransportClass ()

Static Public Member Functions

void displayLocalRegisteredClass ()
 Display registered transport class (debug purpose).

void init ()
 Init the transport class system (must be called one time, in the IService5::init() for example).

void registerClass (CTransportClass &instance)
void release ()
 Release the transport class system (must be called one time, in the IService5::release() for example).


Member Enumeration Documentation

enum NLNET::CTransportClass::TProp
 

Different types that we can use in a Transport class warning: if you add/change a prop, change also in CTransportClass::init() warning: PropUKN must be the last value (used to resize a vector)

Enumeration values:
PropUInt8 
PropUInt16 
PropUInt32 
PropUInt64 
PropSInt8 
PropSInt16 
PropSInt32 
PropSInt64 
PropBool 
PropFloat 
PropDouble 
PropString 
PropDataSetRow 
PropSheetId 
PropUKN 

Definition at line 79 of file transport_class.h.


Constructor & Destructor Documentation

virtual NLNET::CTransportClass::~CTransportClass  )  [inline, virtual]
 

Definition at line 74 of file transport_class.h.

00074 {}


Member Function Documentation

void NLNET::CTransportClass::displayLocalRegisteredClass  )  [static]
 

Display registered transport class (debug purpose).

Definition at line 245 of file transport_class.cpp.

References nldebug.

00246 {
00247         nldebug ("NETTC:> LocalRegisteredClass:");
00248         for (TRegisteredClass::iterator it = LocalRegisteredClass.begin(); it != LocalRegisteredClass.end (); it++)
00249         {
00250                 displayLocalRegisteredClass ((*it).second);
00251         }
00252 }

void NLNET::CTransportClass::init  )  [static]
 

Init the transport class system (must be called one time, in the IService5::init() for example).

Definition at line 330 of file transport_class.cpp.

References NLNET::CallbackArray, NLNET::cbTCUpService(), nlassert, PropBool, PropDouble, PropFloat, PropSheetId, PropSInt16, PropSInt32, PropSInt64, PropSInt8, PropString, PropUInt16, PropUInt32, PropUInt64, PropUInt8, and PropUKN.

00331 {
00332         // this isn't an error!
00333         if (Init) return;
00334 
00335         CUnifiedNetwork::getInstance()->addCallbackArray (CallbackArray, sizeof (CallbackArray) / sizeof (CallbackArray[0]));
00336 
00337         // create an instance of all d'ifferent prop types
00338 
00339         DummyProp.resize (PropUKN);
00340 
00341         nlassert (PropUInt8 < PropUKN); DummyProp[PropUInt8] = new CTransportClass::CRegisteredProp<uint8>;
00342         nlassert (PropUInt16 < PropUKN); DummyProp[PropUInt16] = new CTransportClass::CRegisteredProp<uint16>;
00343         nlassert (PropUInt32 < PropUKN); DummyProp[PropUInt32] = new CTransportClass::CRegisteredProp<uint32>;
00344         nlassert (PropUInt64 < PropUKN); DummyProp[PropUInt64] = new CTransportClass::CRegisteredProp<uint64>;
00345         nlassert (PropSInt8 < PropUKN); DummyProp[PropSInt8] = new CTransportClass::CRegisteredProp<sint8>;
00346         nlassert (PropSInt16 < PropUKN); DummyProp[PropSInt16] = new CTransportClass::CRegisteredProp<sint16>;
00347         nlassert (PropSInt32 < PropUKN); DummyProp[PropSInt32] = new CTransportClass::CRegisteredProp<sint32>;
00348         nlassert (PropSInt64 < PropUKN); DummyProp[PropSInt64] = new CTransportClass::CRegisteredProp<sint64>;
00349         nlassert (PropBool < PropUKN); DummyProp[PropBool] = new CTransportClass::CRegisteredProp<bool>;
00350         nlassert (PropFloat < PropUKN); DummyProp[PropFloat] = new CTransportClass::CRegisteredProp<float>;
00351         nlassert (PropDouble < PropUKN); DummyProp[PropDouble] = new CTransportClass::CRegisteredProp<double>;
00352         nlassert (PropString < PropUKN); DummyProp[PropString] = new CTransportClass::CRegisteredProp<string>;
00353 //      nlassert (PropDataSetRow < PropUKN); DummyProp[PropDataSetRow] = new CTransportClass::CRegisteredProp<TDataSetRow>;
00354 //      nlassert (PropEntityId < PropUKN); DummyProp[PropEntityId] = new CTransportClass::CRegisteredProp<CEntityId>;
00355         nlassert (PropSheetId < PropUKN); DummyProp[PropSheetId] = new CTransportClass::CRegisteredProp<CSheetId>;
00356 
00357         // 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)
00358         CUnifiedNetwork::getInstance()->setServiceUpCallback("*", cbTCUpService, NULL, false);
00359 
00360         Init = true;
00361 }

void NLNET::CTransportClass::registerClass CTransportClass instance  )  [static]
 

Call this function to register a new transport class.

Parameters:
instance A reference to a GLOBAL space of the instance of this transport class. It will be used when receive this class from network.

Definition at line 186 of file transport_class.cpp.

References nlassert.

00187 {
00188         nlassert (Init);
00189         nlassert (Mode == 0);
00190 
00191         // set the mode to register
00192         Mode = 3;
00193         
00194         // clear the current class
00195         TempRegisteredClass.clear ();
00196 
00197         // set the instance pointer
00198         TempRegisteredClass.Instance = &instance;
00199 
00200         // fill name and props
00201         TempRegisteredClass.Instance->description ();
00202 
00203         // add the new registered class in the array
00204         LocalRegisteredClass[TempRegisteredClass.Instance->Name] = TempRegisteredClass;
00205 
00206         // set to mode none
00207         Mode = 0;
00208 }

void NLNET::CTransportClass::release  )  [static]
 

Release the transport class system (must be called one time, in the IService5::release() for example).

Definition at line 363 of file transport_class.cpp.

References uint.

00364 {
00365         unregisterClass ();
00366 
00367         for (uint i = 0; i < DummyProp.size (); i++)
00368         {
00369                 delete DummyProp[i];
00370         }
00371         DummyProp.clear ();
00372 }


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 14:05:06 2004 for NeL by doxygen 1.3.6