[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 | */ |
---|
[8778] | 49 | #define REGISTER_OUTPUT_CONTEXT(name) \ |
---|
[8833] | 50 | const OutputContextContainer& name() { static const OutputContextContainer& context = registerContext(#name); return context; } |
---|
[8778] | 51 | |
---|
[8848] | 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 |
---|
[8853] | 60 | individually by derivatives of orxonox::SubcontextOutputListener. |
---|
[8848] | 61 | */ |
---|
[8833] | 62 | #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \ |
---|
| 63 | const OutputContextContainer& subname() { static const OutputContextContainer& context = registerContext(#name, #subname); return context; } |
---|
| 64 | |
---|
[8840] | 65 | // tolua_begin |
---|
[8765] | 66 | namespace orxonox |
---|
| 67 | { |
---|
| 68 | namespace level |
---|
| 69 | { |
---|
[8848] | 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 | */ |
---|
[8808] | 74 | enum OutputLevel |
---|
| 75 | { |
---|
[8848] | 76 | all = 0xFFFF, ///< Level mask with all bits set to 1 |
---|
| 77 | none = 0x0000, ///< Level mask with all bits set to 0 |
---|
[8799] | 78 | |
---|
[8848] | 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) |
---|
[8808] | 92 | }; |
---|
[8765] | 93 | } |
---|
[8840] | 94 | // tolua_end |
---|
[8765] | 95 | |
---|
[8808] | 96 | using namespace level; |
---|
| 97 | |
---|
[8848] | 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. |
---|
[8765] | 100 | |
---|
[8848] | 101 | /// @brief Stores all information about a context. |
---|
[8833] | 102 | struct OutputContextContainer |
---|
| 103 | { |
---|
[8848] | 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 |
---|
[8833] | 107 | }; |
---|
[8771] | 108 | |
---|
[8833] | 109 | typedef const OutputContextContainer& (OutputContextFunction)(); |
---|
| 110 | |
---|
[8848] | 111 | /** |
---|
| 112 | @brief Registers a context. |
---|
| 113 | This is a shortcut to OutputManager::registerContext() to avoid the inclusion of its header file. |
---|
| 114 | */ |
---|
[8833] | 115 | extern _UtilExport const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = ""); |
---|
| 116 | |
---|
[8765] | 117 | namespace context |
---|
| 118 | { |
---|
[8879] | 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 |
---|
[8765] | 121 | |
---|
[8848] | 122 | static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts |
---|
[8833] | 123 | |
---|
[8777] | 124 | namespace |
---|
| 125 | { |
---|
[8848] | 126 | REGISTER_OUTPUT_CONTEXT(undefined); ///< "undefined" context which is implicitly used for all output that has no explicit context |
---|
[8777] | 127 | |
---|
[8805] | 128 | REGISTER_OUTPUT_CONTEXT(ogre); |
---|
| 129 | REGISTER_OUTPUT_CONTEXT(cegui); |
---|
[8796] | 130 | REGISTER_OUTPUT_CONTEXT(lua); |
---|
| 131 | REGISTER_OUTPUT_CONTEXT(tcl); |
---|
[8805] | 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); |
---|
[8806] | 140 | REGISTER_OUTPUT_CONTEXT(templates); |
---|
| 141 | REGISTER_OUTPUT_CONTEXT(loader); |
---|
| 142 | REGISTER_OUTPUT_CONTEXT(xml); |
---|
[8807] | 143 | REGISTER_OUTPUT_CONTEXT(network); |
---|
| 144 | REGISTER_OUTPUT_CONTEXT(packets); |
---|
| 145 | REGISTER_OUTPUT_CONTEXT(master_server); |
---|
[8809] | 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); |
---|
[8811] | 151 | REGISTER_OUTPUT_CONTEXT(triggers); |
---|
[8809] | 152 | REGISTER_OUTPUT_CONTEXT(docking); |
---|
[8833] | 153 | |
---|
| 154 | namespace misc |
---|
| 155 | { |
---|
[8835] | 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); |
---|
[8833] | 161 | } |
---|
[8777] | 162 | } |
---|
[8765] | 163 | } |
---|
[8840] | 164 | } // tolua_export |
---|
[8765] | 165 | |
---|
| 166 | #endif /* _OutputDefinitions_H__ */ |
---|