YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
yshell.cpp
浏览该文件的文档.
1 /*
2  © 2009-2014 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
48 {
49  // NOTE: %get_raw used here for performance.
50  return get_raw(FetchAppInstance().GetShellHandle()) == this;
51 }
52 
53 void
55 {
56  switch(msg.GetMessageID())
57  {
58  case SM_Set:
59  {
60  auto h(FetchTarget<SM_Set>(msg));
61 
63  }
64  break;
65  case SM_Quit:
66  std::exit(FetchTarget<SM_Quit>(msg));
67  case SM_Bound:
68  {
69  const auto& pr(FetchTarget<SM_Bound>(msg));
70  const auto h_shl(pr.first.lock());
71 
72  if(YB_LIKELY(h_shl))
73  h_shl->OnGotMessage(pr.second);
74  }
75  break;
76  case SM_Task:
77  FetchTarget<SM_Task>(msg)();
78  default:
79  break;
80  }
81 }
82 
83 } // namespace Shells;
84 
85 } // namespace YSLib;
86 
YF_API Application & FetchAppInstance() ynothrow
取应用程序实例。
#define SM_Set
Definition: ymsgdef.h:60
static void DefShlProc(const Message &)
默认 Shell 处理函数。
Definition: yshell.cpp:54
#define SM_Quit
Definition: ymsgdef.h:62
_type * get_raw(_type *const &p)
Definition: memory.hpp:45
#define SM_Task
Definition: ymsgdef.h:64
bool IsActive() const
判断 Shell 是否处于激活状态。
Definition: yshell.cpp:47
#define SM_Bound
Definition: ymsgdef.h:63
#define YB_LIKELY(expr)
Definition: ydef.h:297
bool Switch(shared_ptr< Shell > &) ynothrow
线程切换:若参数非空,和线程空间中当前运行的 Shell 的句柄交换。
Definition: yapp.cpp:63