itpp_sci
1.0.0
it++ based simulation framework for scicoslab, scilab and scipy
Main Page
Related Pages
Modules
Classes
include
dbg.hpp
1
#ifndef _DBG_HPP_
2
#define _DBG_HPP_
3
4
#include <iostream>
5
6
using
std::ostream;
7
8
// This is a function pointer that takes a stream as input and returns the stream.
9
typedef
ostream& (*STRFUNC)(ostream&);
10
11
class
dbg
12
{
13
private
:
14
bool
m_output;
15
16
public
:
17
dbg(
int
level)
18
: m_output(level != 0)
19
{}
20
21
// This covers all except for std::endl
22
template
<
typename
T> dbg& operator<<(T t)
23
{
24
if
(m_output)
25
{
26
std::cout << t;
27
return
*
this
;
28
}
29
else
30
return
*
this
;
31
}
32
33
// This covers functions like std::endl
34
dbg& operator<<(STRFUNC func)
35
{
36
if
(m_output)
37
{
38
// Apply the function
39
func(std::cout);
40
}
41
// But return the debug object
42
return
*
this
;
43
}
44
45
};
46
47
#endif
Generated on Wed Dec 30 2015 18:14:13 for itpp_sci by
1.8.9.1