Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/unity_build/src/libraries/core/Core.h @ 8669

Last change on this file since 8669 was 8524, checked in by rgrieder, 13 years ago

Fixed a serious problem with the debug levels for the Shells by introducing DevModeListener and moving the debug levels to the Shell again..

  • Property svn:eol-style set to native
File size: 5.5 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    @defgroup CoreGame Core and Game
32    @ingroup Management
33*/
34
35/**
36    @file
37    @ingroup Management CoreGame
38    @brief Declaration of the Core singleton which is used to configure the program basics.
39*/
40
41#ifndef _Core_H__
42#define _Core_H__
43
44#include "CorePrereqs.h"
45
46#include <string>
47#include <loki/ScopeGuard.h>
48
49#include "util/DestructionHelper.h"
50#include "util/Singleton.h"
51#include "OrxonoxClass.h"
52
53namespace orxonox
54{
55    //! Informs about changes in the Development Mode.
56    class DevModeListener : virtual public OrxonoxClass
57    {
58    public:
59        DevModeListener();
60        virtual ~DevModeListener() {}
61        virtual void devModeChanged(bool value) = 0;
62    };
63
64    /**
65    @brief
66        The Core class is a singleton used to configure the program basics.
67    @remark
68        You should only create this singleton once because it destroys the identifiers!
69    */
70    class _CoreExport Core : public Singleton<Core>, public OrxonoxClass
71    {
72        friend class Singleton<Core>;
73        friend class Game;
74
75        public:
76            /**
77            @brief
78                Determines the executable path, checks for build directory runs, creates
79                the output directories and sets up the other core library singletons.
80            @throws
81                GeneralException
82            */
83            Core(const std::string& cmdLine);
84
85            /// Leave empty and use destroy() instead
86            ~Core() {}
87            /// Destructor that also executes when the object fails to construct
88            void destroy();
89
90            void setConfigValues();
91
92            //! Returns the configured language.
93            const std::string& getLanguage()
94                { return this->language_; }
95            void resetLanguage();
96
97            void updateLastLevelTimestamp();
98            inline long long getLastLevelTimestamp() const
99                { return this->lastLevelTimestamp_; }
100
101            void updateOgreConfigTimestamp();
102            inline long long getOgreConfigTimestamp() const
103                { return this->ogreConfigTimestamp_; }
104
105            //! Developers bit. If returns false, some options are not available as to not confuse the normal user.
106            inline bool inDevMode(void) const
107                { return this->bDevMode_; }
108
109        private:
110            Core(const Core&); //!< Don't use (undefined symbol)
111
112            void devModeChanged();
113            void languageChanged();
114            void initRandomNumberGenerator();
115
116            void preUpdate(const Clock& time);
117            void postUpdate(const Clock& time);
118
119            void loadGraphics();
120            void unloadGraphics();
121
122            void setThreadAffinity(int limitToCPU);
123
124            PathConfig*               pathConfig_;
125            DynLibManager*            dynLibManager_;
126            SignalHandler*            signalHandler_;
127            ConfigFileManager*        configFileManager_;
128            Language*                 languageInstance_;
129            IOConsole*                ioConsole_;
130            TclBind*                  tclBind_;
131            TclThreadManager*         tclThreadManager_;
132            Scope<ScopeID::Root>*     rootScope_;
133            // graphical
134            GraphicsManager*          graphicsManager_;            //!< Interface to OGRE
135            InputManager*             inputManager_;               //!< Interface to OIS
136            GUIManager*               guiManager_;                 //!< Interface to GUI
137            Scope<ScopeID::Graphics>* graphicsScope_;
138
139            bool                      bGraphicsLoaded_;
140            int                       debugLevelLogFile_;          //!< The debug level for the log file (belongs to OutputHandler)
141            std::string               language_;                   //!< The language
142            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
143            bool                      bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
144            long long                 lastLevelTimestamp_;         ///< Timestamp when the last level was started
145            long long                 ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
146            bool                      bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
147
148            /// Helper object that executes the surrogate destructor destroy()
149            DestructionHelper<Core>   destructionHelper_;
150
151            static Core*              singletonPtr_s;
152    };
153}
154
155#endif /* _Core_H__ */
Note: See TracBrowser for help on using the repository browser.