1 /* 2 * barrier -- mouse and keyboard sharing utility 3 * Copyright (C) 2012-2016 Symless Ltd. 4 * Copyright (C) 2002 Chris Schoeneman 5 * 6 * This package is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * found in the file LICENSE that should have accompanied this file. 9 * 10 * This package is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #pragma once 20 21 #include "barrier/IAppUtil.h" 22 #include "barrier/XBarrier.h" 23 24 class AppUtil : public IAppUtil { 25 public: 26 AppUtil(); 27 virtual ~AppUtil(); 28 29 virtual void adoptApp(IApp* app); 30 IApp& app() const; exitApp(int code)31 virtual void exitApp(int code) { throw XExitApp(code); } 32 33 static AppUtil& instance(); exitAppStatic(int code)34 static void exitAppStatic(int code) { instance().exitApp(code); } beforeAppExit()35 virtual void beforeAppExit() {} 36 37 private: 38 IApp* m_app; 39 static AppUtil* s_instance; 40 }; 41