YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
yapp.cpp
浏览该文件的文档.
1 /*
2  Copyright by FrankHB 2009 - 2013.
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/yapp.h"
29 
31 
32 Application::Application()
33  : Shell(), Queue(), hShell()
34 {}
36 {
37  // Note: It is necessary to cleanup to make sure all shells are destroyed.
38  Queue.Clear();
39 // hShell = nullptr;
40  // NOTE: All shells must have been released.
41  YAssert(!hShell, "Active shell found.");
42 
43  if(ApplicationExit)
45 }
46 
47 void
48 Application::OnGotMessage(const Message& msg)
49 {
50  const auto hShl(GetShellHandle());
51 
52  YAssert(bool(hShl), "Null handle found.");
53 
54  hShl->OnGotMessage(msg);
55 }
56 
57 bool
58 Application::Switch(shared_ptr<Shell>& h) ynothrow
59 {
60  if(YB_LIKELY(hShell != h))
61  {
62  std::swap(hShell, h);
63  return true;
64  }
65  return false;
66 }
67 
68 
69 void
70 PostMessage(const Message& msg, Messaging::Priority prior) ynothrow
71 {
72  FetchAppInstance().Queue.Push(msg, prior);
73 }
74 
75 void
76 PostQuitMessage(int nExitCode, Messaging::Priority prior)
77 {
78  PostMessage<SM_SET>(prior, shared_ptr<Shell>());
79  PostMessage<SM_QUIT>(prior, nExitCode);
80 }
81 
82 YSL_END
83