ConsoleHost.h
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 #pragma once 6 7 #include <Windows.h> 8 #include "ModuleLoader.h" 9 #include "HotkeyManager.h" 10 11 /// <summary> 12 /// Console host that runs the message loop and handles Ctrl+C 13 /// </summary> 14 class ConsoleHost 15 { 16 public: 17 ConsoleHost(ModuleLoader& moduleLoader, HotkeyManager& hotkeyManager); 18 ~ConsoleHost(); 19 20 // Prevent copying 21 ConsoleHost(const ConsoleHost&) = delete; 22 ConsoleHost& operator=(const ConsoleHost&) = delete; 23 24 /// <summary> 25 /// Run the message loop until Ctrl+C is pressed 26 /// </summary> 27 void Run(); 28 29 private: 30 ModuleLoader& m_moduleLoader; 31 HotkeyManager& m_hotkeyManager; 32 static bool s_exitRequested; 33 34 /// <summary> 35 /// Console control handler (for Ctrl+C) 36 /// </summary> 37 static BOOL WINAPI ConsoleCtrlHandler(DWORD ctrlType); 38 };