]>
vaikene.ee Git - evaf/blob - src/libs/Common/iapp.h
3 * @brief eVaf application interface
6 * Copyright (c) 2011 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 * Requests the eVaf application to restart.
135 * This function requests the eVaf application to restart itself. Restarting the application
136 * reloads all the plugins and re-initializes them.
138 virtual void restart() = 0;
141 * Requests the eVaf application to quit.
142 * @param err If true, then indicates that the application exits due to a fatal error
144 * This function requests the eVaf application to quit.
146 virtual void quit(bool err
= false) = 0;
149 * Returns true if the eVaf application is ready.
151 virtual bool isReady() const = 0;
154 * Returns the name of the eVaf root directory
156 * The root directory is the base directory where the eVaf application is installed. The default root
157 * directory is the parent of the binary directory.
159 * Write access to the root directory is not required to run the application.
161 * This directory can be changed with the EVAF_ROOT_DIR environment variable or with the -root[dir]=<directory>
162 * command line argument.
164 virtual QString
const rootDir() const = 0;
167 * Returns the name of the eVaf data directory.
169 * The data root directory is the base directory for all the directories that require write access.
171 * The default data directory on Windows is \%APPDATA\%/\%EVAF_APP_NAME\%. The default data directory
172 * on Linux is ${HOME}/.${EVAF_APP_NAME}.
174 * This directory can be changed with the EVAF_DATA_ROOT_DIR environment variable or with the
175 * -dataroot[dir]=<directory> command line argument.
177 virtual QString
const dataRootDir() const = 0;
180 * Returns the name of the binary files directory.
182 * The binary directory is the directory where all the application's binary files (main executable and
183 * modules) are located. The default binary directory is where the main executable is located.
185 * NB! Changing the application's root directory does not change the location of the binary directory.
187 virtual QString
const binDir() const = 0;
190 * Returns the configuration files directory.
192 * This is the directory where all the application's configuration files are located. The default
193 * configuration files directory is 'etc' in the data root directory.
195 * This directory can be changed with the EVAF_ETC_DIR environment variable or with the -etc[dir]=<directory>
196 * command line argument.
198 virtual QString
const etcDir() const = 0;
201 * Returns the log files directory.
203 * This is the directory where the application outputs all the log files. The default log files
204 * directory is 'log' in the data root directory.
206 * This directory can be changed with the EVAF_LOG_DIR environment variable or with the
207 * -log[dir]=<directory> command line argument.
209 virtual QString
const logDir() const = 0;
212 * Returns the documentation directory.
214 * This is the directory where all the documentation and help files are located. The default
215 * documentation directory is 'doc' in the root directory.
217 * This directory can be changed with the EVAF_DOC_DIR environment variable or with the
218 * -doc[dir]=<directory> command line argument.
220 virtual QString
const docDir() const = 0;
223 * Returns the Qt plugins directory.
225 * The Qt plugins directory is where additional Qt plugins are located. These Qt plugins
226 * are loaded manually by the application and specified in the application's XML file.
228 * Changing this directory does not affect the way how Qt itself loads its plugins.
230 * This directory can be changed with the EVAF_QT_PLUGINS_DIR environment variable or with the
231 * -qtplugins[dir]=<directory> command line argument.
233 virtual QString
const qtPluginsDir() const = 0;
241 * This signal is emitted when the eVaf application is ready, ie the application initialized and all the
247 * Terminating signal.
249 * This signal is emitted when the eVaf application is about to terminate.
255 } // namespace eVaf::Common