1 #ifndef AVR_VERBOSEINFO_H
2 #define AVR_VERBOSEINFO_H
8 enum Verbosity
{ NONE
= 0, WARN
= 1, INFO
= 2, DBG
= 3 };
13 VerboseInfo() : verbosity(0) {}
16 void setVerbosity(Verbosity verbosity
);
17 void setVerbosity(int verbosity
);
18 void increaseVerbosity();
21 bool shouldOutput(Verbosity vb
) const {
22 return ((int)vb
> verbosity
);
28 Printer(const VerboseInfo
& vi
, Verbosity vb
,
30 : vi(vi
), vb(vb
), ostr(ostr
) {}
34 Printer
& operator <<(const T
& c
) {
35 if( vi
.shouldOutput(vb
) )
40 Printer
& operator<<(std::ostream
& (*pf
)(std::ostream
&)) {
41 if( vi
.shouldOutput(vb
) )
47 const VerboseInfo
& vi
;
52 Printer
operator ()(Verbosity vb
,
53 std::ostream
& ostr
= std::cout
) const {
54 return Printer(*this, vb
, ostr
);
61 inline void VerboseInfo::setVerbosity(Verbosity verbosity
) {
62 this->verbosity
= (int)verbosity
;
65 inline void VerboseInfo::setVerbosity(int verbosity
) {
66 this->verbosity
= verbosity
;
69 inline void VerboseInfo::increaseVerbosity() {
73 extern VerboseInfo info
;
76 #endif /* AVR_VERBOSEINFO_H */