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