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