Cantera  2.1.2
LogPrintCtrl.h
Go to the documentation of this file.
1 /**
2  * @file LogPrintCtrl.h
3  * Declarations for a simple class that augments the logfile printing capabilities
4  * (see \ref Cantera::LogPrintCtrl).
5  */
6 /*
7  * Copyright 2004 Sandia Corporation. Under the terms of Contract
8  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
9  * retains certain rights in this software.
10  * See file License.txt for licensing information.
11  */
12 
13 #ifndef CT_LOGPRINTCTRL_H
14 #define CT_LOGPRINTCTRL_H
15 
16 #include <sstream>
17 
18 #include "cantera/base/PrintCtrl.h"
19 
20 namespace Cantera
21 {
22 
23 //! This class provides some printing and cropping utilities
24 //! for writing to the logfile.
25 /*!
26  * This class writes its output to Cantera's logfile
27  * utility. It's a wrapper around PrintCtrl object.
28  * First, we direct PrintCtrl to write to a string
29  * and then we redirect the string to the logfile utility.
30  * This is a first cut, and it's pretty much a kluge.
31  * The logfile utility, however, demands a string, and this
32  * is what I came up with.
33  *
34  * @ingroup globalUtilFuncs
35  * @deprecated To be removed in Cantera 2.2.
36  */
38 {
39 public:
40  //! Constructor
41  /*!
42  * This also serves to initialize the ticks within the object
43  *
44  * @param Ndec value of Ndec. Defaults to -1000, i.e., no decade cropping
45  */
46  LogPrintCtrl(int Ndec = -1000);
47 
48  //! Destructor
49  ~LogPrintCtrl();
50 
51  //! Print a double using scientific notation
52  /*!
53  * Prints a double using scientific notation in a
54  * fixed number of spaces.
55  *
56  * The precision of the number will be adjusted to
57  * fit into the maximum space.
58  *
59  * @param d double to be printed
60  * @param sigDigits Number of significant digits (-1 = default, means to
61  * use the default number for the object, which is initially set
62  * to 13.
63  * @param wMin Minimum number of spaces to print out
64  * @param wMax Maximum number of spaces to print out
65  */
66  void pr_de(const double d, int sigDigits = -1,
67  const int wMin = -1, const int wMax = -1);
68 
69  //! Print a double using scientific notation cropping
70  //! decade values
71  /*!
72  * Prints a double using scientific notation in a
73  * fixed number of spaces. This routine also crops
74  * number below the default decade level.
75  *
76  * The precision of the number will be adjusted to
77  * fit into the maximum space.
78  *
79  * @param d double to be printed
80  * @param sigDigits Number of significant digits (-1 = default, means to
81  * use the default number for the object, which is initially set
82  * to 13.
83  * @param wMin Minimum number of spaces to print out
84  * @param wMax Maximum number of spaces to print out
85  */
86  void pr_de_c10(const double d, int sigDigits = -1,
87  const int wMin = -1, const int wMax = -1);
88 
89  //! Crop a double at a certain number of significant digits
90  /*!
91  * This routine will crop a floating point number at a certain
92  * number of significant digits. Note, it does
93  * rounding up of the last digit.
94  *
95  * @param d Double to be cropped
96  * @param sigDigits Number of significant digits
97  * example:
98  * d = 1.0305E-15;
99  * nsig = 3;
100  * This routine will return 1.03E-15
101  */
102  double cropSigDigits(const double d, int sigDigits) const;
103 
104  //! Crop a double at a certain decade level
105  /*!
106  * This routine will crop a floating point number at a certain decade
107  * lvl. In other words everything below a power of 10^Ndec will be
108  * deleted. Note, it does rounding up of the last digit.
109  *
110  * @param d Double to be cropped
111  * @param nDecades Number of significant digits
112  * example:
113  * d = 1.1305E-15;
114  * nDecades = -16;
115  * This routine will return 1.1E-15
116  *
117  * d = 8.0E-17
118  * nDecades = -16
119  * This routine will return 0.0
120  */
121  double cropAbs10(const double d, const int nDecades) const;
122 
123  //! Set the default value of N decade
124  /*!
125  * @param nDecades new value of Ndec
126  * @return returns the old value of Ndec
127  */
128  int setNdec(int nDecades);
129 
130 
131  //! Set the default significant digits to output
132  /*!
133  * @param sigDigits new value of the sig digits
134  * @return returns the old value of Ndec
135  */
136  int setSigDigits(int sigDigits);
137 
138  //! Set the default minimum width
139  /*!
140  * @param wMin Default minimum width
141  * @return returns the old default
142  */
143  int setWmin(int wMin);
144 
145  //! Set the default maximum width
146  /*!
147  * @param wMax Default maximum width
148  * @return returns the old default
149  */
150  int setWmax(int wMax);
151 
152 private:
153  //! local stringstream class for temp output
154  std::ostringstream m_os;
155 
156  //! Pointer to the ostream where this class actually
157  //! prints its information
158  std::ostream* m_ffss;
159 
160  //! Pointer to the PrintCtrl class
162 };
163 }
164 
165 #endif
void pr_de(const double d, int sigDigits=-1, const int wMin=-1, const int wMax=-1)
Print a double using scientific notation.
int setWmin(int wMin)
Set the default minimum width.
Declarations for a simple class that augments the streams printing capabilities (see Cantera::PrintCt...
PrintCtrl * m_pc
Pointer to the PrintCtrl class.
Definition: LogPrintCtrl.h:161
int setSigDigits(int sigDigits)
Set the default significant digits to output.
~LogPrintCtrl()
Destructor.
This class provides some printing and cropping utilities for writing to the logfile.
Definition: LogPrintCtrl.h:37
double cropAbs10(const double d, const int nDecades) const
Crop a double at a certain decade level.
double cropSigDigits(const double d, int sigDigits) const
Crop a double at a certain number of significant digits.
This class provides some printing and cropping utilities.
Definition: PrintCtrl.h:50
void pr_de_c10(const double d, int sigDigits=-1, const int wMin=-1, const int wMax=-1)
Print a double using scientific notation cropping decade values.
int setNdec(int nDecades)
Set the default value of N decade.
std::ostream * m_ffss
Pointer to the ostream where this class actually prints its information.
Definition: LogPrintCtrl.h:158
std::ostringstream m_os
local stringstream class for temp output
Definition: LogPrintCtrl.h:154
int setWmax(int wMax)
Set the default maximum width.
LogPrintCtrl(int Ndec=-1000)
Constructor.