Home

option_header Class Reference
[Options]

Records a value that denotes whether the option is on, off, or set to a given value. More...

#include <option.hxx>

Collaboration diagram for option_header:

Collaboration graph
[legend]

List of all members.

Public Member Functions

int count () const
 Returns the value of the option_header if the option type is int_option or logical_option.
void display (FILE *fp) const
 Prints the data contained in the option_header to the specified file.
logical is_default ()
 Checks the current value against the default value.
char const * name () const
 Returns the name of the option_header.
option_headernext () const
 Returns the next option_header.
logical on () const
 Returns whether the option_header is on or off if the option type is logical_option.
 option_header (char const *name, char const *init)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 option_header (char const *name, double init)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 option_header (char const *name, int init)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
void pop ()
 Pops the stack to the previous value.
void push (char const *newval)
 Pushes a new string value onto the value stack.
void push (double val)
 Pushes a new double value onto the value stack.
void push (int val)
 Pushes a new integral value onto the value stack.
void reset ()
 Resets the option_header to the default value.
void set (char const *opt)
 Sets the value of the option_header if the type is string_option.
void set (double value)
 Sets the value of the option_header if the option type is a double_option type.
void set (int count)
 Sets the value of the option_header if the option type is an integer_option type or logical_option type.
void set_to_default ()
 Resets the option to its default value, leaving the stack intact.
char const * string () const
 Returns the string value of the option_header if the option type is string_option.
option_type type () const
 Returns the type of option_header.
double value () const
 Returns the value of the option_header if the option type is double_option.
 ~option_header ()
 C++ destructor, deleting an option_header.

Private Attributes

option_value def_value
 The value.
option_headernext_ptr
 pointer for linking option chain
const char * option_name
 The name.


Detailed Description

Records a value that denotes whether the option is on, off, or set to a given value.


Role: The class has a constructor that links an instance of it into a global chain that can then be inspected for reporting or changing the value. It maintains the default option value, as well as a stack of option values. Presently, the option chain is set up at initialization. New options can easily be added by making further static declarations of this class.


Constructor & Destructor Documentation

option_header::option_header ( char const *  name,
int  init 
)

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.



Role: Creates an option_header with the specified name and initial integer value and links it into the option list. For tidiness, we link options in alphabetic order.

Parameters:
name name.
init initial value.

option_header::option_header ( char const *  name,
double  init 
)

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.



Role: Creates an option_header with the specified name and initial double value and links it into the option list. For tidiness, we link options in alphabetic order.

Parameters:
name name.
init initial value.

option_header::option_header ( char const *  name,
char const *  init 
)

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.



Role: Creates an option_header with the specified name and initial string value and links it into the option list. For tidiness, we link options in alphabetic order.

Parameters:
name name.
init initial string.

option_header::~option_header (  ) 

C++ destructor, deleting an option_header.



Role: This destructor returns the option to free storage, cleans up stacked values, and removes the header from the list.


Member Function Documentation

int option_header::count (  )  const [inline]

Returns the value of the option_header if the option type is int_option or logical_option.

void option_header::display ( FILE *  fp  )  const [inline]

Prints the data contained in the option_header to the specified file.



Parameters:
fp file name.

logical option_header::is_default (  ) 

Checks the current value against the default value.



Role: Returns TRUE if they are same or FALSE otherwise.

char const* option_header::name (  )  const [inline]

Returns the name of the option_header.

option_header* option_header::next ( void   )  const [inline]

Returns the next option_header.

logical option_header::on (  )  const [inline]

Returns whether the option_header is on or off if the option type is logical_option.

void option_header::pop (  ) 

Pops the stack to the previous value.

void option_header::push ( char const *  newval  ) 

Pushes a new string value onto the value stack.



Parameters:
newval new value.

void option_header::push ( double  val  ) 

Pushes a new double value onto the value stack.



Parameters:
val double value.

void option_header::push ( int  val  ) 

Pushes a new integral value onto the value stack.



Parameters:
val integer value.

void option_header::reset (  ) 

Resets the option_header to the default value.

void option_header::set ( char const *  opt  ) 

Sets the value of the option_header if the type is string_option.



Parameters:
opt option name.

void option_header::set ( double  value  ) 

Sets the value of the option_header if the option type is a double_option type.



Parameters:
value double value.

void option_header::set ( int  count  ) 

Sets the value of the option_header if the option type is an integer_option type or logical_option type.



Parameters:
count count.

void option_header::set_to_default (  ) 

Resets the option to its default value, leaving the stack intact.

char const* option_header::string (  )  const [inline]

Returns the string value of the option_header if the option type is string_option.

option_type option_header::type (  )  const [inline]

Returns the type of option_header.



Role: The option types are logical_option, int_option, double_option, string_option, or unknown_option.

double option_header::value (  )  const [inline]

Returns the value of the option_header if the option type is double_option.


Member Data Documentation

option_value option_header::def_value [private]

The value.

pointer for linking option chain

const char* option_header::option_name [private]

The name.