YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ymsgdef.h
浏览该文件的文档.
1 /*
2  © 2009-2013 FrankHB.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #ifndef YSL_INC_CORE_ymsgdef_h_
29 #define YSL_INC_CORE_ymsgdef_h_ 1
30 
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YMessage
33 #include <functional> // for std::function;
34 
35 namespace YSLib
36 {
37 
38 namespace Messaging
39 {
40 
41 using MessageID = enum MessageSpace
42 {
43  Null = 0x0000,
44  Set = 0x0003,
45 
46  Quit = 0x0012,
48  Bound = 0x0014,
49  Task = 0x0016,
50 
51  Paint = 0x00AF,
52 
53  Input = 0x00FF
54 };
55 
56 
58 
59 #define SM_Null YSLib::Messaging::Null
60 #define SM_Set YSLib::Messaging::Set
61 
62 #define SM_Quit YSLib::Messaging::Quit
63 #define SM_Bound YSLib::Messaging::Bound
64 #define SM_Task YSLib::Messaging::Task
65 
66 #define SM_Paint YSLib::Messaging::Paint
67 #define SM_Input YSLib::Messaging::Input
68 
69 
70 
71 template<MessageID _vID>
73 {};
74 
75 #define DefMessageTarget(_id, _type) \
76  template<> \
77  struct SMessageMap<_id> \
78  { \
79  using TargetType = _type; \
80  };
81 
83 
85 DefMessageTarget(SM_Set, shared_ptr<Shell>)
87 DefMessageTarget(SM_Bound, pair<weak_ptr<Shell> YPP_Comma Message>)
88 DefMessageTarget(SM_Task, std::function<void()>)
91 
92 
93 template<MessageID _vID>
94 inline const typename SMessageMap<_vID>::TargetType&
95 FetchTarget(const Message& msg)
96 {
97  return msg.GetContent().GetObject<typename SMessageMap<_vID>::TargetType>();
98 }
99 
100 } // namespace Messaging;
101 
102 } // namespace YSLib;
103 
104 #endif
105 
#define SM_Set
Definition: ymsgdef.h:60
#define DefMessageTarget(_id, _type)
Definition: ymsgdef.h:75
enum MessageSpace{Null=0x0000, Set=0x0003, Quit=0x0012, Bound=0x0014, Task=0x0016, Paint=0x00AF, Input=0x00FF} MessageID
Definition: ymsgdef.h:54
#define YPP_Comma
替换为逗号的预处理记号。
Definition: ydef.h:147
const SMessageMap< _vID >::TargetType & FetchTarget(const Message &msg)
Definition: ymsgdef.h:95
#define SM_Quit
Definition: ymsgdef.h:62
#define SM_Task
Definition: ymsgdef.h:64
#define SM_Null
Definition: ymsgdef.h:59
#define SM_Input
Definition: ymsgdef.h:67
#define SM_Bound
Definition: ymsgdef.h:63
空字符集。
Definition: encoding.h:56