Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00032 #ifndef __NG_NETWORKSCENE_H 00033 #define __NG_NETWORKSCENE_H 00034 00035 #include "CTR_Map.h" 00036 #include "STR_HashedString.h" 00037 #include <vector> 00038 00039 #ifdef WITH_CXX_GUARDEDALLOC 00040 #include "MEM_guardedalloc.h" 00041 #endif 00042 00043 //MSVC defines SendMessage as a win api function, even though we aren't using it 00044 #ifdef SendMessage 00045 #undef SendMessage 00046 #endif 00047 00048 class NG_NetworkDeviceInterface; 00049 00050 class NG_NetworkScene 00051 { 00052 class NG_NetworkDeviceInterface *m_networkdevice; 00053 CTR_Map<STR_HashedString, class NG_NetworkObject *> m_networkObjects; 00054 00055 // CTR_Maps used as a 'Bloom' filter 00056 typedef CTR_Map<STR_HashedString, std::vector<class NG_NetworkMessage*>* > TMessageMap; 00057 TMessageMap m_messagesByDestinationName; 00058 TMessageMap m_messagesBySenderName; 00059 TMessageMap m_messagesBySubject; 00060 00061 public: 00062 NG_NetworkScene(NG_NetworkDeviceInterface *nic); 00063 ~NG_NetworkScene(); 00064 00068 void proceed(double curtime); 00069 00073 void AddObject(NG_NetworkObject* object); 00074 00078 void RemoveObject(NG_NetworkObject* object); 00079 00083 void RemoveAllObjects(); 00084 00088 void SendMessage(const STR_String& to,const STR_String& from,const STR_String& subject,const STR_String& message); 00089 00093 NG_NetworkObject* FindNetworkObject(const STR_String& objname); 00094 00095 bool ConstraintsAreValid(const STR_String& from,const STR_String& subject,class NG_NetworkMessage* message); 00096 vector<NG_NetworkMessage*> FindMessages(const STR_String& to,const STR_String& from,const STR_String& subject,bool spamallowed); 00097 00098 protected: 00102 void ClearAllMessageMaps(void); 00103 00108 void ClearMessageMap(TMessageMap& map); 00109 00110 00111 #ifdef WITH_CXX_GUARDEDALLOC 00112 public: 00113 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkScene"); } 00114 void operator delete( void *mem ) { MEM_freeN(mem); } 00115 #endif 00116 }; 00117 00118 #endif //__NG_NETWORKSCENE_H 00119