1/*
2 * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#ifndef APPLICATION_H
24#define APPLICATION_H
25
26#include <framework/global.h>
27
28//@bindsingleton g_app
29class Application
30{
31public:
32 Application();
33 virtual ~Application() {}
34
35 virtual void init(std::vector<std::string>& args);
36 virtual void deinit();
37 virtual void terminate();
38 virtual void run() = 0;
39 virtual void poll();
40 virtual void exit();
41 virtual void quick_exit();
42 virtual void close();
43 void restart();
44 void restartArgs(const std::vector<std::string>& args);
45
46 void setName(const std::string& name) { m_appName = name; }
47 void setCompactName(const std::string& compactName) { m_appCompactName = compactName; }
48 void setVersion(const std::string& version) { m_appVersion = version; }
49
50 bool isRunning() { return m_running; }
51 bool isStopping() { return m_stopping; }
52 bool isTerminated() { return m_terminated; }
53 const std::string& getName() { return m_appName; }
54 const std::string& getCompactName() { return m_appCompactName; }
55 const std::string& getVersion() { return m_appVersion; }
56
57 std::string getCharset() { return m_charset; }
58 std::string getBuildCompiler() { return BUILD_COMPILER; }
59 std::string getBuildDate() { return std::string(__DATE__); }
60 std::string getBuildRevision() { return std::to_string(BUILD_REVISION); }
61 std::string getBuildCommit() { return BUILD_COMMIT; }
62#ifdef FREE_VERSION
63 std::string getBuildType() { return "FREE"; }
64#else
65 std::string getBuildType() { return "FULL"; }
66#endif
67 std::string getBuildArch() { return BUILD_ARCH; }
68 std::string getAuthor() { return "otclient.net"; }
69 std::string getOs();
70 std::string getStartupOptions() { return m_startupOptions; }
71
72 bool isMobile()
73 {
74 return m_mobile;
75 }
76
77protected:
78 void registerLuaFunctions();
79
80 std::string m_charset;
81 std::string m_appName;
82 std::string m_appCompactName;
83 std::string m_appVersion;
84 std::string m_startupOptions;
85 stdext::boolean<false> m_running;
86 stdext::boolean<false> m_stopping;
87 stdext::boolean<false> m_terminated;
88 stdext::boolean<false> m_mobile;
89};
90
91#ifdef FW_GRAPHICS
92#include "graphicalapplication.h"
93#else
94#include "consoleapplication.h"
95#endif
96
97#endif
98