YSTest: YShell.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

YShell.cpp
浏览该文件的文档.
1 /*
2 © 2009-2015 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 #include "YSLib/Core/YModules.h"
29 #include YFM_YSLib_Core_YShell
30 #include YFM_YSLib_Core_YApplication
31
32 namespace YSLib
33 {
34
35 namespace Shells
36 {
37
38 using namespace Messaging;
39
40 Shell::~Shell()
41 {
42 // TODO: Reconsider of using weak pointer in messages.
43 // FetchAppInstance().Queue.Remove(this, 0xFF);
44 }
45
46 bool
47 Shell::IsActive() const
48 {
49 // NOTE: %get_raw used here for performance.
50 return get_raw(FetchAppInstance().GetShellHandle()) == this;
51 }
52
53 void
54 Shell::DefShlProc(const Message& msg)
55 {
56 switch(msg.GetMessageID())
57 {
58 case SM_Set:
59 {
60 auto h(FetchTarget<SM_Set>(msg));
61
62 FetchAppInstance().Switch(h);
63 }
64 break;
65 case SM_Quit:
66 YTraceDe(Notice, "Quit message handled.");
67 std::exit(FetchTarget<SM_Quit>(msg));
68 case SM_Bound:
69 {
70 const auto& pr(FetchTarget<SM_Bound>(msg));
71 const auto h_shl(pr.first.lock());
72
73 if(YB_LIKELY(h_shl))
74 h_shl->OnGotMessage(pr.second);
75 }
76 break;
77 case SM_Task:
78 FetchTarget<SM_Task>(msg)();
79 default:
80 break;
81 }
82 }
83
84 } // namespace Shells;
85
86 } // namespace YSLib;
87
YSLib::Application::Switch
bool Switch(shared_ptr< Shell > &) ynothrow
线程切换：若参数非空，和线程空间中当前运行的 Shell 的句柄交换。
Definition: YApplication.cpp:65
YModules.h
Shells
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::Shells::Shell::DefShlProc
static void DefShlProc(const Message &)
默认 Shell 处理函数。
Definition: YShell.cpp:54
ystdex::get_raw
_type * get_raw(_type *const &p)
Definition: memory.hpp:550
SM_Set
#define SM_Set
Definition: ymsgdef.h:60
YTraceDe
#define YTraceDe(...)
YCLib 默认调试跟踪。
Definition: Debug.h:305
SM_Bound
#define SM_Bound
Definition: ymsgdef.h:63
SM_Task
#define SM_Task
Definition: ymsgdef.h:64
SM_Quit
#define SM_Quit
Definition: ymsgdef.h:62
YB_LIKELY
#define YB_LIKELY(_expr)
Definition: ydef.h:437
YSLib::FetchAppInstance
YF_API Application & FetchAppInstance()
取应用程序实例。
Definition: GUIApplication.cpp:295
YSLib::Messaging::Message
消息。
Definition: YMessage.h:65
platform::Descriptions::Notice
Definition: YCommon.h:158
YSLib::Shells::Shell::IsActive
bool IsActive() const
判断 Shell 是否处于激活状态。
Definition: YShell.cpp:47