Line data Source code
1 : /* Copyright (C) 2009 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #include "precompiled.h"
19 :
20 : #include "Messages.h"
21 : #include "Handlers/MessageHandler.h"
22 : #include "CommandProc.h"
23 :
24 : // We want to include Messages.h again below, with some different definitions,
25 : // so cheat and undefine its include-guard
26 : #undef INCLUDED_MESSAGES
27 :
28 : #include <map>
29 : #include <string>
30 :
31 : #include "SharedTypes.h"
32 : #include "Shareable.h"
33 :
34 : #include <map>
35 : #include <string>
36 :
37 : namespace AtlasMessage
38 : {
39 :
40 : #define MESSAGE(name, vals) \
41 : extern void f##name##_wrapper(AtlasMessage::IMessage*); \
42 : AtlasMessage::GetMsgHandlers().insert(std::pair<std::string, AtlasMessage::msgHandler>(#name, &f##name##_wrapper));
43 :
44 : #define QUERY(name, in_vals, out_vals) \
45 : extern void f##name##_wrapper(AtlasMessage::IMessage*); \
46 : AtlasMessage::GetMsgHandlers().insert(std::pair<std::string, AtlasMessage::msgHandler>(#name, &f##name##_wrapper));
47 :
48 : #define COMMAND(name, merge, vals) \
49 : extern cmdHandler c##name##_create(); \
50 : GetCmdHandlers().insert(std::pair<std::string, cmdHandler>("c"#name, c##name##_create()));
51 :
52 : #undef SHAREABLE_STRUCT
53 : #define SHAREABLE_STRUCT(name)
54 :
55 0 : void RegisterHandlers()
56 : {
57 0 : MESSAGE(DoCommand, );
58 0 : MESSAGE(UndoCommand, );
59 0 : MESSAGE(RedoCommand, );
60 0 : MESSAGE(MergeCommand, );
61 :
62 : #define MESSAGES_SKIP_SETUP
63 : #include "Messages.h"
64 0 : }
65 :
66 : }
|