Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10012 was 9550, checked in by landauf, 12 years ago

merged testing branch back to trunk. unbelievable it took me 13 months to finish this chore…

  • Property svn:eol-style set to native
File size: 7.9 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 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @ingroup Output
32    @brief Defines output levels and output contexts.
33*/
34
35#ifndef _OutputDefinitions_H__
36#define _OutputDefinitions_H__
37
38#include "util/UtilPrereqs.h"
39#include <string>
40
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*/
49#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
50    #define REGISTER_OUTPUT_CONTEXT(name) \
51        const OutputContextContainer& name() { static OutputContextContainer context = registerContext(#name); return context; }
52#else
53    #define REGISTER_OUTPUT_CONTEXT(name) \
54        const OutputContextContainer& name() { return registerContext(#name); }
55#endif
56
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
65    individually by derivatives of orxonox::SubcontextOutputListener.
66*/
67#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
68    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
69        const OutputContextContainer& subname() { static const OutputContextContainer context = registerContext(#name, #subname); return context; }
70#else
71    #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
72        const OutputContextContainer& subname() { return registerContext(#name, #subname); }
73#endif
74
75// tolua_begin
76namespace orxonox
77{
78    namespace level
79    {
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        */
84        enum OutputLevel
85        {
86            all              = 0xFFFF, ///< Level mask with all bits set to 1
87            none             = 0x0000, ///< Level mask with all bits set to 0
88
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)
102        };
103    }
104// tolua_end
105
106    using namespace level;
107
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.
110
111    /// @brief Stores all information about a context.
112    struct OutputContextContainer
113    {
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
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        }
122    };
123
124    typedef const OutputContextContainer& (OutputContextFunction)();
125
126    /**
127        @brief Registers a context.
128        This is a shortcut to OutputManager::registerContext() to avoid the inclusion of its header file.
129    */
130    extern _UtilExport const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
131
132    namespace context
133    {
134        static const OutputContextMask all       = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1
135        static const OutputContextMask none      = 0x0000000000000000ull; ///< Context mask, all bits set to 0
136
137        static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
138
139        namespace
140        {
141            REGISTER_OUTPUT_CONTEXT(undefined); ///< "undefined" context which is implicitly used for all output that has no explicit context
142
143            REGISTER_OUTPUT_CONTEXT(ogre);
144            REGISTER_OUTPUT_CONTEXT(cegui);
145            REGISTER_OUTPUT_CONTEXT(lua);
146            REGISTER_OUTPUT_CONTEXT(tcl);
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);
155            REGISTER_OUTPUT_CONTEXT(templates);
156            REGISTER_OUTPUT_CONTEXT(loader);
157            REGISTER_OUTPUT_CONTEXT(xml);
158            REGISTER_OUTPUT_CONTEXT(network);
159            REGISTER_OUTPUT_CONTEXT(packets);
160            REGISTER_OUTPUT_CONTEXT(master_server);
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);
166            REGISTER_OUTPUT_CONTEXT(triggers);
167            REGISTER_OUTPUT_CONTEXT(docking);
168
169            namespace misc
170            {
171                REGISTER_OUTPUT_SUBCONTEXT(misc, executor);
172                REGISTER_OUTPUT_SUBCONTEXT(misc, factory);
173                REGISTER_OUTPUT_SUBCONTEXT(misc, gui);
174                REGISTER_OUTPUT_SUBCONTEXT(misc, overlays);
175                REGISTER_OUTPUT_SUBCONTEXT(misc, script);
176            }
177        }
178    }
179} // tolua_export
180
181#endif /* _OutputDefinitions_H__ */
Note: See TracBrowser for help on using the repository browser.