LogPrintCtrl.h

Go to the documentation of this file.
00001 /**
00002  * @file LogPrintCtrl.h
00003  *    Declarations for a simple class that augments the logfile printing capabilities
00004  *   (see \ref Cantera::LogPrintCtrl).
00005  */
00006 /*
00007  * $Revision: 368 $
00008  * $Date: 2010-01-03 19:46:26 -0500 (Sun, 03 Jan 2010) $
00009  */
00010 /*
00011  * Copywrite 2004 Sandia Corporation. Under the terms of Contract
00012  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00013  * retains certain rights in this software.
00014  * See file License.txt for licensing information.
00015  */
00016 
00017 #ifndef CT_LOGPRINTCTRL_H
00018 #define CT_LOGPRINTCTRL_H
00019 
00020 #include <sstream>
00021 
00022 #include "PrintCtrl.h"
00023 
00024 namespace Cantera {
00025 
00026   //! This class provides some printing and cropping utilities 
00027   //! for writing to the logfile.
00028   /*!
00029    *  This class writes its output to Cantera's logfile 
00030    *  utility. It's a wrapper around PrintCtrl object. 
00031    *  First, we direct PrintCtrl to write to a string
00032    *  and then we redirect the string to the logfile utility.
00033    *  This is a first cut, and it's pretty much a kluge.
00034    *  The logfile utility, however, demands a string, and this
00035    *  is what I came up with.
00036    *
00037    * @ingroup globalUtilFuncs
00038    *
00039    */
00040   class LogPrintCtrl {
00041   public:
00042 
00043     //! Constructor
00044     /*!
00045      * This also serves to initialize the ticks within the object
00046      *
00047      * @param Ndec value of Ndec. Defaults to -1000, i.e., 
00048      *             no decade cropping
00049      */
00050     LogPrintCtrl(int Ndec = -1000);
00051 
00052     //! Destructor
00053     ~LogPrintCtrl();
00054 
00055     //! Print a double using scientific notation
00056     /*!
00057      * Prints a double using scientific notation in a
00058      * fixed number of spaces.
00059      *
00060      * The precision of the number will be adjusted to
00061      * fit into the maximum space.
00062      *
00063      *  @param d  double to be printed
00064      *  @param sigDigits Number of significant digits
00065      *          (-1 = default, means to use the default 
00066      *           number for the object, which is initially
00067      *           set to 13.
00068      *  @param wMin Minimum number of spaces to print out
00069      *  @param wMax Maximum number of spaces to print out
00070      */
00071     void pr_de(const double d, int sigDigits = -1, 
00072                const int wMin = -1, const int wMax = -1);
00073 
00074     //! Print a double using scientific notation cropping 
00075     //! decade values
00076     /*!
00077      * Prints a double using scientific notation in a
00078      * fixed number of spaces. This routine also crops
00079      * number below the default decade level.
00080      *
00081      * The precision of the number will be adjusted to
00082      * fit into the maximum space.
00083      *
00084      *  @param d  double to be printed
00085      *  @param sigDigits Number of significant digits
00086      *          (-1 = default, means to use the default 
00087      *           number for the object, which is initially
00088      *           set to 13.
00089      *  @param wMin Minimum number of spaces to print out
00090      *  @param wMax Maximum number of spaces to print out
00091      */
00092     void pr_de_c10(const double d, int sigDigits = -1, 
00093                    const int wMin = -1, const int wMax = -1);
00094 
00095     //! Crop a double at a certain number of significant digits
00096     /*!
00097      *  This routine will crop a floating point number at a certain
00098      *  number of significant digits. Note, it does
00099      *  rounding up of the last digit.
00100      *
00101      * @param d         Double to be cropped
00102      * @param sigDigits Number of significant digits
00103      *  example:
00104      *    d = 1.0305E-15;
00105      *    nsig = 3;
00106      *   This routine will return 1.03E-15
00107      */
00108     double cropSigDigits(const double d, int sigDigits) const;
00109 
00110     //! Crop a double at a certain decade level
00111     /*!
00112      *  This routine will crop a floating point number at a certain
00113      *  decade lvl. In other words everything below a power of 10^Ndec
00114      *  will be deleted.
00115      *  Note, it does rounding up of the last digit.
00116      *
00117      *   @param d Double to be cropped
00118      *   @param nDecades Number of significant digits
00119      *   example:
00120      *    d = 1.1305E-15;
00121      *    nDecades = -16;
00122      *   This routine will return 1.1E-15
00123      *   
00124      *    d = 8.0E-17
00125      *    nDecades = -16
00126      *   This routine will return 0.0
00127      */
00128     double cropAbs10(const double d, const int nDecades) const;
00129 
00130     //! Set the default value of N decade
00131     /*!
00132      * @param nDecades new value of Ndec
00133      *
00134      * @return returns the old value of Ndec
00135      */
00136     int setNdec(int nDecades);
00137 
00138  
00139     //! Set the default significant digits to output
00140     /*!
00141      * @param sigDigits new value of the sig digits
00142      *
00143      * @return returns the old value of Ndec
00144      */
00145     int setSigDigits(int sigDigits);
00146     
00147     //! Set the default minimum width
00148     /*!
00149      * @param wMin Default minimum width
00150      *
00151      * @return returns the old default
00152      */
00153     int setWmin(int wMin);
00154 
00155     //! Set the default maximum width
00156     /*!
00157      * @param wMax Default maximum width
00158      *
00159      * @return returns the old default
00160      */
00161     int setWmax(int wMax);
00162     
00163 
00164   private:
00165 
00166     //! local stringstream class for temp output 
00167     std::ostringstream m_os;
00168 
00169     //! Pointer to the ostream where this class actually
00170     //! prints its information
00171     std::ostream *m_ffss;
00172 
00173     //! Pointer to the PrintCtrl class
00174     PrintCtrl *m_pc;
00175 
00176 
00177 
00178   };
00179 }
00180 
00181 #endif
00182 
Generated by  doxygen 1.6.3