# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

msg_stream.h

Go to the documentation of this file.
00001 
00006 /* Copyright, 2001 Nevrax Ltd.
00007  *
00008  * This file is part of NEVRAX NEL.
00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2, or (at your option)
00012  * any later version.
00013 
00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * General Public License for more details.
00018 
00019  * You should have received a copy of the GNU General Public License
00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00022  * MA 02111-1307, USA.
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