Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/Core.h @ 10121

Last change on this file since 10121 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

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