1 // message.hxx -- Multiplayer Client/Server message base class
\r
3 // Written by John Barrett, started November 2003.
\r
5 // Copyright (C) 2003 John R. Barrett - jbarrett@accesshosting.com
\r
7 // This program is free software; you can redistribute it and/or
\r
8 // modify it under the terms of the GNU General Public License as
\r
9 // published by the Free Software Foundation; either version 2 of the
\r
10 // License, or (at your option) any later version.
\r
12 // This program is distributed in the hope that it will be useful, but
\r
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
15 // General Public License for more details.
\r
17 // You should have received a copy of the GNU General Public License
\r
18 // along with this program; if not, write to the Free Software
\r
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
\r
23 #ifndef _FG_MPS_MESSAGE_HXX
\r
24 #define _FG_MPS_MESSAGE_HXX
\r
26 #include <simgear/compiler.h>
\r
29 #include <stdexcept>
\r
32 SG_USING_STD(string);
\r
33 SG_USING_STD(invalid_argument);
\r
36 #include "messagebuf.hxx"
\r
44 fgmps_ulonglong = 0xf3,
\r
48 fgmps_longlong = 0xf7,
\r
50 fgmps_double = 0xf9,
\r
51 fgmps_string = 0xfa,
\r
52 fgmps_reserved = 0xfb,
\r
57 } FGMPSMsgElementType;
\r
61 FGMPSMsgElementType type;
\r
63 } FGMPSMsgElementEntry;
\r
65 #define FGMPSMsgElementArrayEnd {fgmps_null, 0}
\r
69 typedef FGMPSMessage* FGMPSMessagePtr;
\r
70 typedef FGMPSMessagePtr (*FGMPSMsgInstanceFunc)(void);
\r
72 typedef map<unsigned int, FGMPSMsgInstanceFunc> FGMPSInstanceFuncMap;
\r
77 static FGMPSInstanceFuncMap funcmap;
\r
78 FGMPSMsgElementEntry elements[1];
\r
80 FGMPSMessageBuf buf;
\r
83 static int registermsg(int msgid, FGMPSMsgInstanceFunc func)
\r
85 funcmap[msgid] = func;
\r
92 static FGMPSMessage* decodemsg(string msg);
\r
93 unsigned int getmessageid() { return msgid; }
\r
95 virtual FGMPSMsgElementEntry* getelements() { return elements; }
\r