Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/Core.h @ 4070

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

Merged resource branch back to the trunk. Changes:

  • Automated graphics loading by evaluating whether a GameState requires it
  • Using native Tcl library (x3n)

Windows users: Update your dependency package!

  • Property svn:eol-style set to native
File size: 5.3 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>
[3370]45#include <boost/scoped_ptr.hpp>
[1747]46#include "util/OutputHandler.h"
[3370]47#include "util/ScopeGuard.h"
48#include "util/Singleton.h"
[1505]49
50namespace orxonox
51{
[3280]52    class CoreConfiguration;
[3370]53    using boost::scoped_ptr;
[3280]54
[3196]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.
[3370]61    @remark
62        You should only create this singleton once because it destroys the identifiers!
[3196]63    */
[3370]64    class _CoreExport Core : public Singleton<Core>
[1505]65    {
[3370]66        typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
67        friend class Singleton<Core>;
68
[1505]69        public:
[3196]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            */
[3323]77            Core(const std::string& cmdLine);
[2662]78            ~Core();
[2896]79
[1505]80            void setConfigValues();
81
[3370]82            bool preUpdate(const Clock& time) throw();
83            bool postUpdate(const Clock& time) throw();
[2896]84
[3370]85            void loadGraphics();
86            void unloadGraphics();
[2662]87
88            static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
89            static void  setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
[1505]90            static const std::string& getLanguage();
[2662]91            static void  resetLanguage();
[1505]92
[3280]93            static void tsetMediaPath(const std::string& path);
[3196]94            //! Returns the path to the config files as boost::filesystem::path
[2710]95            static const boost::filesystem::path& getMediaPath();
[3196]96            //! Returns the path to the config files as boost::filesystem::path
[2710]97            static const boost::filesystem::path& getConfigPath();
[3196]98            //! Returns the path to the log files as boost::filesystem::path
[2710]99            static const boost::filesystem::path& getLogPath();
[3370]100            //! Returns the path to the root folder as boost::filesystem::path
101            static const boost::filesystem::path& getRootPath();
[3196]102            //! Returns the path to the data files as std::string
[2710]103            static std::string getMediaPathString();
[3196]104            //! Returns the path to the config files as std::string
[2710]105            static std::string getConfigPathString();
[3196]106            //! Returns the path to the log files as std::string
[2710]107            static std::string getLogPathString();
[3370]108            //! Returns the path to the root folder as std::string
109            static std::string getRootPathString();
[2710]110
[3370]111            static bool isDevelopmentRun() { return getInstance().bDevRun_; }
112
[1505]113        private:
[3196]114            Core(const Core&); //!< Don't use (undefined symbol)
[2896]115
116            void checkDevBuild();
117            void setExecutablePath();
118            void createDirectories();
119            void setThreadAffinity(int limitToCPU);
120
[3370]121            // Mind the order for the destruction!
122            scoped_ptr<SignalHandler>     signalHandler_;
123            SimpleScopeGuard              identifierDestroyer_;
124            SimpleScopeGuard              consoleCommandDestroyer_;
125            scoped_ptr<ConfigFileManager> configFileManager_;
126            scoped_ptr<Language>          languageInstance_;
127            scoped_ptr<CoreConfiguration> configuration_;
128            scoped_ptr<LuaBind>           luaBind_;
129            scoped_ptr<TclBind>           tclBind_;
130            scoped_ptr<TclThreadManager>  tclThreadManager_;
131            scoped_ptr<Shell>             shell_;
132            // graphical
133            scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
134            scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
135            scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
[2710]136
[3370]137            bool                          bDevRun_;             //!< True for runs in the build directory (not installed)
138            bool                          bGraphicsLoaded_;
[2087]139
[3370]140            static Core* singletonPtr_s;
[1505]141    };
142}
143
[1531]144#endif /* _Core_H__ */
Note: See TracBrowser for help on using the repository browser.