]>
vaikene.ee Git - evaf/blob - iapp.h
5a61edab0568af268a5252d50b73eb185f58b5ab
3 * @brief eVaf application interface
6 * Copyright (c) 2011-2019 Enar Vaikene
8 * This file is part of the eVaf C++ cross-platform application development framework.
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.
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
20 #ifndef __COMMON_IAPP_H
21 #define __COMMON_IAPP_H
23 #include "libcommon.h"
32 * eVaf application interface
33 * @code#include <Common/iApp>@endcode
35 * The iApp interface provides information about current eVaf application. Functions in this interface return
36 * the name of the application, names of directories where different recources are located etc. Modules should
37 * always use the iApp interface for directory names and locations.
39 * For example, all the configuration files should be located in the eVaf::Common::iApp::instance()->etcDir() directory.
41 * Directory names returned by functions in this interface are UNIX path names and they are quaranteed to
42 * end with the '/' character.
44 * All the resources returned by this interface have default values, that should work in most of the cases.
45 * Fox example, the binary directory is set to the same directory where the application's main executable is found.
46 * The root directory is the parent of the binary directory etc.
48 * Default values can be overwritten with environment variables and command line arguments. If both are used,
49 * then command line arguments have higher priorities.
51 class COMMON_EXPORT iApp
: public QObject
57 /// Application return values
59 RC_Quit
= 0, ///< Normal exit
60 RC_Error
= 1, ///< Exit due to an error
61 RC_Restart
= 2 ///< The application is restarting
64 /// Event that requests the eVaf application to quit
65 static char const * const EV_QUIT
;
67 /// Event that requests the eVaf application to restart
68 static char const * const EV_RESTART
;
70 /// Event informing that the eVaf application is ready
71 static char const * const EV_READY
;
73 /// Event informing that the eVaf application is restarting
74 static char const * const EV_TERMINATING
;
76 /// Interface constructor
79 /// Empty virtual destructor
83 * Returns the iApp interface instance
84 * @return The iApp interface
86 * This function returns the global iApp interface instance. As all the eVaf modules and applications
87 * are expected to be linked against the common library, then this is the preferred method of obtaining
88 * the iApp interface. The other method is by using the iRegistry interface.
90 static iApp
* instance();
93 * Returns the name of the eVaf application
95 * This function returns the name of the eVaf application, which is a string that identifies the application.
96 * The default name of the application is "eVaf".
98 * This name of the application can be changed with the EVAF_APP_NAME environment variable or with the
99 * -app[lication]=<name> command line argument.
101 virtual QString
const name() const = 0;
104 * Returns the current language and country used by the application.
106 * This function returns the current lowercase two-letter ISO 639 language code and uppercase
107 * two-letter ISO 3166 country code if set.
109 * The default language is queried from the operating system.
111 * The language can be changed with the EVAF_LANGUAGE environment variabel or with the
112 * -lang[uage]=<language> command line argument.
114 virtual QString
const language() const = 0;
117 * Returns the name of the application's XML file.
119 * This function returns the name of the application's XML file.
120 * It tries to find the most specific file name for the given language. If not found, then
121 * defaults to the generic name.
123 * For example, if the language is set to "et_EE" and the application's name is "eVaf", then
124 * it tries to find XML files with the following names "eVaf_et_EE.xml" and "eVaf_et.xml". If
125 * neither is found, defaults to the name "eVaf.xml".
127 * The path is not included in the returned file name. Use the eVaf::Common::iEnv::etcDir() function
128 * for the location of the file.
130 virtual QString
const xmlFileName() const = 0;
133 * Enters the main event loop of the Qt application.
134 * @return Value returned by the Qt application
136 * This function enters the event loop of the Qt application. Use this function to start event handling
137 * instead of calling QCoreApplication::exec() or QApplication::exec() functions directly.
139 virtual int exec() = 0;
142 * Requests the eVaf application to restart.
144 * This function requests the eVaf application to restart itself. Restarting the application
145 * reloads all the plugins and re-initializes them.
147 virtual void restart() = 0;
150 * Requests the eVaf application to quit.
151 * @param err If true, then indicates that the application exits due to a fatal error
153 * This function requests the eVaf application to quit.
155 virtual void quit(bool err
= false) = 0;
158 * Returns true if the eVaf application is ready.
160 virtual bool isReady() const = 0;
163 * Returns the name of the eVaf root directory
165 * The root directory is the base directory where the eVaf application is installed. The default root
166 * directory is the parent of the binary directory.
168 * Write access to the root directory is not required to run the application.
170 * This directory can be changed with the EVAF_ROOT_DIR environment variable or with the -root[dir]=<directory>
171 * command line argument.
173 virtual QString
const rootDir() const = 0;
176 * Returns the name of the eVaf data directory.
178 * The data root directory is the base directory for all the directories that require write access.
180 * The default data directory on Windows is \%APPDATA\%/\%EVAF_APP_NAME\%. The default data directory
181 * on Linux is ${HOME}/.${EVAF_APP_NAME}.
183 * This directory can be changed with the EVAF_DATA_ROOT_DIR environment variable or with the
184 * -dataroot[dir]=<directory> command line argument.
186 virtual QString
const dataRootDir() const = 0;
189 * Returns the name of the binary files directory.
191 * The binary directory is the directory where all the application's binary files (main executable and
192 * modules) are located. The default binary directory is where the main executable is located.
194 * NB! Changing the application's root directory does not change the location of the binary directory.
196 virtual QString
const binDir() const = 0;
199 * Returns the configuration files directory.
201 * This is the directory where all the application's configuration files are located. The default
202 * configuration files directory is 'etc' in the data root directory.
204 * This directory can be changed with the EVAF_ETC_DIR environment variable or with the -etc[dir]=<directory>
205 * command line argument.
207 virtual QString
const etcDir() const = 0;
210 * Returns the log files directory.
212 * This is the directory where the application outputs all the log files. The default log files
213 * directory is 'log' in the data root directory.
215 * This directory can be changed with the EVAF_LOG_DIR environment variable or with the
216 * -log[dir]=<directory> command line argument.
218 virtual QString
const logDir() const = 0;
221 * Returns the documentation directory.
223 * This is the directory where all the documentation and help files are located. The default
224 * documentation directory is 'doc' in the root directory.
226 * This directory can be changed with the EVAF_DOC_DIR environment variable or with the
227 * -doc[dir]=<directory> command line argument.
229 virtual QString
const docDir() const = 0;
232 * Returns the Qt plugins directory.
234 * The Qt plugins directory is where additional Qt plugins are located. These Qt plugins
235 * are loaded manually by the application and specified in the application's XML file.
237 * Changing this directory does not affect the way how Qt itself loads its plugins.
239 * This directory can be changed with the EVAF_QT_PLUGINS_DIR environment variable or with the
240 * -qtplugins[dir]=<directory> command line argument.
242 virtual QString
const qtPluginsDir() const = 0;
250 * This signal is emitted when the eVaf application is ready, ie the application initialized and all the
256 * Terminating signal.
258 * This signal is emitted when the eVaf application is about to terminate.
264 } // namespace eVaf::Common