LogPrintCtrl.cpp

Go to the documentation of this file.
00001 /**
00002  * @file LogPrintCtrl.cpp
00003  *    Declarations for a simple class that augments the logfile printing capabilities
00004  *   (see \ref Cantera::LogPrintCtrl).
00005  */
00006 /*
00007  * $Author: hkmoffa $
00008  * $Revision: 368 $
00009  * $Date: 2010-01-03 19:46:26 -0500 (Sun, 03 Jan 2010) $
00010  */
00011 /*
00012  * Copywrite 2004 Sandia Corporation. Under the terms of Contract
00013  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00014  * retains certain rights in this software.
00015  * See file License.txt for licensing information.
00016  */
00017 
00018 #include <cmath>
00019 
00020 #include <iostream>
00021 #include <fstream>
00022 
00023 #include "LogPrintCtrl.h"
00024 #include "global.h"
00025 
00026 using namespace std;
00027 
00028 namespace Cantera {
00029 
00030   LogPrintCtrl::LogPrintCtrl(int Ndec) :
00031     m_ffss(0),
00032     m_pc(0)
00033   {
00034     m_ffss = new std::ostream(m_os.rdbuf());
00035     m_pc = new PrintCtrl(*m_ffss, Ndec);
00036   }
00037   
00038   LogPrintCtrl::~LogPrintCtrl() {
00039     delete m_pc;
00040     delete m_ffss;
00041   }
00042 
00043   // Print a double using scientific notation 
00044   /*
00045    * Prints a double using scientific notation in a
00046    * fixed number of spaces
00047    * 
00048    *
00049    *  @param d  double to be printed
00050    *  @param w  Number of spaces to use
00051    *  @param p  Precision 
00052    *
00053    *
00054    */
00055   void LogPrintCtrl::pr_de_c10(const double din, int p, const int wMin, 
00056                             const int wMax) {
00057     m_pc->pr_de_c10(din, p, wMin, wMax);
00058     writelog(m_os.str());
00059     m_os.str("");
00060   }
00061 
00062   // Print a double using scientific notation 
00063   /*
00064    * Prints a double using scientific notation in a
00065    * fixed number of spaces. Rounding of the last digit is carried out
00066    * by the standard c++ printing utilities.
00067    *
00068    *  @param d  double to be printed
00069    *  @param w  Number of spaces to use
00070    *  @param p  Precision 
00071    */
00072   void LogPrintCtrl::pr_de(const double d, int sigDigIn, const int wMinIn,
00073                         const int wMaxIn) {
00074     m_pc->pr_de(d, sigDigIn, wMinIn, wMaxIn);
00075     writelog(m_os.str());
00076     m_os.str("");
00077   }
00078 
00079   // Croup a double at a certain decade level
00080   /*
00081    *    This routine will crop a floating point number at a certain
00082    *  decade lvl. In other words everything below a power of 10^Ndec
00083    *  will be deleted.
00084    *  Note, it currently does not do rounding of the last digit.
00085    *
00086    *   @param d Double to be cropped
00087    *   @param nSig Number of significant digits
00088    *   example:
00089    *    d = 1.1305E-15;
00090    *    Ndec = -16;
00091    *   This routine will return 1.1E-15
00092    *   
00093    *    d = 8.0E-17
00094    *    Ndec = -16
00095    *   This routine will return 0.0
00096    */
00097   double LogPrintCtrl::cropAbs10(const double d, int Ndec) const {
00098     return m_pc->cropAbs10(d, Ndec);
00099   }
00100 
00101   // Crop a double at a certain number of significant digits
00102   /*
00103    *  This routine will crop a floating point number at a certain
00104    *  number of significant digits. Note, it currently does 
00105    *  rounding up of the last digit.
00106    *
00107    *  example:
00108    *    d = 1.0305E-15;
00109    *    nsig = 3;
00110    *   This routine will return 1.03E-15
00111    */
00112   double LogPrintCtrl::cropSigDigits(const double d, int nSig) const {
00113     return m_pc->cropSigDigits(d, nSig);
00114   }
00115   
00116   // Set the default value of N decade
00117   /*
00118    * @param Ndec new value of Ndec
00119    *
00120    * @return returns the old value of Ndec
00121    */
00122   int LogPrintCtrl::setNdec(int Ndec) {
00123     return m_pc->setNdec(Ndec);
00124   }
00125 
00126   // Set the default significant digits to output
00127   /*
00128    * @param nSigDigits new value of the sig digits
00129    *
00130    * @return returns the old value of Ndec
00131    */
00132   int LogPrintCtrl::setSigDigits(int nSigDigits) {
00133     return m_pc->setSigDigits(nSigDigits);
00134   }
00135 
00136   // Set the default minimum width
00137   /*
00138    * @param wmin Default minimum width
00139    *
00140    * @return returns the old default
00141    */
00142   int LogPrintCtrl::setWmin(int wmin) {
00143     return m_pc->setWmin(wmin);
00144   }
00145 
00146 
00147   // Set the default maximum width
00148   /*
00149    * @param wmin Default maximum width
00150    *
00151    * @return returns the old default
00152    */
00153   int LogPrintCtrl::setWmax(int wmax) {
00154     return m_pc->setWmax(wmax);
00155   }
00156 
00157 
00158 }
Generated by  doxygen 1.6.3