/** * @file Common/ienv.h * @brief Environment 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_IENV_H #define __COMMON_IENV_H #include "libcommon.h" #include #include namespace eVaf { namespace Common { /** * Environment interface for eVaf applications * @code#include @endcode * * The iEnv interface provides information about the environment where the application is running. * Functions in this interface return names of directories where different resources are located. * Modules should always use the iEnv interface for directory names and locations. * * Directory names returned by functions in this interface are UNIX path names and they are quaranteed * to end with the '/' character. * * All the directories have reasonable default values, that should work in most of the cases. For example, * the binary directory is set to the same directory where the application's main executable is located. * 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. */ class COMMON_EXPORT iEnv : public QObject { Q_OBJECT public: /// Interface constructor iEnv() : QObject() {} /// Empty virtual destructor virtual ~iEnv() {} /** * Returns the iEnv interface instance * @return The iEnv interface * * This function returns the global iEnv 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 iEnv interface. The other method is by using the iRegistry interface. */ static iEnv * instance(); /** * 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; }; } // namespace eVaf::Common } // namespace eVaf #endif