[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 | |
---|
[7401] | 30 | /** |
---|
| 31 | @defgroup CoreGame Core and Game |
---|
| 32 | @ingroup Management |
---|
| 33 | */ |
---|
| 34 | |
---|
| 35 | /** |
---|
| 36 | @file |
---|
| 37 | @ingroup Management CoreGame |
---|
| 38 | @brief Declaration of the Core singleton which is used to configure the program basics. |
---|
| 39 | */ |
---|
| 40 | |
---|
[1531] | 41 | #ifndef _Core_H__ |
---|
| 42 | #define _Core_H__ |
---|
[1505] | 43 | |
---|
| 44 | #include "CorePrereqs.h" |
---|
| 45 | |
---|
[6417] | 46 | #include <string> |
---|
[11012] | 47 | #include <list> |
---|
[8423] | 48 | #include "util/DestructionHelper.h" |
---|
[3370] | 49 | #include "util/Singleton.h" |
---|
[10624] | 50 | #include "CoreConfig.h" |
---|
[1505] | 51 | |
---|
| 52 | namespace orxonox |
---|
| 53 | { |
---|
[3196] | 54 | /** |
---|
| 55 | @brief |
---|
| 56 | The Core class is a singleton used to configure the program basics. |
---|
[3370] | 57 | @remark |
---|
| 58 | You should only create this singleton once because it destroys the identifiers! |
---|
[3196] | 59 | */ |
---|
[10624] | 60 | class _CoreExport Core : public Singleton<Core> |
---|
[1505] | 61 | { |
---|
[3370] | 62 | friend class Singleton<Core>; |
---|
| 63 | |
---|
[1505] | 64 | public: |
---|
[3196] | 65 | /** |
---|
| 66 | @brief |
---|
| 67 | Determines the executable path, checks for build directory runs, creates |
---|
| 68 | the output directories and sets up the other core library singletons. |
---|
| 69 | @throws |
---|
| 70 | GeneralException |
---|
| 71 | */ |
---|
[3323] | 72 | Core(const std::string& cmdLine); |
---|
[2896] | 73 | |
---|
[8423] | 74 | /// Leave empty and use destroy() instead |
---|
[11071] | 75 | ~Core() = default; |
---|
[8423] | 76 | /// Destructor that also executes when the object fails to construct |
---|
| 77 | void destroy(); |
---|
| 78 | |
---|
[10624] | 79 | void preUpdate(const Clock& time); |
---|
| 80 | void postUpdate(const Clock& time); |
---|
[1505] | 81 | |
---|
[10624] | 82 | void loadGraphics(); |
---|
| 83 | void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); |
---|
[1505] | 84 | |
---|
[10624] | 85 | void loadModules(); |
---|
| 86 | void unloadModules(); |
---|
| 87 | void loadModule(ModuleInstance* module); |
---|
| 88 | void unloadModule(ModuleInstance* module); |
---|
[7870] | 89 | |
---|
[10624] | 90 | inline CoreConfig* getConfig() const |
---|
| 91 | { return this->config_; } |
---|
[7870] | 92 | |
---|
[1505] | 93 | private: |
---|
[11071] | 94 | // non-copyable: |
---|
| 95 | Core(const Core&) = delete; |
---|
| 96 | Core& operator=(const Core&) = delete; |
---|
[2896] | 97 | |
---|
| 98 | void setThreadAffinity(int limitToCPU); |
---|
[8423] | 99 | |
---|
[10624] | 100 | ApplicationPaths* applicationPaths_; |
---|
| 101 | ConfigurablePaths* configurablePaths_; |
---|
| 102 | DynLibManager* dynLibManager_; |
---|
| 103 | SignalHandler* signalHandler_; |
---|
| 104 | ConfigFileManager* configFileManager_; |
---|
| 105 | Language* languageInstance_; |
---|
| 106 | Loader* loaderInstance_; |
---|
| 107 | IOConsole* ioConsole_; |
---|
| 108 | TclBind* tclBind_; |
---|
| 109 | TclThreadManager* tclThreadManager_; |
---|
| 110 | Scope<ScopeID::ROOT>* rootScope_; |
---|
[5781] | 111 | // graphical |
---|
[10624] | 112 | GraphicsManager* graphicsManager_; //!< Interface to OGRE |
---|
| 113 | InputManager* inputManager_; //!< Interface to OIS |
---|
| 114 | GUIManager* guiManager_; //!< Interface to GUI |
---|
| 115 | Scope<ScopeID::GRAPHICS>* graphicsScope_; |
---|
| 116 | bool bGraphicsLoaded_; |
---|
[2710] | 117 | |
---|
[10624] | 118 | CoreStaticInitializationHandler* staticInitHandler_; |
---|
| 119 | PluginManager* pluginManager_; |
---|
| 120 | ModuleInstance* rootModule_; |
---|
| 121 | std::list<ModuleInstance*> modules_; |
---|
[6417] | 122 | |
---|
[10624] | 123 | /// Helper object that stores the config values |
---|
| 124 | CoreConfig* config_; |
---|
| 125 | |
---|
[8423] | 126 | /// Helper object that executes the surrogate destructor destroy() |
---|
[10624] | 127 | DestructionHelper<Core> destructionHelper_; |
---|
[8423] | 128 | |
---|
[10624] | 129 | static Core* singletonPtr_s; |
---|
[1505] | 130 | }; |
---|
| 131 | } |
---|
| 132 | |
---|
[1531] | 133 | #endif /* _Core_H__ */ |
---|