| 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 | @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 | |
|---|
| 41 | #ifndef _Core_H__ |
|---|
| 42 | #define _Core_H__ |
|---|
| 43 | |
|---|
| 44 | #include "CorePrereqs.h" |
|---|
| 45 | |
|---|
| 46 | #include <string> |
|---|
| 47 | #include <list> |
|---|
| 48 | #include "util/DestructionHelper.h" |
|---|
| 49 | #include "util/Singleton.h" |
|---|
| 50 | #include "CoreConfig.h" |
|---|
| 51 | |
|---|
| 52 | namespace orxonox |
|---|
| 53 | { |
|---|
| 54 | /** |
|---|
| 55 | @brief |
|---|
| 56 | The Core class is a singleton used to configure the program basics. |
|---|
| 57 | @remark |
|---|
| 58 | You should only create this singleton once because it destroys the identifiers! |
|---|
| 59 | */ |
|---|
| 60 | class _CoreExport Core : public Singleton<Core> |
|---|
| 61 | { |
|---|
| 62 | friend class Singleton<Core>; |
|---|
| 63 | |
|---|
| 64 | public: |
|---|
| 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 | */ |
|---|
| 72 | Core(const std::string& cmdLine); |
|---|
| 73 | |
|---|
| 74 | /// Leave empty and use destroy() instead |
|---|
| 75 | ~Core() {} |
|---|
| 76 | /// Destructor that also executes when the object fails to construct |
|---|
| 77 | void destroy(); |
|---|
| 78 | |
|---|
| 79 | void preUpdate(const Clock& time); |
|---|
| 80 | void postUpdate(const Clock& time); |
|---|
| 81 | |
|---|
| 82 | void loadGraphics(); |
|---|
| 83 | void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true); |
|---|
| 84 | |
|---|
| 85 | void loadModules(); |
|---|
| 86 | void unloadModules(); |
|---|
| 87 | void loadModule(ModuleInstance* module); |
|---|
| 88 | void unloadModule(ModuleInstance* module); |
|---|
| 89 | |
|---|
| 90 | inline CoreConfig* getConfig() const |
|---|
| 91 | { return this->config_; } |
|---|
| 92 | |
|---|
| 93 | private: |
|---|
| 94 | Core(const Core&); //!< Don't use (undefined symbol) |
|---|
| 95 | |
|---|
| 96 | void setThreadAffinity(int limitToCPU); |
|---|
| 97 | |
|---|
| 98 | ApplicationPaths* applicationPaths_; |
|---|
| 99 | ConfigurablePaths* configurablePaths_; |
|---|
| 100 | DynLibManager* dynLibManager_; |
|---|
| 101 | SignalHandler* signalHandler_; |
|---|
| 102 | ConfigFileManager* configFileManager_; |
|---|
| 103 | Language* languageInstance_; |
|---|
| 104 | Loader* loaderInstance_; |
|---|
| 105 | IOConsole* ioConsole_; |
|---|
| 106 | TclBind* tclBind_; |
|---|
| 107 | TclThreadManager* tclThreadManager_; |
|---|
| 108 | Scope<ScopeID::ROOT>* rootScope_; |
|---|
| 109 | // graphical |
|---|
| 110 | GraphicsManager* graphicsManager_; //!< Interface to OGRE |
|---|
| 111 | InputManager* inputManager_; //!< Interface to OIS |
|---|
| 112 | GUIManager* guiManager_; //!< Interface to GUI |
|---|
| 113 | Scope<ScopeID::GRAPHICS>* graphicsScope_; |
|---|
| 114 | bool bGraphicsLoaded_; |
|---|
| 115 | |
|---|
| 116 | CoreStaticInitializationHandler* staticInitHandler_; |
|---|
| 117 | PluginManager* pluginManager_; |
|---|
| 118 | ModuleInstance* rootModule_; |
|---|
| 119 | std::list<ModuleInstance*> modules_; |
|---|
| 120 | |
|---|
| 121 | /// Helper object that stores the config values |
|---|
| 122 | CoreConfig* config_; |
|---|
| 123 | |
|---|
| 124 | /// Helper object that executes the surrogate destructor destroy() |
|---|
| 125 | DestructionHelper<Core> destructionHelper_; |
|---|
| 126 | |
|---|
| 127 | static Core* singletonPtr_s; |
|---|
| 128 | }; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | #endif /* _Core_H__ */ |
|---|