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 <boost/scoped_ptr.hpp> |
---|
48 | #include <loki/ScopeGuard.h> |
---|
49 | |
---|
50 | #include "util/Singleton.h" |
---|
51 | #include "OrxonoxClass.h" |
---|
52 | |
---|
53 | namespace orxonox |
---|
54 | { |
---|
55 | /** |
---|
56 | @brief |
---|
57 | The Core class is a singleton used to configure the program basics. |
---|
58 | @remark |
---|
59 | You should only create this singleton once because it destroys the identifiers! |
---|
60 | */ |
---|
61 | class _CoreExport Core : public Singleton<Core>, public OrxonoxClass |
---|
62 | { |
---|
63 | typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard; |
---|
64 | friend class Singleton<Core>; |
---|
65 | friend class Game; |
---|
66 | |
---|
67 | public: |
---|
68 | /** |
---|
69 | @brief |
---|
70 | Determines the executable path, checks for build directory runs, creates |
---|
71 | the output directories and sets up the other core library singletons. |
---|
72 | @throws |
---|
73 | GeneralException |
---|
74 | */ |
---|
75 | Core(const std::string& cmdLine); |
---|
76 | ~Core(); |
---|
77 | |
---|
78 | void setConfigValues(); |
---|
79 | |
---|
80 | //! Returns the configured language. |
---|
81 | const std::string& getLanguage() |
---|
82 | { return this->language_; } |
---|
83 | void resetLanguage(); |
---|
84 | |
---|
85 | void updateLastLevelTimestamp(); |
---|
86 | inline long long getLastLevelTimestamp() const |
---|
87 | { return this->lastLevelTimestamp_; } |
---|
88 | |
---|
89 | void updateOgreConfigTimestamp(); |
---|
90 | inline long long getOgreConfigTimestamp() const |
---|
91 | { return this->ogreConfigTimestamp_; } |
---|
92 | |
---|
93 | //! Developers bit. If returns false, some options are not available as to not confuse the normal user. |
---|
94 | inline bool inDevMode(void) const |
---|
95 | { return this->bDevMode_; } |
---|
96 | |
---|
97 | private: |
---|
98 | Core(const Core&); //!< Don't use (undefined symbol) |
---|
99 | |
---|
100 | void languageChanged(); |
---|
101 | void initRandomNumberGenerator(); |
---|
102 | |
---|
103 | void preUpdate(const Clock& time); |
---|
104 | void postUpdate(const Clock& time); |
---|
105 | |
---|
106 | void loadGraphics(); |
---|
107 | void unloadGraphics(); |
---|
108 | |
---|
109 | void setThreadAffinity(int limitToCPU); |
---|
110 | // MANAGED SINGLETONS/OBJECTS |
---|
111 | // Mind the order for the destruction! |
---|
112 | scoped_ptr<PathConfig> pathConfig_; |
---|
113 | scoped_ptr<DynLibManager> dynLibManager_; |
---|
114 | scoped_ptr<SignalHandler> signalHandler_; |
---|
115 | SimpleScopeGuard identifierDestroyer_; |
---|
116 | SimpleScopeGuard consoleCommandDestroyer_; |
---|
117 | scoped_ptr<ConfigFileManager> configFileManager_; |
---|
118 | scoped_ptr<Language> languageInstance_; |
---|
119 | scoped_ptr<IOConsole> ioConsole_; |
---|
120 | scoped_ptr<TclBind> tclBind_; |
---|
121 | scoped_ptr<TclThreadManager> tclThreadManager_; |
---|
122 | scoped_ptr<Scope<ScopeID::Root> > rootScope_; |
---|
123 | // graphical |
---|
124 | scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE |
---|
125 | scoped_ptr<InputManager> inputManager_; //!< Interface to OIS |
---|
126 | scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI |
---|
127 | scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_; |
---|
128 | |
---|
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. |
---|
137 | |
---|
138 | static Core* singletonPtr_s; |
---|
139 | }; |
---|
140 | } |
---|
141 | |
---|
142 | #endif /* _Core_H__ */ |
---|