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 | */ |
---|
39 | |
---|
40 | #ifndef _Core_H__ |
---|
41 | #define _Core_H__ |
---|
42 | |
---|
43 | #include "CorePrereqs.h" |
---|
44 | |
---|
45 | #include <string> |
---|
46 | #include <boost/scoped_ptr.hpp> |
---|
47 | #include <loki/ScopeGuard.h> |
---|
48 | |
---|
49 | #include "util/Singleton.h" |
---|
50 | #include "OrxonoxClass.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>, public OrxonoxClass |
---|
61 | { |
---|
62 | typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard; |
---|
63 | friend class Singleton<Core>; |
---|
64 | friend class Game; |
---|
65 | |
---|
66 | public: |
---|
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 | */ |
---|
74 | Core(const std::string& cmdLine); |
---|
75 | ~Core(); |
---|
76 | |
---|
77 | void setConfigValues(); |
---|
78 | |
---|
79 | //! Returns the configured language. |
---|
80 | const std::string& getLanguage() |
---|
81 | { return this->language_; } |
---|
82 | void resetLanguage(); |
---|
83 | |
---|
84 | private: |
---|
85 | Core(const Core&); //!< Don't use (undefined symbol) |
---|
86 | |
---|
87 | void languageChanged(); |
---|
88 | void initRandomNumberGenerator(); |
---|
89 | |
---|
90 | void preUpdate(const Clock& time); |
---|
91 | void postUpdate(const Clock& time); |
---|
92 | |
---|
93 | void loadGraphics(); |
---|
94 | void unloadGraphics(); |
---|
95 | |
---|
96 | void setThreadAffinity(int limitToCPU); |
---|
97 | // MANAGED SINGLETONS/OBJECTS |
---|
98 | // Mind the order for the destruction! |
---|
99 | scoped_ptr<PathConfig> pathConfig_; |
---|
100 | scoped_ptr<DynLibManager> dynLibManager_; |
---|
101 | scoped_ptr<SignalHandler> signalHandler_; |
---|
102 | SimpleScopeGuard identifierDestroyer_; |
---|
103 | SimpleScopeGuard consoleCommandDestroyer_; |
---|
104 | scoped_ptr<ConfigFileManager> configFileManager_; |
---|
105 | scoped_ptr<Language> languageInstance_; |
---|
106 | scoped_ptr<IOConsole> ioConsole_; |
---|
107 | scoped_ptr<TclBind> tclBind_; |
---|
108 | scoped_ptr<TclThreadManager> tclThreadManager_; |
---|
109 | scoped_ptr<Scope<ScopeID::Root> > rootScope_; |
---|
110 | // graphical |
---|
111 | scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE |
---|
112 | scoped_ptr<InputManager> inputManager_; //!< Interface to OIS |
---|
113 | scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI |
---|
114 | scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_; |
---|
115 | |
---|
116 | bool bGraphicsLoaded_; |
---|
117 | int softDebugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler) |
---|
118 | std::string language_; //!< The language |
---|
119 | bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called |
---|
120 | bool bStartIOConsole_; //!< Set to false if you don't want to use the IOConsole |
---|
121 | |
---|
122 | static Core* singletonPtr_s; |
---|
123 | }; |
---|
124 | } |
---|
125 | |
---|
126 | #endif /* _Core_H__ */ |
---|