00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef NL_MSG_STREAM_H
00025 #define NL_MSG_STREAM_H
00026
00027 #include "nel/misc/file.h"
00028 #include "nel/ai/agent/agent.h"
00029 #include "nel/ai/agent/msg.h"
00030
00031 namespace NLAIAGENT
00032 {
00033 class CMsgIStream: public NLMISC::IStream
00034 {
00035 private:
00036 const IBaseGroupType &_List;
00037 CConstIteratorContener _It;
00038 sint32 _Len;
00039 sint32 _Pos;
00040
00041 public:
00042 CMsgIStream(const IBaseGroupType &l):NLMISC::IStream(true), _List(l), _It(_List.getConstIterator()), _Len(_List.size()), _Pos(0)
00043 {
00044 }
00045
00046 CMsgIStream(const CMsgIStream &ist) : NLMISC::IStream(ist), _List(ist._List), _It(ist._It), _Len(ist._Len), _Pos(ist._Len)
00047 {
00048 }
00049
00050 virtual ~CMsgIStream()
00051 {
00052 }
00053
00054 virtual void serial(uint8 &b) throw(NLMISC::EStream);
00055 virtual void serial(sint8 &b) throw(NLMISC::EStream);
00056 virtual void serial(uint16 &b) throw(NLMISC::EStream);
00057 virtual void serial(sint16 &b) throw(NLMISC::EStream);
00058 virtual void serial(uint32 &b) throw(NLMISC::EStream);
00059 virtual void serial(sint32 &b) throw(NLMISC::EStream);
00060 virtual void serial(uint64 &b) throw(NLMISC::EStream);
00061 virtual void serial(sint64 &b) throw(NLMISC::EStream);
00062 virtual void serial(float &b) throw(NLMISC::EStream);
00063 virtual void serial(double &b) throw(NLMISC::EStream);
00064 virtual void serial(bool &b) throw(NLMISC::EStream);
00065
00066 virtual void serial(IObjectIA &b) throw(NLMISC::EStream);
00067 virtual void serial(IObjectIA* &b) throw(NLMISC::EStream);
00068
00069 #ifndef NL_OS_CYGWIN
00070 virtual void serial(char &b) throw(NLMISC::EStream);
00071 #endif
00072 virtual void serial(std::string &b) throw(NLMISC::EStream);
00073 virtual void serial(ucstring &b) throw(NLMISC::EStream);
00074 virtual void serialBuffer(uint8 *buf, uint len)throw(NLMISC::EReadError)
00075 {
00076 throw NLMISC::EReadError((const char *)_List.getType());
00077 }
00078 virtual void serialBit(bool &bit) throw(NLMISC::EReadError)
00079 {
00080 throw NLMISC::EReadError((const char *)_List.getType());
00081 }
00082 virtual sint32 getPos ()
00083 {
00084 return _Pos;
00085 }
00086 bool isEnd() const
00087 {
00088 return _It.isInEnd();
00089 }
00090 };
00091
00092 class CMsgOStream: public NLMISC::IStream
00093 {
00094 private:
00095 IBaseGroupType &_List;
00096 public:
00097 CMsgOStream(IBaseGroupType &msg):NLMISC::IStream(false), _List(msg)
00098 {
00099 }
00100
00101 CMsgOStream(const CMsgOStream &ost):NLMISC::IStream(ost), _List(ost._List)
00102 {
00103 }
00104
00105 virtual ~CMsgOStream()
00106 {
00107 }
00108
00109 virtual void serial(uint8 &b) throw(NLMISC::EStream);
00110 virtual void serial(sint8 &b) throw(NLMISC::EStream);
00111 virtual void serial(uint16 &b) throw(NLMISC::EStream);
00112 virtual void serial(sint16 &b) throw(NLMISC::EStream);
00113 virtual void serial(uint32 &b) throw(NLMISC::EStream);
00114 virtual void serial(sint32 &b) throw(NLMISC::EStream);
00115 virtual void serial(uint64 &b) throw(NLMISC::EStream);
00116 virtual void serial(sint64 &b) throw(NLMISC::EStream);
00117 virtual void serial(float &b) throw(NLMISC::EStream);
00118 virtual void serial(double &b) throw(NLMISC::EStream);
00119 virtual void serial(bool &b) throw(NLMISC::EStream);
00120
00121 virtual void serial(IObjectIA &b) throw(NLMISC::EStream);
00122 virtual void serial(IObjectIA* &b) throw(NLMISC::EStream);
00123
00124 #ifndef NL_OS_CYGWIN
00125 virtual void serial(char &b) throw(NLMISC::EStream);
00126 #endif
00127 virtual void serial(std::string &b) throw(NLMISC::EStream);
00128 virtual void serial(ucstring &b) throw(NLMISC::EStream);
00129 virtual void serialBuffer(uint8 *buf, uint len)throw(NLMISC::EReadError)
00130 {
00131 throw NLMISC::EReadError((const char *)_List.getType());
00132 }
00133 virtual void serialBit(bool &bit) throw(NLMISC::EReadError)
00134 {
00135 throw NLMISC::EReadError((const char *)_List.getType());
00136 }
00137 };
00138
00139 }
00140
00141 #endif