Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/util/output/OutputDefinitions.h @ 11252

Last change on this file since 11252 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 7.9 KB
RevLine 
[8765]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 *   Co-authors:
25 *      ...
26 *
27 */
28
[8848]29/**
30    @file
31    @ingroup Output
32    @brief Defines output levels and output contexts.
33*/
34
[8765]35#ifndef _OutputDefinitions_H__
36#define _OutputDefinitions_H__
37
38#include "util/UtilPrereqs.h"
[8771]39#include <string>
[8765]40
[8848]41/**
42    @brief Defines a context function with a given name.
43    @param name Name of the context
44
45    Context functions return a reference to a OutputContextContainer. Context
46    functions (or the containers they return) can be passed to orxout() as
47    context argument.
48*/
[9550]49#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
50    #define REGISTER_OUTPUT_CONTEXT(name) \
[10317]51        inline const OutputContextContainer& name() { static OutputContextContainer context = registerContext(#name); return context; }
[9550]52#else
53    #define REGISTER_OUTPUT_CONTEXT(name) \
[10317]54        inline const OutputContextContainer& name() { return registerContext(#name); }
[9550]55#endif
[8778]56
[8848]57/**
58    @brief Defines a sub-context.
59    @param name Name of the main-context
60    @param subname Name of the sub-context
61
62    Sub-contexts act like normal contexts, except that multiple sub-contexts
63    share the context mask of their main-context. This allows contexts with
64    more descriptive names (e.g. input::keyboard) and they can be filtered
[8853]65    individually by derivatives of orxonox::SubcontextOutputListener.
[8848]66*/
[9550]67#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
68    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
[10317]69        inline const OutputContextContainer& subname() { static const OutputContextContainer context = registerContext(#name, #subname); return context; }
[9550]70#else
71    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
[10317]72        inline const OutputContextContainer& subname() { return registerContext(#name, #subname); }
[9550]73#endif
[8833]74
[8840]75// tolua_begin
[8765]76namespace orxonox
77{
78    namespace level
79    {
[8848]80        /**
81            @brief Output levels define type and importance of an output message.
82            They can be passed to the orxout() function as level argument.
83        */
[8808]84        enum OutputLevel
85        {
[8848]86            all              = 0xFFFF, ///< Level mask with all bits set to 1
87            none             = 0x0000, ///< Level mask with all bits set to 0
[8799]88
[8848]89            message          = 0x0001, ///< Output level, used for messages directed to the user (e.g. "Press any key to continue")
90            debug_output     = 0x0002, ///< Output level, used for temporary debug output while writing code
91            user_error       = 0x0004, ///< Output level, used for error messages which are important for the user
92            user_warning     = 0x0008, ///< Output level, used for warnings which are important for the user
93            user_status      = 0x0010, ///< Output level, used to notify the user about the program's state
94            user_info        = 0x0020, ///< Output level, used to provide the user with additional progress information
95            internal_error   = 0x0040, ///< Output level, used for error messages which are important for developers
96            internal_warning = 0x0080, ///< Output level, used for warnings which are important for developers
97            internal_status  = 0x0100, ///< Output level, used to log the program's internal state in the log file
98            internal_info    = 0x0200, ///< Output level, used to log information about the program's progress in the log file
99            verbose          = 0x0400, ///< Output level, usually not visible, used for unimportant debug information
100            verbose_more     = 0x0800, ///< Output level, usually not visible, used for unimportant debug information (less important than verbose)
101            verbose_ultra    = 0x1000  ///< Output level, usually not visible, used for unimportant debug information (even less important than verbose_more)
[8808]102        };
[8765]103    }
[8840]104// tolua_end
[8765]105
[8808]106    using namespace level;
107
[8848]108    typedef uint64_t OutputContextMask;  ///< Used to store the context masks. Each bit defines a context.
109    typedef uint16_t OutputContextSubID; ///< Used to store the IDs of sub-contexts. Each number except context::no_subcontext defines a sub-context.
[8765]110
[8848]111    /// @brief Stores all information about a context.
[8833]112    struct OutputContextContainer
113    {
[8848]114        OutputContextMask mask;     ///< The mask of the context (or the mask of the main-context if this container defines a sub-context)
115        OutputContextSubID sub_id;  ///< The id of the sub-context (or context::no_subcontext if this container doesn't define a sub-context)
116        std::string name;           ///< The name of this context
[9550]117
118        inline bool operator==(const OutputContextContainer& other) const
119        {
120            return this->mask == other.mask && this->sub_id == other.sub_id && this->name == other.name;
121        }
[8833]122    };
[8771]123
[8833]124    typedef const OutputContextContainer& (OutputContextFunction)();
125
[8848]126    /**
127        @brief Registers a context.
128        This is a shortcut to OutputManager::registerContext() to avoid the inclusion of its header file.
129    */
[8833]130    extern _UtilExport const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
131
[8765]132    namespace context
133    {
[11071]134        static constexpr OutputContextMask all       = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1
135        static constexpr OutputContextMask none      = 0x0000000000000000ull; ///< Context mask, all bits set to 0
[8765]136
[11071]137        static constexpr OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
[8833]138
[8777]139        namespace
140        {
[8848]141            REGISTER_OUTPUT_CONTEXT(undefined); ///< "undefined" context which is implicitly used for all output that has no explicit context
[8777]142
[8805]143            REGISTER_OUTPUT_CONTEXT(ogre);
144            REGISTER_OUTPUT_CONTEXT(cegui);
[8796]145            REGISTER_OUTPUT_CONTEXT(lua);
146            REGISTER_OUTPUT_CONTEXT(tcl);
[8805]147            REGISTER_OUTPUT_CONTEXT(identifier);
148            REGISTER_OUTPUT_CONTEXT(object_list);
149            REGISTER_OUTPUT_CONTEXT(super);
150            REGISTER_OUTPUT_CONTEXT(language);
151            REGISTER_OUTPUT_CONTEXT(commands);
152            REGISTER_OUTPUT_CONTEXT(input);
153            REGISTER_OUTPUT_CONTEXT(events);
154            REGISTER_OUTPUT_CONTEXT(config);
[8806]155            REGISTER_OUTPUT_CONTEXT(templates);
156            REGISTER_OUTPUT_CONTEXT(loader);
157            REGISTER_OUTPUT_CONTEXT(xml);
[8807]158            REGISTER_OUTPUT_CONTEXT(network);
159            REGISTER_OUTPUT_CONTEXT(packets);
160            REGISTER_OUTPUT_CONTEXT(master_server);
[8809]161            REGISTER_OUTPUT_CONTEXT(sound);
162            REGISTER_OUTPUT_CONTEXT(lod);
163            REGISTER_OUTPUT_CONTEXT(pickups);
164            REGISTER_OUTPUT_CONTEXT(quests);
165            REGISTER_OUTPUT_CONTEXT(notifications);
[8811]166            REGISTER_OUTPUT_CONTEXT(triggers);
[8809]167            REGISTER_OUTPUT_CONTEXT(docking);
[8833]168
169            namespace misc
170            {
[8835]171                REGISTER_OUTPUT_SUBCONTEXT(misc, executor);
172                REGISTER_OUTPUT_SUBCONTEXT(misc, gui);
173                REGISTER_OUTPUT_SUBCONTEXT(misc, overlays);
174                REGISTER_OUTPUT_SUBCONTEXT(misc, script);
[8833]175            }
[8777]176        }
[8765]177    }
[8840]178} // tolua_export
[8765]179
180#endif /* _OutputDefinitions_H__ */
Note: See TracBrowser for help on using the repository browser.