[1505] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
[2896] | 24 | * Reto Grieder |
---|
[1505] | 25 | * Co-authors: |
---|
[2896] | 26 | * ... |
---|
[1505] | 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | /** |
---|
[3196] | 31 | @file |
---|
| 32 | @brief |
---|
| 33 | Declaration of the Core class. |
---|
| 34 | @details |
---|
[1524] | 35 | The Core class is a singleton, only used to configure some variables |
---|
[1505] | 36 | in the core through the config-file. |
---|
| 37 | */ |
---|
| 38 | |
---|
[1531] | 39 | #ifndef _Core_H__ |
---|
| 40 | #define _Core_H__ |
---|
[1505] | 41 | |
---|
| 42 | #include "CorePrereqs.h" |
---|
| 43 | |
---|
[2662] | 44 | #include <cassert> |
---|
[1505] | 45 | #include "OrxonoxClass.h" |
---|
[1747] | 46 | #include "util/OutputHandler.h" |
---|
[1505] | 47 | |
---|
| 48 | namespace orxonox |
---|
| 49 | { |
---|
[3196] | 50 | /** |
---|
| 51 | @brief |
---|
| 52 | The Core class is a singleton used to configure the program basics. |
---|
| 53 | @details |
---|
| 54 | The class provides information about the media, config and log path. |
---|
| 55 | It determines those by the use of platform specific functions. |
---|
| 56 | */ |
---|
[1524] | 57 | class _CoreExport Core : public OrxonoxClass |
---|
[1505] | 58 | { |
---|
| 59 | public: |
---|
[3196] | 60 | /** |
---|
| 61 | @brief |
---|
| 62 | Determines the executable path, checks for build directory runs, creates |
---|
| 63 | the output directories and sets up the other core library singletons. |
---|
| 64 | @throws |
---|
| 65 | GeneralException |
---|
| 66 | */ |
---|
[2662] | 67 | Core(); |
---|
| 68 | ~Core(); |
---|
[2896] | 69 | |
---|
| 70 | void initialise(int argc, char** argv); |
---|
[1505] | 71 | void setConfigValues(); |
---|
| 72 | |
---|
[2896] | 73 | void update(const Clock& time); |
---|
| 74 | |
---|
[2662] | 75 | static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; } |
---|
| 76 | |
---|
| 77 | static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); |
---|
| 78 | static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); |
---|
[1505] | 79 | static const std::string& getLanguage(); |
---|
[2662] | 80 | static void resetLanguage(); |
---|
[1505] | 81 | |
---|
[2710] | 82 | static void tsetMediaPath(const std::string& path) |
---|
| 83 | { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); } |
---|
[3196] | 84 | //! Returns the path to the config files as boost::filesystem::path |
---|
[2710] | 85 | static const boost::filesystem::path& getMediaPath(); |
---|
[3196] | 86 | //! Returns the path to the config files as boost::filesystem::path |
---|
[2710] | 87 | static const boost::filesystem::path& getConfigPath(); |
---|
[3196] | 88 | //! Returns the path to the log files as boost::filesystem::path |
---|
[2710] | 89 | static const boost::filesystem::path& getLogPath(); |
---|
[3196] | 90 | //! Returns the path to the data files as std::string |
---|
[2710] | 91 | static std::string getMediaPathString(); |
---|
[3196] | 92 | //! Returns the path to the config files as std::string |
---|
[2710] | 93 | static std::string getConfigPathString(); |
---|
[3196] | 94 | //! Returns the path to the log files as std::string |
---|
[2710] | 95 | static std::string getLogPathString(); |
---|
| 96 | |
---|
[1505] | 97 | private: |
---|
[3196] | 98 | Core(const Core&); //!< Don't use (undefined symbol) |
---|
[2896] | 99 | |
---|
| 100 | void checkDevBuild(); |
---|
| 101 | void setExecutablePath(); |
---|
| 102 | void createDirectories(); |
---|
| 103 | void setThreadAffinity(int limitToCPU); |
---|
| 104 | |
---|
[1505] | 105 | void resetLanguageIntern(); |
---|
[2662] | 106 | void initializeRandomNumberGenerator(); |
---|
[2710] | 107 | void debugLevelChanged(); |
---|
| 108 | void languageChanged(); |
---|
| 109 | void mediaPathChanged(); |
---|
| 110 | void _tsetMediaPath(const std::string& path); |
---|
[1505] | 111 | |
---|
[2896] | 112 | // Singletons |
---|
| 113 | ConfigFileManager* configFileManager_; |
---|
| 114 | Language* languageInstance_; |
---|
| 115 | LuaBind* luaBind_; |
---|
| 116 | Shell* shell_; |
---|
| 117 | SignalHandler* signalHandler_; |
---|
| 118 | TclBind* tclBind_; |
---|
| 119 | TclThreadManager* tclThreadManager_; |
---|
[2710] | 120 | |
---|
[1505] | 121 | int softDebugLevel_; //!< The debug level |
---|
| 122 | int softDebugLevelConsole_; //!< The debug level for the console |
---|
| 123 | int softDebugLevelLogfile_; //!< The debug level for the logfile |
---|
| 124 | int softDebugLevelShell_; //!< The debug level for the ingame shell |
---|
| 125 | std::string language_; //!< The language |
---|
[2710] | 126 | bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called |
---|
| 127 | std::string mediaPathString_; //!< Path to the data/media file folder as string |
---|
[2896] | 128 | bool isDevBuild_; //!< True for builds in the build directory (not installed) |
---|
| 129 | bool loaded_; //!< Only true if constructor was interrupted |
---|
[2087] | 130 | |
---|
[2662] | 131 | static Core* singletonRef_s; |
---|
[1505] | 132 | }; |
---|
| 133 | } |
---|
| 134 | |
---|
[1531] | 135 | #endif /* _Core_H__ */ |
---|