YSTest: YMessageDefinition.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

YMessageDefinition.h
浏览该文件的文档.
1 /*
2 © 2009-2013, 2019 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_YMessageDefinition_h_
29 #define YSL_INC_Core_YMessageDefinition_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YMessage // for shared_ptr, pair, function;
33
34 namespace YSLib
35 {
36
37 namespace Messaging
38 {
39
40 using MessageID = enum MessageSpace
41 {
42 Null = 0x0000,
43 Set = 0x0003,
44
45 Quit = 0x0012,
47 Bound = 0x0014,
48 Task = 0x0016,
49
50 Paint = 0x00AF,
51
52 Input = 0x00FF
53 };
54
55
57
58 #define SM_Null YSLib::Messaging::Null
59 #define SM_Set YSLib::Messaging::Set
60
61 #define SM_Quit YSLib::Messaging::Quit
62 #define SM_Bound YSLib::Messaging::Bound
63 #define SM_Task YSLib::Messaging::Task
64
65 #define SM_Paint YSLib::Messaging::Paint
66 #define SM_Input YSLib::Messaging::Input
67
68
69
70 template<MessageID _vID>
71 struct SMessageMap
72 {};
73
74 #define DefMessageTarget(_id, _type) \
75 template<> \
76 struct SMessageMap<_id> \
77 { \
78 using TargetType = _type; \
79 };
80
82
83 DefMessageTarget(SM_Null, void)
84 DefMessageTarget(SM_Set, shared_ptr<Shell>)
85 DefMessageTarget(SM_Quit, int)
86 DefMessageTarget(SM_Bound, pair<weak_ptr<Shell> YPP_Comma Message>)
87 DefMessageTarget(SM_Task, function<void()>)
88 DefMessageTarget(SM_Input, void)
90
91
92 template<MessageID _vID>
93 inline const typename SMessageMap<_vID>::TargetType&
94 FetchTarget(const Message& msg)
95 {
96 return msg.GetContent().GetObject<typename SMessageMap<_vID>::TargetType>();
97 }
98
99 } // namespace Messaging;
100
101 } // namespace YSLib;
102
103 #endif
104
SM_Input
#define SM_Input
Definition: YMessageDefinition.h:66
CHRLib::CharSet::Null
@ Null
空字符集。
Definition: Encoding.h:63
SM_Quit
#define SM_Quit
Definition: YMessageDefinition.h:61
YPP_Comma
#define YPP_Comma
替换为逗号的预处理记号。
Definition: ydef.h:370
SM_Task
#define SM_Task
Definition: YMessageDefinition.h:63
YSLib::Messaging::SMessageMap
Definition: YMessageDefinition.h:72
YSLib::Messaging::SMessageMap< YSLib::Messaging::Input >::TargetType
void TargetType
Definition: YMessageDefinition.h:88
YSLib::Shells::Shell
外壳程序：实现运行期控制流映像语义。
Definition: YShell.h:42
SM_Bound
#define SM_Bound
Definition: YMessageDefinition.h:62
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
YModules.h
YSLib 用户界面模块配置文件。
SM_Set
#define SM_Set
Definition: YMessageDefinition.h:59
SM_Null
#define SM_Null
Definition: YMessageDefinition.h:58
ystdex::function
function_base< function_traits< _fSig, empty_function_policy::throwing >, _fSig > function
函数包装类模板。
Definition: function.hpp:900
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
YSLib::Messaging::FetchTarget
const SMessageMap< _vID >::TargetType & FetchTarget(const Message &msg)
Definition: YMessageDefinition.h:94
DefMessageTarget
#define DefMessageTarget(_id, _type)
Definition: YMessageDefinition.h:74
YSLib::UI::Paint
@ Paint
界面绘制。
Definition: YWidgetEvent.h:427
YSLib::Messaging::MessageID
enum MessageSpace { Null=0x0000, Set=0x0003, Quit=0x0012, Bound=0x0014, Task=0x0016, Paint=0x00AF, Input=0x00FF } MessageID
Definition: YMessageDefinition.h:53
YSLib::Messaging::Message
消息。
Definition: YMessage.h:67