|
Blender
V2.59
|
00001 /* 00002 * $Id: NG_NetworkScene.h 36523 2011-05-06 20:18:42Z blendix $ 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_NETWORKSCENE_H 00035 #define __NG_NETWORKSCENE_H 00036 00037 #include "CTR_Map.h" 00038 #include "STR_HashedString.h" 00039 #include <vector> 00040 00041 #ifdef WITH_CXX_GUARDEDALLOC 00042 #include "MEM_guardedalloc.h" 00043 #endif 00044 00045 //MSVC defines SendMessage as a win api function, even though we aren't using it 00046 #ifdef SendMessage 00047 #undef SendMessage 00048 #endif 00049 00050 class NG_NetworkDeviceInterface; 00051 00052 class NG_NetworkScene 00053 { 00054 class NG_NetworkDeviceInterface *m_networkdevice; 00055 CTR_Map<STR_HashedString, class NG_NetworkObject *> m_networkObjects; 00056 00057 // CTR_Maps used as a 'Bloom' filter 00058 typedef CTR_Map<STR_HashedString, std::vector<class NG_NetworkMessage*>* > TMessageMap; 00059 TMessageMap m_messagesByDestinationName; 00060 TMessageMap m_messagesBySenderName; 00061 TMessageMap m_messagesBySubject; 00062 00063 public: 00064 NG_NetworkScene(NG_NetworkDeviceInterface *nic); 00065 ~NG_NetworkScene(); 00066 00070 void proceed(double curtime); 00071 00075 void AddObject(NG_NetworkObject* object); 00076 00080 void RemoveObject(NG_NetworkObject* object); 00081 00085 void RemoveAllObjects(); 00086 00090 void SendMessage(const STR_String& to,const STR_String& from,const STR_String& subject,const STR_String& message); 00091 00095 NG_NetworkObject* FindNetworkObject(const STR_String& objname); 00096 00097 bool ConstraintsAreValid(const STR_String& from,const STR_String& subject,class NG_NetworkMessage* message); 00098 vector<NG_NetworkMessage*> FindMessages(const STR_String& to,const STR_String& from,const STR_String& subject,bool spamallowed); 00099 00100 protected: 00104 void ClearAllMessageMaps(void); 00105 00110 void ClearMessageMap(TMessageMap& map); 00111 00112 00113 #ifdef WITH_CXX_GUARDEDALLOC 00114 public: 00115 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkScene"); } 00116 void operator delete( void *mem ) { MEM_freeN(mem); } 00117 #endif 00118 }; 00119 00120 #endif //__NG_NETWORKSCENE_H 00121