Otclient  14/8/2020
application.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 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>
28 
29 //@bindsingleton g_app
31 {
32 public:
33  Application();
34  virtual ~Application() {}
35 
36  virtual void init(std::vector<std::string>& args);
37  virtual void deinit();
38  virtual void terminate();
39  virtual void run() = 0;
40  virtual void poll();
41  virtual void exit();
42  virtual void close();
43 
44  void setName(const std::string& name) { m_appName = name; }
45  void setCompactName(const std::string& compactName) { m_appCompactName = compactName; }
46  void setVersion(const std::string& version) { m_appVersion = version; }
47 
48  bool isRunning() { return m_running; }
49  bool isStopping() { return m_stopping; }
50  bool isTerminated() { return m_terminated; }
51  const std::string& getName() { return m_appName; }
52  const std::string& getCompactName() { return m_appCompactName; }
53  const std::string& getVersion() { return m_appVersion; }
54 
55  std::string getCharset() { return m_charset; }
56  std::string getBuildCompiler() { return BUILD_COMPILER; }
57  std::string getBuildDate() { return std::string(__DATE__); }
58  std::string getBuildRevision() { return BUILD_REVISION; }
59  std::string getBuildCommit() { return BUILD_COMMIT; }
60  std::string getBuildType() { return BUILD_TYPE; }
61  std::string getBuildArch() { return BUILD_ARCH; }
62  std::string getOs();
63  std::string getStartupOptions() { return m_startupOptions; }
64 
65 protected:
66  void registerLuaFunctions();
67 
68  std::string m_charset;
69  std::string m_appName;
70  std::string m_appCompactName;
71  std::string m_appVersion;
72  std::string m_startupOptions;
76 };
77 
78 #ifdef FW_GRAPHICS
79 #include "graphicalapplication.h"
80 #else
81 #include "consoleapplication.h"
82 #endif
83 
84 #endif
Application::terminate
virtual void terminate()
Definition: application.cpp:124
Application::Application
Application()
Definition: application.cpp:55
Application::getBuildRevision
std::string getBuildRevision()
Definition: application.h:58
Application::getBuildCompiler
std::string getBuildCompiler()
Definition: application.h:56
Application::getCompactName
const std::string & getCompactName()
Definition: application.h:52
Application::isStopping
bool isStopping()
Definition: application.h:49
Application::m_running
stdext::boolean< false > m_running
Definition: application.h:73
Application::m_startupOptions
std::string m_startupOptions
Definition: application.h:72
stdext::boolean< false >
Application::getBuildArch
std::string getBuildArch()
Definition: application.h:61
Application::setVersion
void setVersion(const std::string &version)
Definition: application.h:46
Application::getStartupOptions
std::string getStartupOptions()
Definition: application.h:63
BUILD_ARCH
#define BUILD_ARCH
Definition: const.h:49
Application::deinit
virtual void deinit()
Definition: application.cpp:104
Application::poll
virtual void poll()
Definition: application.cpp:146
adaptativeframecounter.h
Application::getName
const std::string & getName()
Definition: application.h:51
Application::getBuildDate
std::string getBuildDate()
Definition: application.h:57
Application::setCompactName
void setCompactName(const std::string &compactName)
Definition: application.h:45
BUILD_TYPE
#define BUILD_TYPE
Definition: const.h:40
Application::getCharset
std::string getCharset()
Definition: application.h:55
Application::getBuildType
std::string getBuildType()
Definition: application.h:60
BUILD_REVISION
#define BUILD_REVISION
Definition: const.h:36
Application::isRunning
bool isRunning()
Definition: application.h:48
graphicalapplication.h
Application::close
virtual void close()
Definition: application.cpp:166
Application
Definition: application.h:30
Application::getOs
std::string getOs()
Definition: application.cpp:172
Application::run
virtual void run()=0
Application::m_charset
std::string m_charset
Definition: application.h:68
Application::isTerminated
bool isTerminated()
Definition: application.h:50
Application::getBuildCommit
std::string getBuildCommit()
Definition: application.h:59
Application::exit
virtual void exit()
Definition: application.cpp:160
Application::init
virtual void init(std::vector< std::string > &args)
Definition: application.cpp:64
BUILD_COMMIT
#define BUILD_COMMIT
Definition: const.h:32
Application::m_stopping
stdext::boolean< false > m_stopping
Definition: application.h:74
Application::m_appCompactName
std::string m_appCompactName
Definition: application.h:70
global.h
Application::setName
void setName(const std::string &name)
Definition: application.h:44
Application::m_terminated
stdext::boolean< false > m_terminated
Definition: application.h:75
consoleapplication.h
Application::~Application
virtual ~Application()
Definition: application.h:34
Application::registerLuaFunctions
void registerLuaFunctions()
Definition: luafunctions.cpp:64
Application::m_appName
std::string m_appName
Definition: application.h:69
Application::m_appVersion
std::string m_appVersion
Definition: application.h:71
Application::getVersion
const std::string & getVersion()
Definition: application.h:53