1 | using namespace std;
|
---|
2 |
|
---|
3 | #include "Helpers/MemDebug.hpp"
|
---|
4 |
|
---|
5 | #include "info.hpp"
|
---|
6 | #include "verbose.hpp"
|
---|
7 | #include <iostream>
|
---|
8 |
|
---|
9 | /** Prints the tabs according to verbosity stored in the temporary constructed class.
|
---|
10 | * \param &ost stream to extend with tabs
|
---|
11 | * \return &ost stream with tabs
|
---|
12 | */
|
---|
13 | ostream& Verbose::print (ostream &ost) const
|
---|
14 | {
|
---|
15 | for (int i=Verbosity+Info::verbosity;i--;)
|
---|
16 | ost.put('\t');
|
---|
17 | //Log() << Verbose(0) << "Verbose(.) called." << endl;
|
---|
18 | return ost;
|
---|
19 | };
|
---|
20 |
|
---|
21 | /** States whether current output message should be print or not.
|
---|
22 | * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel.
|
---|
23 | * \param verbosityLevel given global level of verbosity
|
---|
24 | * \return true - do output, false - don't
|
---|
25 | */
|
---|
26 | bool Verbose::DoOutput(int verbosityLevel) const
|
---|
27 | {
|
---|
28 | return (verbosityLevel >= Verbosity+Info::verbosity);
|
---|
29 | };
|
---|
30 |
|
---|
31 | /** States whether current error output message should be print or not.
|
---|
32 | * Compares Verbose::Verbosity against \a verbosityLevel.
|
---|
33 | * \param verbosityLevel given global level of verbosity
|
---|
34 | * \return true - do output, false - don't
|
---|
35 | */
|
---|
36 | bool Verbose::DoErrorOutput(int verbosityLevel) const
|
---|
37 | {
|
---|
38 | return (verbosityLevel >= Verbosity);
|
---|
39 | };
|
---|
40 |
|
---|
41 | /** Operator for the Verbose(arg) call.
|
---|
42 | * Constructs temporary a Verbose class object, wherein the verbosity is stored.
|
---|
43 | * Then << is called, which calls Verbose's print which adds the tabs and returns the stream.
|
---|
44 | * \param &ost stream to extend
|
---|
45 | * \param &m pointer to created Verbose object
|
---|
46 | * \return &ost
|
---|
47 | */
|
---|
48 | ostream& operator<<(ostream& ost,const Verbose& m)
|
---|
49 | {
|
---|
50 | return m.print(ost);
|
---|
51 | };
|
---|
52 |
|
---|
53 | /** Prints the tabs according to verbosity stored in the temporary constructed class.
|
---|
54 | * Note that highest bit is set artificially to give number of bits to print
|
---|
55 | * \param &ost stream to extend with tabs
|
---|
56 | * \return &ost stream with tabs
|
---|
57 | */
|
---|
58 | ostream& Binary::print (ostream &ost) const
|
---|
59 | {
|
---|
60 | int bits = 1, counter = 1;
|
---|
61 | while ((bits = 1 << counter) < BinaryNumber)
|
---|
62 | counter++;
|
---|
63 | for (int i=0;i<counter-1;i++) {
|
---|
64 | if ((BinaryNumber & (1 << i)) == 0)
|
---|
65 | ost.put('0');
|
---|
66 | else
|
---|
67 | ost.put('1');
|
---|
68 | }
|
---|
69 | ost.put('b');
|
---|
70 | //Log() << Verbose(0) << "Binary(.) called." << endl;
|
---|
71 | return ost;
|
---|
72 | };
|
---|
73 |
|
---|
74 | /** Operator for the Binary(arg) call.
|
---|
75 | * Constructs temporary a Verbose class object, wherein the Binary is stored.
|
---|
76 | * Then << is called, which calls Binary's print which adds the tabs and returns the stream.
|
---|
77 | * \param &ost stream to extend
|
---|
78 | * \param &m pointer to created Binary object
|
---|
79 | * \return &ost
|
---|
80 | */
|
---|
81 | ostream& operator<<(ostream& ost,const Binary& m)
|
---|
82 | {
|
---|
83 | return m.print(ost);
|
---|
84 | };
|
---|