rasdaman complete source
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
debug
debug.hh
Go to the documentation of this file.
1
/*
2
* This file is part of rasdaman community.
3
*
4
* Rasdaman community is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* Rasdaman community is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16
*
17
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18
rasdaman GmbH.
19
*
20
* For more information please see <http://www.rasdaman.org>
21
* or contact Peter Baumann via <baumann@rasdaman.com>.
22
/
38
#ifndef DEBUG_HH
39
#define DEBUG_HH
40
41
/* activated through
42
#define DEBUG
43
in the target code; needs one main! */
44
45
#include <iostream>
46
47
#ifdef DEBUG
48
// enable trace macros
49
50
// allow output stream 'cout' to be overridden
51
#ifndef OSTREAM
52
#include "
raslib/rminit.hh
"
53
#define OSTREAM RMInit::logOut
54
#endif // OSTREAM
55
56
#define INDENT ". "
57
58
// no output by default
59
#define DEBUG_OUTPUT_DEFAULT false
60
64
#ifdef __cplusplus
65
# define EXTERN extern // "C"
66
#else
67
# define EXTERN extern
68
#endif
69
72
#ifdef DEBUG_MAIN
73
int
indentLevel
= 0;
74
bool
debugOutput
= DEBUG_OUTPUT_DEFAULT;
75
#else
76
EXTERN
int
indentLevel
;
77
EXTERN
bool
debugOutput
;
78
#endif // DEBUG_MAIN
79
83
#define SET_OUTPUT(b) { debugOutput = b; }
84
86
#define ENTER(a) \
87
{ \
88
if (debugOutput) \
89
{ \
90
for (int i = 0; i < indentLevel; i++) \
91
OSTREAM << INDENT; \
92
OSTREAM << "ENTER " << a << std::endl << std::flush; \
93
indentLevel++; \
94
} \
95
}
96
98
#define LEAVE(a) \
99
{ \
100
if (debugOutput) \
101
{ \
102
if (indentLevel > 0 ) \
103
indentLevel--; \
104
for (int i = 0; i < indentLevel; i++) \
105
OSTREAM << INDENT; \
106
OSTREAM << "LEAVE " << a << std::endl << std::flush; \
107
} \
108
}
109
110
112
#define TALK(a) \
113
{ \
114
if (debugOutput) \
115
{ \
116
for (int i = 0; i < indentLevel; i++) \
117
OSTREAM << INDENT; \
118
OSTREAM << a << std::endl << std::flush; \
119
} \
120
}
121
122
#else
123
// disable all trace macros
124
#undef SET_OUTPUT
125
#undef ENTER
126
#undef LEAVE
127
#undef TALK
128
129
#define SET_OUTPUT(b) {
/* SET_OUTPUT(b) */
}
130
#define ENTER(a) {
/* ENTER(a) */
}
131
#define LEAVE(a) {
/* LEAVE(a) */
}
132
#define TALK(a) {
/* TALK(a) */
}
133
134
#endif // DEBUG
135
136
#endif // DEBUG_HH
debugOutput
bool debugOutput
Definition:
debug.hh:74
rminit.hh
indentLevel
int indentLevel
variables are allocated in the main module (i.e., the source where main() resides), and referened from all other places
Definition:
debug.hh:73
Generated on Sat Mar 7 2015 22:20:35 for rasdaman complete source by
1.8.8