]> vaikene.ee Git - evaf/blob - src/libs/Common/app.h
Mac OS changes and switched to c++11.
[evaf] / src / libs / Common / app.h
1 /**
2 * @file Common/app.h
3 * @brief Application interface implementation
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011-2019 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __COMMON_APP_H
21 #define __COMMON_APP_H
22
23 #include "iapp.h"
24
25 #include <QObject>
26 #include <QString>
27
28 class QEvent;
29
30 namespace eVaf {
31 namespace Common {
32 namespace Internal {
33
34 /**
35 * iApp application interface implementation
36 */
37 class App : public iApp
38 {
39 Q_OBJECT
40
41 public:
42
43 /**
44 * Destroys the iApp interface instance
45 */
46 static void destroyInstance();
47
48 App();
49
50 virtual ~App();
51
52 /**
53 * Initializes the interface implementation
54 * @return True if ok; false if initialization failed
55 */
56 bool init();
57
58 virtual bool event(QEvent *);
59
60 /*
61 iApp interface
62 */
63 virtual QString const name() const { return mName; }
64
65 virtual QString const language() const { return mLanguage; }
66
67 virtual QString const xmlFileName() const;
68
69 virtual int exec();
70
71 virtual void restart();
72
73 virtual void quit(bool err = false);
74
75 virtual bool isReady() const { return mReady; }
76
77 virtual QString const rootDir() const { return mRootDir; }
78
79 virtual QString const dataRootDir() const;
80
81 virtual QString const binDir() const { return mBinDir; }
82
83 virtual QString const etcDir() const;
84
85 virtual QString const logDir() const;
86
87 virtual QString const docDir() const;
88
89 virtual QString const qtPluginsDir() const;
90
91
92 private: // Members
93
94 /// Flag indicating that the eVaf application is ready
95 bool mReady;
96
97 /// Name of the application
98 QString mName;
99
100 /// Language for the application
101 QString mLanguage;
102
103 /// Name of the application's XML file
104 mutable QString mXmlFile;
105
106 /// Name of the root directry
107 QString mRootDir;
108
109 /// Name of the data root directory
110 mutable QString mDataRootDir;
111
112 /// Name of the binary directory
113 QString mBinDir;
114
115 /// Name of the Qt plugins directory
116 mutable QString mQtPluginsDir;
117
118 /// Name of the configuration files directory
119 mutable QString mEtcDir;
120
121 /// Name of the log files directory
122 mutable QString mLogDir;
123
124 /// Name of the documentation directory
125 mutable QString mDocDir;
126
127 /// Event numbers
128 uint mEvQuit;
129 uint mEvRestart;
130 uint mEvReady;
131 uint mEvTerminating;
132
133
134 private: // Methods
135
136 void setReady(bool value);
137
138 };
139
140 } // namespace eVaf::Common::Internal
141 } // namespace eVaf::Common
142 } // namespace eVaf
143
144 #endif // app.h