/** * @file Common/iapp.h * @brief eVaf application interface * @author Enar Vaikene * * Copyright (c) 2011 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * * This file can be used under the terms of the GNU General Public License * version 3.0 as published by the Free Software Foundation and appearing in * the file LICENSE included in the packaging of this file. Please review the * the following information to ensure the GNU General Public License version * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. * * Alternatively, this file may be used in accordance with the Commercial License * Agreement provided with the Software. */ #ifndef __COMMON_IAPP_H #define __COMMON_IAPP_H #include "libcommon.h" #include #include namespace eVaf { namespace Common { /** * eVaf application interface * @code#include @endcode * * The iApp interface provides information about current eVaf application. * * All the resources returned by this interface have default values, that should work in most of the cases. * * Default values can be overwritten with environment variables and command line arguments. If both are used, * then command line arguments have higher priorities. */ class COMMON_EXPORT iApp : public QObject { Q_OBJECT 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() {} /// Empty virtual destructor virtual ~iApp() {} /** * Returns the iApp interface instance * @return The iApp interface * * This function returns the global iApp interface instance. As all the eVaf modules and applications * are expected to be linked against the common library, then this is the preferred method of obtaining * the iApp interface. The other method is by using the iRegistry interface. */ static iApp * instance(); /** * Returns the name of the eVaf application * * This function returns the name of the eVaf application, which is a string that identifies the application. * The default name of the application is "eVaf". * * This name of the application can be changed with the EVAF_APP_NAME environment variable or with the * -app[lication]=<name> command line argument. */ virtual QString const name() const = 0; /** * Returns the current language and country used by the application. * * This function returns the current lowercase two-letter ISO 639 language code and uppercase * two-letter ISO 3166 country code if set. * * The default language is queried from the operating system. * * The language can be changed with the EVAF_LANGUAGE environment variabel or with the * -lang[uage]=<language> command line argument. */ virtual QString const language() const = 0; /** * Returns the name of the application's XML file. * * This function returns the name of the application's XML file. * It tries to find the most specific file name for the given language. If not found, then * defaults to the generic name. * * For example, if the language is set to "et_EE" and the application's name is "eVaf", then * it tries to find XML files with the following names "eVaf_et_EE.xml" and "eVaf_et.xml". If * neither is found, defaults to the name "eVaf.xml". * * The path is not included in the returned file name. Use the eVaf::Common::iEnv::etcDir() function * for the location of the file. */ virtual QString const xmlFileName() const = 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; signals: /** * Ready signal. * * This signal is emitted when the eVaf application is ready, ie the application initialized and all the * modules loaded. */ void ready(); /** * Terminating signal. * * This signal is emitted when the eVaf application is about to terminate. */ void terminating(); }; } // namespace eVaf::Common } // namespace eVaf #endif