Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource3/src/core/Core.h @ 5680

Last change on this file since 5680 was 5679, checked in by rgrieder, 15 years ago

Merged revision 5641 to resource3:

  • Prepared build system for an external media directory.
  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
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
50namespace orxonox
51{
52    class CoreConfiguration;
53    using boost::scoped_ptr;
54
55    /**
56    @brief
57        The Core class is a singleton used to configure the program basics.
58    @details
59        The class provides information about the media, config and log path.
60        It determines those by the use of platform specific functions.
61    @remark
62        You should only create this singleton once because it destroys the identifiers!
63    */
64    class _CoreExport Core : public Singleton<Core>
65    {
66        typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
67        friend class Singleton<Core>;
68        friend class Game;
69
70        public:
71            /**
72            @brief
73                Determines the executable path, checks for build directory runs, creates
74                the output directories and sets up the other core library singletons.
75            @throws
76                GeneralException
77            */
78            Core(const std::string& cmdLine);
79            ~Core();
80
81            void setConfigValues();
82
83            bool preUpdate(const Clock& time) throw();
84            bool postUpdate(const Clock& time) throw();
85
86            static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
87            static void  setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
88            static const std::string& getLanguage();
89            static void  resetLanguage();
90
91            static void tsetExternalMediaPath(const std::string& path);
92            //! Returns the path to the data files as boost::filesystem::path
93            static const boost::filesystem::path& getMediaPath();
94            //! Returns the path to the external data files as boost::filesystem::path
95            static const boost::filesystem::path& getExternalMediaPath();
96            //! Returns the path to the config files as boost::filesystem::path
97            static const boost::filesystem::path& getConfigPath();
98            //! Returns the path to the log files as boost::filesystem::path
99            static const boost::filesystem::path& getLogPath();
100            //! Returns the path to the data files as std::string
101            //! Returns the path to the root folder as boost::filesystem::path
102            static const boost::filesystem::path& getRootPath();
103            static std::string getMediaPathString();
104            //! Returns the path to the external data files as std::string
105            static std::string getExternalMediaPathString();
106            //! Returns the path to the config files as std::string
107            static std::string getConfigPathString();
108            //! Returns the path to the log files as std::string
109            static std::string getLogPathString();
110            //! Returns the path to the root folder as std::string
111            static std::string getRootPathString();
112
113            static bool isDevelopmentRun() { return getInstance().bDevRun_; }
114
115        private:
116            Core(const Core&); //!< Don't use (undefined symbol)
117
118            void loadGraphics();
119            void unloadGraphics();
120
121            void checkDevBuild();
122            void setExecutablePath();
123            void createDirectories();
124            void setThreadAffinity(int limitToCPU);
125
126            // Mind the order for the destruction!
127            scoped_ptr<SignalHandler>     signalHandler_;
128            SimpleScopeGuard              identifierDestroyer_;
129            SimpleScopeGuard              consoleCommandDestroyer_;
130            scoped_ptr<ConfigFileManager> configFileManager_;
131            scoped_ptr<Language>          languageInstance_;
132            scoped_ptr<CoreConfiguration> configuration_;
133            scoped_ptr<LuaBind>           luaBind_;
134            scoped_ptr<TclBind>           tclBind_;
135            scoped_ptr<TclThreadManager>  tclThreadManager_;
136            scoped_ptr<Shell>             shell_;
137            // graphical
138            scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
139            scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
140            scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
141
142            bool                          bDevRun_;             //!< True for runs in the build directory (not installed)
143            bool                          bGraphicsLoaded_;
144
145            static Core* singletonPtr_s;
146    };
147}
148
149#endif /* _Core_H__ */
Note: See TracBrowser for help on using the repository browser.