X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;f=src%2Flibs%2FCommon%2Fiapp.h;h=31390e371c35e3565eab991b21f12f750b3b6e82;hb=c8050984a289a6ea98812395313ef37d4c7fd059;hp=55269e1498ae84b885bf3fad1fa0ec7d8229372d;hpb=441d1b38e0900f56891f495a94a08dc8d48e0a32;p=evaf
diff --git a/src/libs/Common/iapp.h b/src/libs/Common/iapp.h
index 55269e1..31390e3 100644
--- a/src/libs/Common/iapp.h
+++ b/src/libs/Common/iapp.h
@@ -32,9 +32,18 @@ namespace Common {
* eVaf application interface
* @code#include @endcode
*
- * The iApp interface provides information about current eVaf application.
+ * The iApp interface provides information about current eVaf application. Functions in this interface return
+ * the name of the application, names of directories where different recources are located etc. Modules should
+ * always use the iApp interface for directory names and locations.
+ *
+ * For example, all the configuration files should be located in the eVaf::Common::iApp::instance()->etcDir() directory.
+ *
+ * Directory names returned by functions in this interface are UNIX path names and they are quaranteed to
+ * end with the '/' character.
*
* All the resources returned by this interface have default values, that should work in most of the cases.
+ * Fox example, the binary directory is set to the same directory where the application's main executable is found.
+ * The root directory is the parent of the binary directory etc.
*
* Default values can be overwritten with environment variables and command line arguments. If both are used,
* then command line arguments have higher priorities.
@@ -45,6 +54,25 @@ class COMMON_EXPORT iApp : public QObject
public:
+ /// Application return values
+ enum {
+ RC_Quit = 0, ///< Normal exit
+ RC_Error = 1, ///< Exit due to an error
+ RC_Restart = 2 ///< The application is restarting
+ };
+
+ /// Event that requests the eVaf application to quit
+ static char const * const EV_QUIT;
+
+ /// Event that requests the eVaf application to restart
+ static char const * const EV_RESTART;
+
+ /// Event informing that the eVaf application is ready
+ static char const * const EV_READY;
+
+ /// Event informing that the eVaf application is restarting
+ static char const * const EV_TERMINATING;
+
/// Interface constructor
iApp() : QObject() {}
@@ -101,6 +129,118 @@ public:
*/
virtual QString const xmlFileName() const = 0;
+ /**
+ * Enters the main event loop of the Qt application.
+ * @return Value returned by the Qt application
+ *
+ * This function enters the event loop of the Qt application. Use this function to start event handling
+ * instead of calling QCoreApplication::exec() or QApplication::exec() functions directly.
+ */
+ virtual int exec() = 0;
+
+ /**
+ * Requests the eVaf application to restart.
+ *
+ * This function requests the eVaf application to restart itself. Restarting the application
+ * reloads all the plugins and re-initializes them.
+ */
+ virtual void restart() = 0;
+
+ /**
+ * Requests the eVaf application to quit.
+ * @param err If true, then indicates that the application exits due to a fatal error
+ *
+ * This function requests the eVaf application to quit.
+ */
+ virtual void quit(bool err = false) = 0;
+
+ /**
+ * Returns true if the eVaf application is ready.
+ */
+ virtual bool isReady() const = 0;
+
+ /**
+ * Returns the name of the eVaf root directory
+ *
+ * The root directory is the base directory where the eVaf application is installed. The default root
+ * directory is the parent of the binary directory.
+ *
+ * Write access to the root directory is not required to run the application.
+ *
+ * This directory can be changed with the EVAF_ROOT_DIR environment variable or with the -root[dir]=<directory>
+ * command line argument.
+ */
+ virtual QString const rootDir() const = 0;
+
+ /**
+ * Returns the name of the eVaf data directory.
+ *
+ * The data root directory is the base directory for all the directories that require write access.
+ *
+ * The default data directory on Windows is \%APPDATA\%/\%EVAF_APP_NAME\%. The default data directory
+ * on Linux is ${HOME}/.${EVAF_APP_NAME}.
+ *
+ * This directory can be changed with the EVAF_DATA_ROOT_DIR environment variable or with the
+ * -dataroot[dir]=<directory> command line argument.
+ */
+ virtual QString const dataRootDir() const = 0;
+
+ /**
+ * Returns the name of the binary files directory.
+ *
+ * The binary directory is the directory where all the application's binary files (main executable and
+ * modules) are located. The default binary directory is where the main executable is located.
+ *
+ * NB! Changing the application's root directory does not change the location of the binary directory.
+ */
+ virtual QString const binDir() const = 0;
+
+ /**
+ * Returns the configuration files directory.
+ *
+ * This is the directory where all the application's configuration files are located. The default
+ * configuration files directory is 'etc' in the data root directory.
+ *
+ * This directory can be changed with the EVAF_ETC_DIR environment variable or with the -etc[dir]=<directory>
+ * command line argument.
+ */
+ virtual QString const etcDir() const = 0;
+
+ /**
+ * Returns the log files directory.
+ *
+ * This is the directory where the application outputs all the log files. The default log files
+ * directory is 'log' in the data root directory.
+ *
+ * This directory can be changed with the EVAF_LOG_DIR environment variable or with the
+ * -log[dir]=<directory> command line argument.
+ */
+ virtual QString const logDir() const = 0;
+
+ /**
+ * Returns the documentation directory.
+ *
+ * This is the directory where all the documentation and help files are located. The default
+ * documentation directory is 'doc' in the root directory.
+ *
+ * This directory can be changed with the EVAF_DOC_DIR environment variable or with the
+ * -doc[dir]=<directory> command line argument.
+ */
+ virtual QString const docDir() const = 0;
+
+ /**
+ * Returns the Qt plugins directory.
+ *
+ * The Qt plugins directory is where additional Qt plugins are located. These Qt plugins
+ * are loaded manually by the application and specified in the application's XML file.
+ *
+ * Changing this directory does not affect the way how Qt itself loads its plugins.
+ *
+ * This directory can be changed with the EVAF_QT_PLUGINS_DIR environment variable or with the
+ * -qtplugins[dir]=<directory> command line argument.
+ */
+ virtual QString const qtPluginsDir() const = 0;
+
signals: