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

Private Attributes

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

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.

Deprecated:
To be removed in Cantera 2.2.

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 21 of file LogPrintCtrl.cpp.

References LogPrintCtrl::m_ffss, LogPrintCtrl::m_os, LogPrintCtrl::m_pc, and Cantera::warn_deprecated().

Destructor.

Definition at line 30 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 44 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 36 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 57 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 52 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 62 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 67 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 72 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 77 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 154 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 158 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: