Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8879 was 8879, checked in by baermatt, 13 years ago

Added 'ull' to some OutputContextMasks, because of an error with LLVM GCC 4.2 (Integer constant is too large for 'long' type).

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