|
Blender
V2.59
|
00001 /* 00002 * $Id: NG_NetworkMessage.h 35072 2011-02-22 12:42:55Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef NG_NETWORKMESSAGE_H 00035 #define NG_NETWORKMESSAGE_H 00036 00037 #include "STR_HashedString.h" 00038 00039 #ifdef WITH_CXX_GUARDEDALLOC 00040 #include "MEM_guardedalloc.h" 00041 #endif 00042 00043 class NG_NetworkMessage 00044 { 00045 static int s_nextID; 00046 int m_uniqueMessageID; // intern counting MessageID 00047 unsigned int m_ClientId; 00048 int m_refcount; 00049 00050 STR_String m_to; // receiver 00051 STR_String m_from; // sender 00052 STR_String m_subject; // empty or propName 00053 STR_String m_message; // message or propValue 00054 00055 protected: 00056 ~NG_NetworkMessage(); 00057 00058 public: 00059 NG_NetworkMessage( 00060 const STR_String& to, 00061 const STR_String& from, 00062 const STR_String& subject, 00063 const STR_String& body); 00064 00065 void AddRef() { 00066 m_refcount++; 00067 } 00068 00069 // This is not nice code you should'nt need to resort to 00070 // delete this. 00071 void Release() 00072 { 00073 if (! --m_refcount) 00074 { 00075 delete this; 00076 } 00077 } 00078 00082 void SetMessageText(const STR_String& msgtext) { 00083 m_message = msgtext; 00084 } 00085 00089 const STR_String& GetDestinationName() { return m_to;}; 00090 00094 const STR_String& GetSenderName() { return m_from;}; 00095 00099 const STR_String& GetSubject() { return m_subject;}; 00100 00104 const STR_String& GetMessageText() { 00105 //cout << "GetMessageText " << m_message << "\n"; 00106 return m_message; 00107 } 00108 const STR_String& GetMessageText() const { 00109 //cout << "GetMessageText " << m_message << "\n"; 00110 return m_message; 00111 } 00112 00116 void SetSender(unsigned int ClientId) { 00117 m_ClientId = ClientId; 00118 } 00119 00123 unsigned int GetSender(void) { 00124 return m_ClientId; 00125 } 00126 00130 int GetMessageID() { 00131 return m_uniqueMessageID; 00132 } 00133 00134 00135 #ifdef WITH_CXX_GUARDEDALLOC 00136 public: 00137 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkMessage"); } 00138 void operator delete( void *mem ) { MEM_freeN(mem); } 00139 #endif 00140 }; 00141 00142 #endif //NG_NETWORKMESSAGE_H 00143