Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource/src/core/Core.h @ 3363

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

Exception-safety for the Game and Core c'tors as well as load/unload-Graphics.

  • Property svn:eol-style set to native
File size: 5.2 KB
RevLine 
[1505]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
[2896]24 *      Reto Grieder
[1505]25 *   Co-authors:
[2896]26 *      ...
[1505]27 *
28 */
29
30/**
[3196]31@file
32@brief
33    Declaration of the Core class.
34@details
[1524]35    The Core class is a singleton, only used to configure some variables
[1505]36    in the core through the config-file.
37*/
38
[1531]39#ifndef _Core_H__
40#define _Core_H__
[1505]41
42#include "CorePrereqs.h"
43
[2662]44#include <cassert>
[3363]45#include <boost/scoped_ptr.hpp>
[1747]46#include "util/OutputHandler.h"
[3363]47#include "util/ScopeGuard.h"
[1505]48
49namespace orxonox
50{
[3280]51    class CoreConfiguration;
[3363]52    using boost::scoped_ptr;
[3280]53
[3196]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 media, config and log path.
59        It determines those by the use of platform specific functions.
60    */
[3280]61    class _CoreExport Core
[1505]62    {
[3363]63        typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
64
[1505]65        public:
[3196]66            /**
67            @brief
68                Determines the executable path, checks for build directory runs, creates
69                the output directories and sets up the other core library singletons.
70            @throws
71                GeneralException
72            */
[3323]73            Core(const std::string& cmdLine);
[2662]74            ~Core();
[2896]75
[1505]76            void setConfigValues();
77
[3349]78            bool preUpdate(const Clock& time) throw();
79            bool postUpdate(const Clock& time) throw();
[2896]80
[3343]81            void loadGraphics();
82            void unloadGraphics();
83
[2662]84            static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
85
86            static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
87            static void  setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
[1505]88            static const std::string& getLanguage();
[2662]89            static void  resetLanguage();
[1505]90
[3280]91            static void tsetMediaPath(const std::string& path);
[3196]92            //! Returns the path to the config files as boost::filesystem::path
[2710]93            static const boost::filesystem::path& getMediaPath();
[3196]94            //! Returns the path to the config files as boost::filesystem::path
[2710]95            static const boost::filesystem::path& getConfigPath();
[3196]96            //! Returns the path to the log files as boost::filesystem::path
[2710]97            static const boost::filesystem::path& getLogPath();
[3345]98            //! Returns the path to the root folder as boost::filesystem::path
99            static const boost::filesystem::path& getRootPath();
[3196]100            //! Returns the path to the data files as std::string
[2710]101            static std::string getMediaPathString();
[3196]102            //! Returns the path to the config files as std::string
[2710]103            static std::string getConfigPathString();
[3196]104            //! Returns the path to the log files as std::string
[2710]105            static std::string getLogPathString();
[3345]106            //! Returns the path to the root folder as std::string
107            static std::string getRootPathString();
[2710]108
[3345]109            static bool isDevelopmentRun() { return getInstance().bDevRun_; }
110
[1505]111        private:
[3196]112            Core(const Core&); //!< Don't use (undefined symbol)
[2896]113
114            void checkDevBuild();
115            void setExecutablePath();
116            void createDirectories();
117            void setThreadAffinity(int limitToCPU);
118
[3363]119            // Mind the order for the destruction!
120            scoped_ptr<SignalHandler>     signalHandler_;
121            SimpleScopeGuard              identifierDestroyer_;
122            SimpleScopeGuard              consoleCommandDestroyer_;
123            scoped_ptr<ConfigFileManager> configFileManager_;
124            scoped_ptr<Language>          languageInstance_;
125            scoped_ptr<CoreConfiguration> configuration_;
126            scoped_ptr<LuaBind>           luaBind_;
127            scoped_ptr<TclBind>           tclBind_;
128            scoped_ptr<TclThreadManager>  tclThreadManager_;
129            scoped_ptr<Shell>             shell_;
[3349]130            // graphical
[3363]131            scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
132            scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
133            scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
[2710]134
[3363]135            bool                          bDevRun_;             //!< True for runs in the build directory (not installed)
136            bool                          bGraphicsLoaded_;
[2087]137
[2662]138            static Core* singletonRef_s;
[1505]139    };
140}
141
[1531]142#endif /* _Core_H__ */
Note: See TracBrowser for help on using the repository browser.