YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
yshell.cpp
浏览该文件的文档.
1 /*
2  Copyright (C) by Franksoft 2009 - 2012.
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/yshell.h"
29 #include "YSLib/Core/yapp.h"
30 
32 
33 YSL_BEGIN_NAMESPACE(Shells)
34 
35 using namespace Messaging;
36 
38 {
39  // TODO: Reconsider of using weak pointer in messages.
40 // FetchAppInstance().Queue.Remove(this, 0xFF);
41 }
42 
43 bool
44 Shell::IsActive() const
45 {
46  // NOTE: %raw used here for performance.
47  return raw(FetchAppInstance().GetShellHandle()) == this;
48 }
49 
50 int
51 Shell::DefShlProc(const Message& msg)
52 {
53  switch(msg.GetMessageID())
54  {
55  case SM_SET:
56  {
57  auto h(FetchTarget<SM_SET>(msg));
58 
59  return -!FetchAppInstance().Switch(h);
60  }
61  case SM_QUIT:
62  std::exit(FetchTarget<SM_QUIT>(msg));
63  break;
64  case SM_TASK:
65  FetchTarget<SM_TASK>(msg)();
66  default:
67  break;
68  }
69  return 0;
70 }
71 
72 YSL_END_NAMESPACE(Shells)
73 
74 YSL_END
75