libStatGen Software 1
Loading...
Searching...
No Matches
DoubleParameter Class Reference
Inheritance diagram for DoubleParameter:
Collaboration diagram for DoubleParameter:

Public Member Functions

 DoubleParameter (char c, const char *desc, double &v)
virtual void Status ()
DoubleParameterSetPrecision (int precision)
Public Member Functions inherited from Parameter
 Parameter (char c, const char *desc, void *v)
virtual bool Read (int argc, char **argv, int argn)
virtual void addParamsToString (String &params)
void SetWarningBuffer (String &buffer)
void warning (const char *format,...)

Protected Member Functions

virtual void Translate (const char *value)
virtual bool TranslateExtras (const char *value, const char *extras)

Protected Attributes

int precision
Protected Attributes inherited from Parameter
char ch
char * description
void * var
Stringwarnings
bool myNoPhoneHome
String myVersion

Additional Inherited Members

Static Public Member Functions inherited from Parameter
static void SetNameLen (int len)
static void SetStatusLen (int len)
Static Protected Member Functions inherited from Parameter
static bool CheckInteger (const char *value)
static bool CheckDouble (const char *value)
Static Protected Attributes inherited from Parameter
static const char PARAM_STR_SEP = ','
static int nameCol = 30
static int statusCol = 15

Detailed Description

Definition at line 141 of file Parameters.h.

Constructor & Destructor Documentation

◆ DoubleParameter()

DoubleParameter::DoubleParameter ( char c,
const char * desc,
double & v )

Definition at line 130 of file Parameters.cpp.

131 : Parameter(c, desc, &v)
132{
133 precision = 2;
134}

Member Function Documentation

◆ SetPrecision()

DoubleParameter & DoubleParameter::SetPrecision ( int precision)
inline

Definition at line 148 of file Parameters.h.

149 {
150 this->precision = precision;
151
152 return *this;
153 }

◆ Status()

void DoubleParameter::Status ( )
virtual

Implements Parameter.

Definition at line 154 of file Parameters.cpp.

155{
156 double absolute_value = fabs(* (double *) var);
157
158 if (*(double *) var == _NAN_)
159 fprintf(stderr, "%*s : %*s (-%c99.999)\n", nameCol, description,
160 statusCol, "NAN", ch);
161 else if (absolute_value >= 0.00095)
162 fprintf(stderr, "%*s : % *.*f (-%c99.999)\n", nameCol, description,
163 statusCol, precision, * (double *) var, ch);
164 else if (absolute_value <= 1e-15)
165 fprintf(stderr, "%*s : % *.0f (-%c99.999)\n", nameCol, description,
166 statusCol, * (double *) var, ch);
167 else
168 fprintf(stderr, "%*s : %*.0e (-%c99.999)\n", nameCol, description,
169 statusCol, *(double *) var, ch);
170}

◆ Translate()

void DoubleParameter::Translate ( const char * value)
protectedvirtual

Implements Parameter.

Definition at line 136 of file Parameters.cpp.

137{
138 if (value[0])
139 *(double *) var = atof(value);
140 else
141 *(double *) var = _NAN_;
142}

◆ TranslateExtras()

bool DoubleParameter::TranslateExtras ( const char * value,
const char * extras )
protectedvirtual

Reimplemented from Parameter.

Definition at line 144 of file Parameters.cpp.

145{
146 if (value[0] != 0 || !CheckDouble(extras))
147 return false;
148
149 Translate(extras);
150
151 return true;
152}

Member Data Documentation

◆ precision

int DoubleParameter::precision
protected

Definition at line 159 of file Parameters.h.


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