4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
30 /** \file NG_NetworkScene.h
32 * \brief NetworkSceneManagement generic class
34 #ifndef __NG_NETWORKSCENE_H
35 #define __NG_NETWORKSCENE_H
38 #include "STR_HashedString.h"
41 #ifdef WITH_CXX_GUARDEDALLOC
42 #include "MEM_guardedalloc.h"
45 //MSVC defines SendMessage as a win api function, even though we aren't using it
50 class NG_NetworkDeviceInterface;
54 class NG_NetworkDeviceInterface *m_networkdevice;
55 GEN_Map<STR_HashedString, class NG_NetworkObject *> m_networkObjects;
57 // GEN_Maps used as a 'Bloom' filter
58 typedef GEN_Map<STR_HashedString, std::vector<class NG_NetworkMessage*>* > TMessageMap;
59 TMessageMap m_messagesByDestinationName;
60 TMessageMap m_messagesBySenderName;
61 TMessageMap m_messagesBySubject;
64 NG_NetworkScene(NG_NetworkDeviceInterface *nic);
68 * progress one frame, handle all network traffic
70 void proceed(double curtime);
73 * add a networkobject to the scene
75 void AddObject(NG_NetworkObject* object);
78 * remove a networkobject to the scene
80 void RemoveObject(NG_NetworkObject* object);
83 * remove all objects at once
85 void RemoveAllObjects();
88 * send a message (ascii text) over the network
90 void SendMessage(const STR_String& to,const STR_String& from,const STR_String& subject,const STR_String& message);
93 * find an object by name
95 NG_NetworkObject* FindNetworkObject(const STR_String& objname);
97 bool ConstraintsAreValid(const STR_String& from,const STR_String& subject,class NG_NetworkMessage* message);
98 vector<NG_NetworkMessage*> FindMessages(const STR_String& to,const STR_String& from,const STR_String& subject,bool spamallowed);
102 * Releases messages in message map members.
104 void ClearAllMessageMaps(void);
107 * Releases messages for the given message map.
108 * @param map Message map with messages.
110 void ClearMessageMap(TMessageMap& map);
113 #ifdef WITH_CXX_GUARDEDALLOC
115 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkScene"); }
116 void operator delete( void *mem ) { MEM_freeN(mem); }
120 #endif //__NG_NETWORKSCENE_H