[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> |
---|
[7266] | 47 | #include <loki/ScopeGuard.h> |
---|
| 48 | |
---|
[8423] | 49 | #include "util/DestructionHelper.h" |
---|
[3370] | 50 | #include "util/Singleton.h" |
---|
[6746] | 51 | #include "OrxonoxClass.h" |
---|
[1505] | 52 | |
---|
| 53 | namespace orxonox |
---|
| 54 | { |
---|
[3196] | 55 | /** |
---|
| 56 | @brief |
---|
| 57 | The Core class is a singleton used to configure the program basics. |
---|
[3370] | 58 | @remark |
---|
| 59 | You should only create this singleton once because it destroys the identifiers! |
---|
[3196] | 60 | */ |
---|
[6417] | 61 | class _CoreExport Core : public Singleton<Core>, public OrxonoxClass |
---|
[1505] | 62 | { |
---|
[3370] | 63 | friend class Singleton<Core>; |
---|
[5695] | 64 | friend class Game; |
---|
[3370] | 65 | |
---|
[1505] | 66 | public: |
---|
[3196] | 67 | /** |
---|
| 68 | @brief |
---|
| 69 | Determines the executable path, checks for build directory runs, creates |
---|
| 70 | the output directories and sets up the other core library singletons. |
---|
| 71 | @throws |
---|
| 72 | GeneralException |
---|
| 73 | */ |
---|
[3323] | 74 | Core(const std::string& cmdLine); |
---|
[2896] | 75 | |
---|
[8423] | 76 | /// Leave empty and use destroy() instead |
---|
| 77 | ~Core() {} |
---|
| 78 | /// Destructor that also executes when the object fails to construct |
---|
| 79 | void destroy(); |
---|
| 80 | |
---|
[1505] | 81 | void setConfigValues(); |
---|
| 82 | |
---|
[6417] | 83 | //! Returns the configured language. |
---|
| 84 | const std::string& getLanguage() |
---|
| 85 | { return this->language_; } |
---|
| 86 | void resetLanguage(); |
---|
[1505] | 87 | |
---|
[7870] | 88 | void updateLastLevelTimestamp(); |
---|
| 89 | inline long long getLastLevelTimestamp() const |
---|
| 90 | { return this->lastLevelTimestamp_; } |
---|
| 91 | |
---|
| 92 | void updateOgreConfigTimestamp(); |
---|
| 93 | inline long long getOgreConfigTimestamp() const |
---|
| 94 | { return this->ogreConfigTimestamp_; } |
---|
| 95 | |
---|
[8366] | 96 | //! Developers bit. If returns false, some options are not available as to not confuse the normal user. |
---|
[8079] | 97 | inline bool inDevMode(void) const |
---|
| 98 | { return this->bDevMode_; } |
---|
| 99 | |
---|
[1505] | 100 | private: |
---|
[3196] | 101 | Core(const Core&); //!< Don't use (undefined symbol) |
---|
[2896] | 102 | |
---|
[6417] | 103 | void languageChanged(); |
---|
| 104 | void initRandomNumberGenerator(); |
---|
| 105 | |
---|
[5695] | 106 | void preUpdate(const Clock& time); |
---|
| 107 | void postUpdate(const Clock& time); |
---|
| 108 | |
---|
[5781] | 109 | void loadGraphics(); |
---|
| 110 | void unloadGraphics(); |
---|
| 111 | |
---|
[2896] | 112 | void setThreadAffinity(int limitToCPU); |
---|
[8423] | 113 | |
---|
| 114 | PathConfig* pathConfig_; |
---|
| 115 | DynLibManager* dynLibManager_; |
---|
| 116 | SignalHandler* signalHandler_; |
---|
| 117 | ConfigFileManager* configFileManager_; |
---|
| 118 | Language* languageInstance_; |
---|
| 119 | IOConsole* ioConsole_; |
---|
| 120 | TclBind* tclBind_; |
---|
| 121 | TclThreadManager* tclThreadManager_; |
---|
| 122 | Scope<ScopeID::Root>* rootScope_; |
---|
[5781] | 123 | // graphical |
---|
[8423] | 124 | GraphicsManager* graphicsManager_; //!< Interface to OGRE |
---|
| 125 | InputManager* inputManager_; //!< Interface to OIS |
---|
| 126 | GUIManager* guiManager_; //!< Interface to GUI |
---|
| 127 | Scope<ScopeID::Graphics>* graphicsScope_; |
---|
[2710] | 128 | |
---|
[8423] | 129 | bool bGraphicsLoaded_; |
---|
| 130 | int softDebugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler) |
---|
| 131 | std::string language_; //!< The language |
---|
| 132 | bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called |
---|
| 133 | bool bStartIOConsole_; //!< Set to false if you don't want to use the IOConsole |
---|
| 134 | long long lastLevelTimestamp_; ///< Timestamp when the last level was started |
---|
| 135 | long long ogreConfigTimestamp_; ///< Timestamp wehen the ogre config level was modified |
---|
| 136 | bool bDevMode_; //!< Developers bit. If set to false, some options are not available as to not confuse the normal user. |
---|
[6417] | 137 | |
---|
[8423] | 138 | /// Helper object that executes the surrogate destructor destroy() |
---|
| 139 | DestructionHelper<Core> destructionHelper_; |
---|
| 140 | |
---|
| 141 | static Core* singletonPtr_s; |
---|
[1505] | 142 | }; |
---|
| 143 | } |
---|
| 144 | |
---|
[1531] | 145 | #endif /* _Core_H__ */ |
---|