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 | #ifndef _Core_H__ |
---|
31 | #define _Core_H__ |
---|
32 | |
---|
33 | #include "CorePrereqs.h" |
---|
34 | |
---|
35 | #include <cassert> |
---|
36 | #include <boost/scoped_ptr.hpp> |
---|
37 | #include "util/OutputHandler.h" |
---|
38 | #include "util/Scope.h" |
---|
39 | #include "util/ScopeGuard.h" |
---|
40 | #include "util/Singleton.h" |
---|
41 | |
---|
42 | namespace orxonox |
---|
43 | { |
---|
44 | class CoreConfiguration; |
---|
45 | class IOConsole; |
---|
46 | |
---|
47 | /** |
---|
48 | @brief |
---|
49 | The Core class is a singleton used to configure the program basics. |
---|
50 | @remark |
---|
51 | You should only create this singleton once because it destroys the identifiers! |
---|
52 | */ |
---|
53 | class _CoreExport Core : public Singleton<Core> |
---|
54 | { |
---|
55 | typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard; |
---|
56 | friend class Singleton<Core>; |
---|
57 | friend class Game; |
---|
58 | |
---|
59 | public: |
---|
60 | /** |
---|
61 | @brief |
---|
62 | Determines the executable path, checks for build directory runs, creates |
---|
63 | the output directories and sets up the other core library singletons. |
---|
64 | @throws |
---|
65 | GeneralException |
---|
66 | */ |
---|
67 | Core(const std::string& cmdLine); |
---|
68 | ~Core(); |
---|
69 | |
---|
70 | void setConfigValues(); |
---|
71 | |
---|
72 | static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); |
---|
73 | static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); |
---|
74 | static const std::string& getLanguage(); |
---|
75 | static void resetLanguage(); |
---|
76 | |
---|
77 | private: |
---|
78 | Core(const Core&); //!< Don't use (undefined symbol) |
---|
79 | |
---|
80 | void preUpdate(const Clock& time); |
---|
81 | void postUpdate(const Clock& time); |
---|
82 | |
---|
83 | void loadGraphics(); |
---|
84 | void unloadGraphics(); |
---|
85 | |
---|
86 | void setThreadAffinity(int limitToCPU); |
---|
87 | |
---|
88 | // Mind the order for the destruction! |
---|
89 | scoped_ptr<PathConfig> pathConfig_; |
---|
90 | scoped_ptr<DynLibManager> dynLibManager_; |
---|
91 | scoped_ptr<SignalHandler> signalHandler_; |
---|
92 | SimpleScopeGuard identifierDestroyer_; |
---|
93 | SimpleScopeGuard consoleCommandDestroyer_; |
---|
94 | scoped_ptr<ConfigFileManager> configFileManager_; |
---|
95 | scoped_ptr<Language> languageInstance_; |
---|
96 | scoped_ptr<CoreConfiguration> configuration_; |
---|
97 | scoped_ptr<TclBind> tclBind_; |
---|
98 | scoped_ptr<TclThreadManager> tclThreadManager_; |
---|
99 | scoped_ptr<Shell> shell_; |
---|
100 | scoped_ptr<IOConsole> ioConsole_; |
---|
101 | // graphical |
---|
102 | scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE |
---|
103 | scoped_ptr<InputManager> inputManager_; //!< Interface to OIS |
---|
104 | scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI |
---|
105 | scoped_ptr<Scope<ScopeID::Root> > rootScope_; |
---|
106 | scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_; |
---|
107 | |
---|
108 | bool bGraphicsLoaded_; |
---|
109 | static Core* singletonPtr_s; |
---|
110 | }; |
---|
111 | } |
---|
112 | |
---|
113 | #endif /* _Core_H__ */ |
---|