]> git.mxchange.org Git - flightgear.git/blob - src/Server/message.hxx
Multiplayer client/server system -- MessageBuf class and test harness complete
[flightgear.git] / src / Server / message.hxx
1 // message.hxx -- Multiplayer Client/Server message base class\r
2 //\r
3 // Written by John Barrett, started November 2003.\r
4 //\r
5 // Copyright (C) 2003  John R. Barrett - jbarrett@accesshosting.com\r
6 //\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
11 //\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
16 //\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
20 //\r
21 \r
22 \r
23 #ifndef _FG_MPS_MESSAGE_HXX\r
24 #define _FG_MPS_MESSAGE_HXX\r
25 \r
26 #include <simgear/compiler.h>\r
27 \r
28 #include STL_STRING\r
29 #include <stdexcept>\r
30 \r
31 SG_USING_STD(string);\r
32 SG_USING_STD(invalid_argument);\r
33 \r
34 #include "messagebuf.hxx"\r
35 \r
36 typedef enum \r
37 {\r
38         fgmps_null      = 0x00,\r
39         fgmps_uchar     = 0xf0,\r
40         fgmps_uint      = 0xf1,\r
41         fgmps_ulong     = 0xf2,\r
42         fgmps_ulonglong = 0xf3,\r
43         fgmps_char      = 0xf4,\r
44         fgmps_int       = 0xf5,\r
45         fgmps_long      = 0xf6,\r
46         fgmps_longlong  = 0xf7,\r
47         fgmps_float     = 0xf8,\r
48         fgmps_double    = 0xf9,\r
49         fgmps_string    = 0xfa,\r
50         fgmps_reserved  = 0xfb,\r
51         fgmps_eom       = 0xfc,\r
52         fgmps_som8      = 0xfd,\r
53         fgmps_som16     = 0xfe,\r
54         fgmps_esc       = 0xfe\r
55 } FGMPSMsgElementType;\r
56 \r
57 typedef struct \r
58 {\r
59         FGMPSMsgElementType     type;\r
60         void *                  data;\r
61 } FGMPSMsgElementEntry;\r
62 \r
63 #define FGMPSMsgElementArrayEnd {fgmps_null, 0}\r
64 \r
65 class FGMPSMessage\r
66 {\r
67 private:\r
68         FGMPSMsgElementEntry            elements[1];\r
69         static unsigned int             msgid;\r
70 protected:\r
71         FGMPSMessageBuf                 msg;\r
72 public:\r
73         FGMPSMessage();\r
74         ~FGMPSMessage() {}\r
75 \r
76         virtual string                  encodemsg() {}\r
77         virtual FGMPSMessage*           decodemsg(string msg) {}\r
78         virtual FGMPSMsgElementEntry*   getelements() { return elements; }\r
79         virtual unsigned int            getmessageid() { return msgid; }\r
80 \r
81 };\r
82 \r
83 #endif\r