ionflux.org | Impressum

Message.hpp

Go to the documentation of this file.
00001 #ifndef IONFLUX_TOOLS_MESSAGE
00002 #define IONFLUX_TOOLS_MESSAGE
00003 /* ==========================================================================
00004  * Ionflux Tools
00005  * Copyright (c) 2004 Joern P. Meier
00006  * mail@ionflux.org
00007  * --------------------------------------------------------------------------
00008  * Message.hpp                    Network message.
00009  * ==========================================================================
00010  * 
00011  * This file is part of Ionflux Tools.
00012  * 
00013  * Ionflux Tools is free software; you can redistribute it and/or modify it 
00014  * under the terms of the GNU General Public License as published by the Free
00015  * Software Foundation; either version 2 of the License, or (at  your option)
00016  * any later version.
00017  * 
00018  * Ionflux Tools is distributed in the hope that it will be useful, but 
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00020  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00021  * for more details.
00022  * 
00023  * You should have received a copy of the GNU General Public License
00024  * along with Ionflux Tools; if not, write to the Free Software Foundation, 
00025  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00026  * 
00027  * ========================================================================== */
00028 
00029 #include <string>
00030 #include <iostream>
00031 #include <sstream>
00032 #include <vector>
00033 #include "ionflux/tools.hpp"
00034 #include "ionflux/Reporter.hpp"
00035 #include "ionflux/Tree.hpp"
00036 #include "ionflux/MessageDump.hpp"
00037 
00038 namespace Ionflux
00039 {
00040 
00041 namespace Tools
00042 {
00043 
00044 class MessageDump;
00045 
00067 class Message
00068 : public Tree
00069 {
00070     protected:
00072         std::string magicWord;
00074         int protocolVersion;
00076         int protocolVersionLower;
00078         int protocolVersionUpper;
00080         int uid;
00082         int type;
00084         unsigned int flags;
00086         unsigned int size;
00088         std::string checksum;
00090         std::string username;
00092         std::string userSecret;
00094         std::string sessionSecret;
00096         std::string serialized;
00098         MessageDump *target;
00100         unsigned int maxSize;
00101         
00109         virtual bool unpack();
00110         
00111     public:
00113         static const std::string DEFAULT_MAGIC_WORD;
00115         static const int DEFAULT_PROTOCOL_VERSION;
00117         static const int UID_NOT_SET;
00119         static const int TYPE_NOT_SET;
00121         static const int FLAG_COMPRESS;
00123         static const int HEADER_SIZE;
00125         static const unsigned int DEFAULT_MAX_SIZE;
00126         
00131         Message();
00132         
00137         virtual ~Message();
00138         
00147         virtual void clearData();
00148         
00156         virtual void clearAll();
00157         
00167         virtual void serialize(std::string &buffer);
00168         
00181         virtual bool append(const std::string& bytes);
00182         
00195         virtual void dump(const std::string& bytes);
00196         
00205         virtual void setMagicWord(const std::string &newMagicWord);
00206         
00217         virtual void setProtocolVersion(int newProtocolVersion);
00218         
00234         virtual void setAcceptableProtocolVersion(int newProtocolVersionLower, 
00235             int newProtocolVersionUpper);
00236         
00244         virtual void setUID(int newUID);
00245         
00254         virtual void setType(int newType);
00255         
00266         virtual void setFlags(unsigned int newFlags);
00267         
00274         virtual void setUsername(const std::string &newUsername);
00275         
00282         virtual void setUserSecret(const std::string &newUserSecret);
00283         
00295         virtual void setSessionSecret(const std::string &newSessionSecret);
00296         
00303         virtual void setTarget(MessageDump *newTarget);
00304         
00311         virtual void setMaxSize(unsigned int newMaxSize);
00312         
00317         virtual std::string getMagicWord();
00318         
00323         virtual int getProtocolVersion();
00324         
00329         virtual int getUID();
00330         
00335         virtual int getType();
00336         
00341         virtual unsigned int getFlags();
00342         
00347         virtual unsigned int getSize();
00348         
00353         virtual std::string getUsername();
00354         
00361         virtual void getUserSecret(std::string &userSecretBuffer);
00362         
00369         virtual void getSessionSecret(std::string &sessionSecretBuffer);
00370         
00387         virtual unsigned int getNumBytesMissing();
00388         
00393         virtual unsigned int getMaxSize();
00394 };
00395 
00396 }
00397 
00398 }
00399 
00403 #endif

Generated on Tue Mar 14 20:58:29 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6