Cantera  2.0
Public Member Functions | Private Attributes | List of all members
LogPrintCtrl Class Reference

This class provides some printing and cropping utilities for writing to the logfile. More...

#include <LogPrintCtrl.h>

Collaboration diagram for LogPrintCtrl:
[legend]

Public Member Functions

 LogPrintCtrl (int Ndec=-1000)
 Constructor.
 
 ~LogPrintCtrl ()
 Destructor.
 
void pr_de (const double d, int sigDigits=-1, const int wMin=-1, const int wMax=-1)
 Print a double using scientific notation.
 
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.
 
double cropSigDigits (const double d, int sigDigits) const
 Crop a double at a certain number of significant digits.
 
double cropAbs10 (const double d, const int nDecades) const
 Crop a double at a certain decade level.
 
int setNdec (int nDecades)
 Set the default value of N decade.
 
int setSigDigits (int sigDigits)
 Set the default significant digits to output.
 
int setWmin (int wMin)
 Set the default minimum width.
 
int setWmax (int wMax)
 Set the default maximum width.
 

Private Attributes

std::ostringstream m_os
 local stringstream class for temp output
 
std::ostream * m_ffss
 Pointer to the ostream where this class actually prints its information.
 
PrintCtrlm_pc
 Pointer to the PrintCtrl class.
 

Detailed Description

This class provides some printing and cropping utilities for writing to the logfile.

This class writes its output to Cantera's logfile utility. It's a wrapper around PrintCtrl object. First, we direct PrintCtrl to write to a string and then we redirect the string to the logfile utility. This is a first cut, and it's pretty much a kluge. The logfile utility, however, demands a string, and this is what I came up with.

Definition at line 37 of file LogPrintCtrl.h.

Constructor & Destructor Documentation

LogPrintCtrl ( int  Ndec = -1000)

Constructor.

This also serves to initialize the ticks within the object

Parameters
Ndecvalue of Ndec. Defaults to -1000, i.e., no decade cropping

Definition at line 26 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_ffss, LogPrintCtrl::m_os, and LogPrintCtrl::m_pc.

Destructor.

Definition at line 34 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_ffss, and LogPrintCtrl::m_pc.

Member Function Documentation

void pr_de ( const double  d,
int  sigDigits = -1,
const int  wMin = -1,
const int  wMax = -1 
)

Print a double using scientific notation.

Prints a double using scientific notation in a fixed number of spaces.

The precision of the number will be adjusted to fit into the maximum space.

Parameters
ddouble to be printed
sigDigitsNumber of significant digits (-1 = default, means to use the default number for the object, which is initially set to 13.
wMinMinimum number of spaces to print out
wMaxMaximum number of spaces to print out

Definition at line 70 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_os, LogPrintCtrl::m_pc, PrintCtrl::pr_de(), and Cantera::writelog().

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.

Prints a double using scientific notation in a fixed number of spaces. This routine also crops number below the default decade level.

The precision of the number will be adjusted to fit into the maximum space.

Parameters
ddouble to be printed
sigDigitsNumber of significant digits (-1 = default, means to use the default number for the object, which is initially set to 13.
wMinMinimum number of spaces to print out
wMaxMaximum number of spaces to print out

Definition at line 52 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_os, LogPrintCtrl::m_pc, PrintCtrl::pr_de_c10(), and Cantera::writelog().

double cropSigDigits ( const double  d,
int  sigDigits 
) const

Crop a double at a certain number of significant digits.

This routine will crop a floating point number at a certain number of significant digits. Note, it does rounding up of the last digit.

Parameters
dDouble to be cropped
sigDigitsNumber of significant digits example: d = 1.0305E-15; nsig = 3; This routine will return 1.03E-15

Definition at line 112 of file LogPrintCtrl.cpp.

References PrintCtrl::cropSigDigits(), and LogPrintCtrl::m_pc.

double cropAbs10 ( const double  d,
const int  nDecades 
) const

Crop a double at a certain decade level.

This routine will crop a floating point number at a certain decade lvl. In other words everything below a power of 10^Ndec will be deleted. Note, it does rounding up of the last digit.

Parameters
dDouble to be cropped
nDecadesNumber of significant digits example: d = 1.1305E-15; nDecades = -16; This routine will return 1.1E-15

d = 8.0E-17 nDecades = -16 This routine will return 0.0

Definition at line 96 of file LogPrintCtrl.cpp.

References PrintCtrl::cropAbs10(), and LogPrintCtrl::m_pc.

int setNdec ( int  nDecades)

Set the default value of N decade.

Parameters
nDecadesnew value of Ndec
Returns
returns the old value of Ndec

Definition at line 123 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_pc, and PrintCtrl::setNdec().

int setSigDigits ( int  sigDigits)

Set the default significant digits to output.

Parameters
sigDigitsnew value of the sig digits
Returns
returns the old value of Ndec

Definition at line 134 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_pc, and PrintCtrl::setSigDigits().

int setWmin ( int  wMin)

Set the default minimum width.

Parameters
wMinDefault minimum width
Returns
returns the old default

Definition at line 145 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_pc, and PrintCtrl::setWmin().

int setWmax ( int  wMax)

Set the default maximum width.

Parameters
wMaxDefault maximum width
Returns
returns the old default

Definition at line 157 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_pc, and PrintCtrl::setWmax().

Member Data Documentation

std::ostringstream m_os
private

local stringstream class for temp output

Definition at line 165 of file LogPrintCtrl.h.

Referenced by LogPrintCtrl::LogPrintCtrl(), LogPrintCtrl::pr_de(), and LogPrintCtrl::pr_de_c10().

std::ostream* m_ffss
private

Pointer to the ostream where this class actually prints its information.

Definition at line 169 of file LogPrintCtrl.h.

Referenced by LogPrintCtrl::LogPrintCtrl(), and LogPrintCtrl::~LogPrintCtrl().

PrintCtrl* m_pc
private

The documentation for this class was generated from the following files: