Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/defs/debug.h @ 7873

Last change on this file since 7873 was 7819, checked in by patrick, 19 years ago

trunk: added a collision reaction lib. starting implementation

File size: 7.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16/*!
17 * @file debug.h
18 * @briefHandles output to console for different Verbose-Modes.
19 *
20 * There are two main modes HARD and SOFT. HARD is precessed during compileTime where SOFT is for runtime.
21 * @li HARD: One can choose between different modes. see: // DEFINE_MODULES
22 * @li SOFT: If you want each module can have its own variable for processing. just pass it to DEBUG_MODULE_SOFT
23 */
24
25#ifndef _DEBUG_H
26#define _DEBUG_H
27
28#include "confincl.h"
29#ifndef NO_SHELL
30#include "lib/shell/shell_buffer.h"
31#endif /* NO_SHELL */
32
33#include <stdio.h>
34#include <cassert>
35
36// DEFINE ERROR MODES
37#define ORX_NONE            0
38#define ORX_ERR             1
39#define ORX_WARN            2
40#define ORX_INFO            3
41#define ORX_DEBUG           4
42#define ORX_vDEBUG          5
43
44extern int verbose;
45
46//definitions
47#ifndef MODULAR_DEBUG
48 #define HARD_DEBUG_LEVEL ORX_DEBUG
49 #define SOFT_DEBUG_LEVEL verbose
50#else /* MODULAR_DEBUG */
51 #ifndef DEBUG_MODULE_SOFT
52  #define SOFT_DEBUG_LEVEL verbose
53 #else /* DEBUG_MODULE_SOFT */
54  #define SOFT_DEBUG_LEVEL DEBUG_MODULE_SOFT
55 #endif /* DEBUG_MODULE_SOFT */
56
57 #ifndef DEBUG_SPECIAL_MODULE
58  #define HARD_DEBUG_LEVEL DEBUG
59 #else /* DEBUG_SPECIAL_MODULE */
60  ////////////////////
61  // DEFINE MODULES //
62  ////////////////////
63  // FRAMEWORK
64  #define DEBUG_MODULE_BASE                  2
65  #define DEBUG_MODULE_ORXONOX               2
66  #define DEBUG_MODULE_WORLD                 2
67  #define DEBUG_MODULE_NETWORK               2
68
69  // LOADING
70  #define DEBUG_MODULE_LOAD                  2
71  #define DEBUG_MODULE_IMPORTER              2
72
73  // ENGINES
74  #define DEBUG_MODULE_GRAPHICS              2
75  #define DEBUG_MODULE_EVENT                 2
76  #define DEBUG_MODULE_PHYSICS               2
77  #define DEBUG_MODULE_GARBAGE_COLLECTOR     2
78  #define DEBUG_MODULE_OBJECT_MANAGER        2
79  #define DEBUG_MODULE_ANIM                  2
80  #define DEBUG_MODULE_COLLISION_DETECTION   2
81  #define DEBUG_MODULE_COLLISION_REACTION    2
82  #define DEBUG_MODULE_SPATIAL_SEPARATION    2
83  #define DEBUG_MODULE_GUI                   2
84  #define DEBUG_MODULE_SOUND                 2
85
86  // MISC
87  #define DEBUG_MODULE_TRACK_MANAGER         2
88  #define DEBUG_MODULE_MATH                  2
89
90  #define DEBUG_MODULE_PNODE                 2
91  #define DEBUG_MODULE_WORLD_ENTITY          2
92
93  #define DEBUG_MODULE_STORY_ENTITY          2
94  #define DEBUG_MODULE_GAME_RULES            2
95
96  #define DEBUG_MODULE_WEAPON                2
97
98  #define HARD_DEBUG_LEVEL DEBUG_SPECIAL_MODULE
99
100 #endif /* DEBUG_SPECIAL_MODULE */
101#endif /* MODULAR_DEBUG */
102
103///////////////////////////////////////////////////
104/// PRINTF: prints with filename and linenumber ///
105///////////////////////////////////////////////////
106#define PRINTFORX_NONE    PRINTF0
107#define PRINTFORX_ERR     PRINTF1
108#define PRINTFORX_WARN    PRINTF2
109#define PRINTFORX_INFO    PRINTF3
110#define PRINTFORX_DEBUG   PRINTF4
111#define PRINTFORX_VDEBUG  PRINTF5
112
113#if DEBUG_LEVEL <= 3
114#define PRINTF(x)        PRINT(x)
115#endif
116#ifndef NO_SHELL
117#define PRINT_EXEC       OrxShell::ShellBuffer::addBufferLineStatic
118#define COUT_EXEC        std::cout
119#else /* NO_SHELL */
120#define PRINT_EXEC       printf
121#define COUT_EXEC        std::cout
122#endif
123
124#ifndef PRINTF
125#ifdef ORX_DEBUG
126
127#define PRINTF(x) \
128           PRINTF ## x
129
130#if HARD_DEBUG_LEVEL >= ORX_ERR
131#define PRINTF1 \
132    if (SOFT_DEBUG_LEVEL >= ORX_ERR) \
133      printf("(EE)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
134#else
135#define PRINTF1 if (ORX_NONE)
136#endif
137
138#if HARD_DEBUG_LEVEL >= ORX_WARN
139#define PRINTF2 \
140     if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
141       printf("(WW)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
142
143#else
144#define PRINTF2 if (ORX_NONE)
145#endif
146
147#if HARD_DEBUG_LEVEL >= ORX_INFO
148#define PRINTF3 \
149     if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
150       printf("(II)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
151#else
152#define PRINTF3 if (ORX_NONE)
153#endif
154
155#if HARD_DEBUG_LEVEL >= ORX_DEBUG
156#define PRINTF4 \
157     if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
158       printf("(DD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
159#else
160#define PRINTF4 if (ORX_NONE)
161#endif
162
163#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
164#define PRINTF5 \
165     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
166       printf("(VD)::%s:%d:", __FILE__, __LINE__) && PRINT_EXEC
167#else
168#define PRINTF5 if (ORX_NONE)
169#endif
170
171#else
172#define PRINTF(x) if (ORX_NONE)
173#endif
174
175#define PRINTF0 \
176    printf("%s:%d::", __FILE__, __LINE__) && PRINT_EXEC
177#endif
178
179///////////////////////////////////////////////////
180///  PRINT: just prints output as is            ///
181///////////////////////////////////////////////////
182#define PRINTORX_NONE    PRINT0
183#define PRINTORX_ERR     PRINT1
184#define PRINTORX_WARN    PRINT2
185#define PRINTORX_INFO    PRINT3
186#define PRINTORX_DEBUG   PRINT4
187#define PRINTORX_vDEBUG  PRINT5
188
189#ifdef  DEBUG_LEVEL
190#define PRINT(x) \
191  PRINT ## x
192
193#if HARD_DEBUG_LEVEL >= ORX_ERR
194#define PRINT1  \
195  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
196    PRINT_EXEC
197#else
198#define PRINT1 if (ORX_NONE)
199#endif
200
201#if HARD_DEBUG_LEVEL >= ORX_WARN
202#define PRINT2 \
203  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
204    PRINT_EXEC
205
206#else
207#define PRINT2 if (ORX_NONE)
208#endif
209
210#if HARD_DEBUG_LEVEL >= ORX_INFO
211#define PRINT3 \
212  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
213    PRINT_EXEC
214#else
215#define PRINT3 if (ORX_NONE)
216#endif
217
218#if HARD_DEBUG_LEVEL >= ORX_DEBUG
219#define PRINT4 \
220  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
221    PRINT_EXEC
222#else
223#define PRINT4 if (ORX_NONE)
224#endif
225
226#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
227#define PRINT5 \
228     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
229       PRINT_EXEC
230#else
231#define PRINT5 if (ORX_NONE)
232#endif
233
234
235#else
236#define PRINT(x) if (ORX_NONE)
237#endif
238
239#define PRINT0 \
240  PRINT_EXEC
241
242
243
244////////////////////////////////////////////////////////
245///  COUT: just prints output as is with std::cout   ///
246////////////////////////////////////////////////////////
247#define COUTORX_NONE    COUT0
248#define COUTORX_ERR     COUT1
249#define COUTORX_WARN    COUT2
250#define COUTORX_INFO    COUT3
251#define COUTORX_DEBUG   COUT4
252#define COUTORX_vDEBUG  COUT5
253
254#ifdef  DEBUG_LEVEL
255#define COUT(x) \
256  COUT ## x
257
258#if HARD_DEBUG_LEVEL >= ORX_ERR
259#define COUT1  \
260  if (SOFT_DEBUG_LEVEL >= ORX_ERR)  \
261    COUT_EXEC
262#else
263#define COUT1 if (ORX_NONE)\
264    COUT_EXEC
265#endif
266
267#if HARD_DEBUG_LEVEL >= ORX_WARN
268#define COUT2 \
269  if (SOFT_DEBUG_LEVEL >= ORX_WARN) \
270    COUT_EXEC
271
272#else
273#define COUT2 if (ORX_NONE) \
274    COUT_EXEC
275#endif
276
277#if HARD_DEBUG_LEVEL >= ORX_INFO
278#define COUT3 \
279  if (SOFT_DEBUG_LEVEL >= ORX_INFO) \
280    COUT_EXEC
281#else
282#define COUT3 if (ORX_NONE) \
283    COUT_EXEC
284#endif
285
286#if HARD_DEBUG_LEVEL >= ORX_DEBUG
287#define COUT4 \
288  if (SOFT_DEBUG_LEVEL >= ORX_DEBUG) \
289    COUT_EXEC
290#else
291#define COUT4 if (ORX_NONE) \
292    COUT_EXEC
293#endif
294
295#if HARD_DEBUG_LEVEL >= ORX_vDEBUG
296#define COUT5 \
297     if (SOFT_DEBUG_LEVEL >= ORX_vDEBUG) \
298       COUT_EXEC
299#else
300#define COUT5 if (ORX_NONE) \
301    COUT_EXEC
302#endif
303
304
305#else
306#define COUT(x) if (ORX_NONE) \
307    COUT_EXEC
308#endif
309
310#define COUT0 \
311  COUT_EXEC
312
313
314#endif /* _DEBUG_H */
Note: See TracBrowser for help on using the repository browser.