| [f66195] | 1 | using namespace std;
 | 
|---|
 | 2 | 
 | 
|---|
| [112b09] | 3 | #include "Helpers/MemDebug.hpp"
 | 
|---|
 | 4 | 
 | 
|---|
| [8725ed] | 5 | #include "info.hpp"
 | 
|---|
| [f66195] | 6 | #include "verbose.hpp"
 | 
|---|
| [5e8e02] | 7 | #include <iostream>
 | 
|---|
| [14de469] | 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 | {
 | 
|---|
| [8725ed] | 15 |   for (int i=Verbosity+Info::verbosity;i--;)
 | 
|---|
| [042f82] | 16 |     ost.put('\t');
 | 
|---|
| [e138de] | 17 |   //Log() << Verbose(0) << "Verbose(.) called." << endl;
 | 
|---|
| [042f82] | 18 |   return ost;
 | 
|---|
| [14de469] | 19 | };
 | 
|---|
 | 20 | 
 | 
|---|
| [06c7a3] | 21 | /** States whether current output message should be print or not.
 | 
|---|
| [90f680] | 22 |  * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel.
 | 
|---|
| [06c7a3] | 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 | {
 | 
|---|
| [8725ed] | 28 |   return (verbosityLevel >= Verbosity+Info::verbosity);
 | 
|---|
| [06c7a3] | 29 | };
 | 
|---|
 | 30 | 
 | 
|---|
| [90f680] | 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 | };
 | 
|---|
| [06c7a3] | 40 | 
 | 
|---|
| [14de469] | 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 | {
 | 
|---|
| [042f82] | 50 |   return m.print(ost);
 | 
|---|
| [14de469] | 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 | {
 | 
|---|
| [042f82] | 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');
 | 
|---|
| [e138de] | 70 |   //Log() << Verbose(0) << "Binary(.) called." << endl;
 | 
|---|
| [042f82] | 71 |   return ost;
 | 
|---|
| [14de469] | 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 | {
 | 
|---|
| [042f82] | 83 |   return m.print(ost);
 | 
|---|
| [14de469] | 84 | };
 | 
|---|