[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 | /** |
---|
[2171] | 31 | @file |
---|
[1755] | 32 | @brief Declaration of the Core class. |
---|
[1505] | 33 | |
---|
[1524] | 34 | The Core class is a singleton, only used to configure some variables |
---|
[1505] | 35 | in the core through the config-file. |
---|
| 36 | */ |
---|
| 37 | |
---|
[1531] | 38 | #ifndef _Core_H__ |
---|
| 39 | #define _Core_H__ |
---|
[1505] | 40 | |
---|
| 41 | #include "CorePrereqs.h" |
---|
| 42 | |
---|
[2662] | 43 | #include <cassert> |
---|
[1505] | 44 | #include "OrxonoxClass.h" |
---|
[1747] | 45 | #include "util/OutputHandler.h" |
---|
[1505] | 46 | |
---|
[2710] | 47 | // boost::filesystem header has quite a large tail, use forward declaration |
---|
| 48 | namespace boost { namespace filesystem |
---|
| 49 | { |
---|
| 50 | struct path_traits; |
---|
| 51 | template<class String, class Traits> class basic_path; |
---|
| 52 | typedef basic_path< std::string, path_traits> path; |
---|
| 53 | } } |
---|
| 54 | |
---|
[1505] | 55 | namespace orxonox |
---|
| 56 | { |
---|
[1524] | 57 | //! The Core class is a singleton, only used to configure some config-values. |
---|
| 58 | class _CoreExport Core : public OrxonoxClass |
---|
[1505] | 59 | { |
---|
| 60 | public: |
---|
[2662] | 61 | Core(); |
---|
| 62 | ~Core(); |
---|
[2896] | 63 | |
---|
| 64 | void initialise(int argc, char** argv); |
---|
[1505] | 65 | void setConfigValues(); |
---|
| 66 | |
---|
[2896] | 67 | void update(const Clock& time); |
---|
| 68 | |
---|
[2662] | 69 | static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; } |
---|
| 70 | |
---|
| 71 | static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); |
---|
| 72 | static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); |
---|
[1505] | 73 | static const std::string& getLanguage(); |
---|
[2662] | 74 | static void resetLanguage(); |
---|
[1505] | 75 | |
---|
[2710] | 76 | static void tsetMediaPath(const std::string& path) |
---|
| 77 | { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); } |
---|
| 78 | static const boost::filesystem::path& getMediaPath(); |
---|
| 79 | static const boost::filesystem::path& getConfigPath(); |
---|
| 80 | static const boost::filesystem::path& getLogPath(); |
---|
| 81 | static std::string getMediaPathString(); |
---|
| 82 | static std::string getConfigPathString(); |
---|
| 83 | static std::string getLogPathString(); |
---|
| 84 | |
---|
[1505] | 85 | private: |
---|
[2662] | 86 | Core(const Core&); |
---|
[2896] | 87 | |
---|
| 88 | void checkDevBuild(); |
---|
| 89 | void setExecutablePath(); |
---|
| 90 | void createDirectories(); |
---|
| 91 | void setThreadAffinity(int limitToCPU); |
---|
| 92 | |
---|
[1505] | 93 | void resetLanguageIntern(); |
---|
[2662] | 94 | void initializeRandomNumberGenerator(); |
---|
[2710] | 95 | void debugLevelChanged(); |
---|
| 96 | void languageChanged(); |
---|
| 97 | void mediaPathChanged(); |
---|
| 98 | void _tsetMediaPath(const std::string& path); |
---|
[1505] | 99 | |
---|
[2896] | 100 | // Singletons |
---|
| 101 | ConfigFileManager* configFileManager_; |
---|
| 102 | Language* languageInstance_; |
---|
| 103 | LuaBind* luaBind_; |
---|
| 104 | Shell* shell_; |
---|
| 105 | SignalHandler* signalHandler_; |
---|
| 106 | TclBind* tclBind_; |
---|
| 107 | TclThreadManager* tclThreadManager_; |
---|
[2710] | 108 | |
---|
[1505] | 109 | int softDebugLevel_; //!< The debug level |
---|
| 110 | int softDebugLevelConsole_; //!< The debug level for the console |
---|
| 111 | int softDebugLevelLogfile_; //!< The debug level for the logfile |
---|
| 112 | int softDebugLevelShell_; //!< The debug level for the ingame shell |
---|
| 113 | std::string language_; //!< The language |
---|
[2710] | 114 | bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called |
---|
| 115 | std::string mediaPathString_; //!< Path to the data/media file folder as string |
---|
[2896] | 116 | bool isDevBuild_; //!< True for builds in the build directory (not installed) |
---|
| 117 | bool loaded_; //!< Only true if constructor was interrupted |
---|
[2087] | 118 | |
---|
[2662] | 119 | static Core* singletonRef_s; |
---|
[1505] | 120 | }; |
---|
| 121 | } |
---|
| 122 | |
---|
[1531] | 123 | #endif /* _Core_H__ */ |
---|