Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/release2012/src/libraries/core/Core.h @ 10970

Last change on this file since 10970 was 8858, checked in by landauf, 13 years ago

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
  • 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 "OrxonoxClass.h"
50
51namespace orxonox
52{
53    //! Informs about changes in the Development Mode.
54    class DevModeListener : virtual public OrxonoxClass
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 OrxonoxClass
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.