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 | @file |
---|
32 | @brief |
---|
33 | Declaration of the Core class. |
---|
34 | @details |
---|
35 | The Core class is a singleton, only used to configure some variables |
---|
36 | in the core through the config-file. |
---|
37 | */ |
---|
38 | |
---|
39 | #ifndef _Core_H__ |
---|
40 | #define _Core_H__ |
---|
41 | |
---|
42 | #include "CorePrereqs.h" |
---|
43 | |
---|
44 | #include <cassert> |
---|
45 | #include <boost/scoped_ptr.hpp> |
---|
46 | #include "util/OutputHandler.h" |
---|
47 | #include "util/ScopeGuard.h" |
---|
48 | #include "util/Singleton.h" |
---|
49 | |
---|
50 | namespace orxonox |
---|
51 | { |
---|
52 | class CoreConfiguration; |
---|
53 | |
---|
54 | /** |
---|
55 | @brief |
---|
56 | The Core class is a singleton used to configure the program basics. |
---|
57 | @details |
---|
58 | The class provides information about the data, config and log path. |
---|
59 | It determines those by the use of platform specific functions. |
---|
60 | @remark |
---|
61 | You should only create this singleton once because it destroys the identifiers! |
---|
62 | */ |
---|
63 | class _CoreExport Core : public Singleton<Core> |
---|
64 | { |
---|
65 | typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard; |
---|
66 | friend class Singleton<Core>; |
---|
67 | friend class Game; |
---|
68 | |
---|
69 | public: |
---|
70 | /** |
---|
71 | @brief |
---|
72 | Determines the executable path, checks for build directory runs, creates |
---|
73 | the output directories and sets up the other core library singletons. |
---|
74 | @throws |
---|
75 | GeneralException |
---|
76 | */ |
---|
77 | Core(const std::string& cmdLine); |
---|
78 | ~Core(); |
---|
79 | |
---|
80 | void setConfigValues(); |
---|
81 | |
---|
82 | static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); |
---|
83 | static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); |
---|
84 | static const std::string& getLanguage(); |
---|
85 | static void resetLanguage(); |
---|
86 | |
---|
87 | //! Returns the path to the data files as boost::filesystem::path |
---|
88 | static const boost::filesystem::path& getDataPath(); |
---|
89 | //! Returns the path to the config files as boost::filesystem::path |
---|
90 | static const boost::filesystem::path& getConfigPath(); |
---|
91 | //! Returns the path to the log files as boost::filesystem::path |
---|
92 | static const boost::filesystem::path& getLogPath(); |
---|
93 | //! Returns the path to the root folder as boost::filesystem::path |
---|
94 | static const boost::filesystem::path& getRootPath(); |
---|
95 | //! Returns the path to the data files as std::string |
---|
96 | static std::string getDataPathString(); |
---|
97 | //! Returns the path to the config files as std::string |
---|
98 | static std::string getConfigPathString(); |
---|
99 | //! Returns the path to the log files as std::string |
---|
100 | static std::string getLogPathString(); |
---|
101 | //! Returns the path to the root folder as std::string |
---|
102 | static std::string getRootPathString(); |
---|
103 | |
---|
104 | static bool isDevelopmentRun() { return getInstance().bDevRun_; } |
---|
105 | |
---|
106 | private: |
---|
107 | Core(const Core&); //!< Don't use (undefined symbol) |
---|
108 | |
---|
109 | void preUpdate(const Clock& time); |
---|
110 | void postUpdate(const Clock& time); |
---|
111 | |
---|
112 | void setFixedPaths(); |
---|
113 | void setConfigurablePaths(); |
---|
114 | void setThreadAffinity(int limitToCPU); |
---|
115 | |
---|
116 | // Mind the order for the destruction! |
---|
117 | scoped_ptr<DynLibManager> dynLibManager_; |
---|
118 | scoped_ptr<SignalHandler> signalHandler_; |
---|
119 | SimpleScopeGuard identifierDestroyer_; |
---|
120 | scoped_ptr<ConfigFileManager> configFileManager_; |
---|
121 | scoped_ptr<Language> languageInstance_; |
---|
122 | scoped_ptr<CoreConfiguration> configuration_; |
---|
123 | |
---|
124 | bool bDevRun_; //!< True for runs in the build directory (not installed) |
---|
125 | |
---|
126 | static Core* singletonPtr_s; |
---|
127 | }; |
---|
128 | } |
---|
129 | |
---|
130 | #endif /* _Core_H__ */ |
---|