casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
casa::DisplayOptions Class Reference

Class to provide option parsing routines for display classes. More...

#include <DisplayOptions.h>

Inheritance diagram for casa::DisplayOptions:
casa::DisplayData casa::PanelDisplay casa::WCAxisLabeller casa::WCDataScaleHandler casa::WorldCanvas casa::CachingDisplayData casa::NBody casa::PrincipalAxesDD casa::WCCSAxisLabeller casa::WCLinearScaleHandler casa::WCPowerScaleHandler casa::ActiveCaching2dDD casa::PassiveCachingDD casa::LatticePADisplayData< T > casa::ScrollingRasterDD casa::WCCSNLAxisLabeller casa::Histogram2dDD casa::MSAsRaster casa::Profile2dDD casa::TblAsContourDD casa::TblAsRasterDD casa::TblAsXYDD casa::WedgeDD casa::AxesDisplayData casa::DrawingDisplayData casa::PassiveTableDD casa::RegionShape casa::LatticeAsContour< T > casa::LatticeAsMarker< T > casa::LatticeAsRaster< T > casa::LatticeAsVector< T >

List of all members.

Public Member Functions

 DisplayOptions ()
 Constructor.
virtual ~DisplayOptions ()
 Destructor.
template<class T >
Bool readOptionRecord (Vector< T > &target, Bool &error, const Record &rec, const String &fieldname) const
 Find the field fieldname in Record rec, containing the requested type (Bool, String, Float, Int) in itself or its "value" sub-field, and return the value in target.
template<class T >
Bool readOptionRecord (T &target, Bool &error, const Record &rec, const String &fieldname) const
virtual Bool readOptionRecord (String &target, Bool &unsetTarget, Bool &error, const Record &rec, const String &fieldname) const
 Find the field fieldname in Record rec, containing the requested type (String) in itself or its "value" sub-field, and return the value in target.
Record unset () const
 Return a Record which is an "unset" Record, ie.
Bool isUnset (const Record &rec) const
 Return True or False indicating if the provided Record is equal to an "unset" Record.

Protected Member Functions

 DisplayOptions (const DisplayOptions &other)
 (Required) copy constructor.
void operator= (const DisplayOptions &other)
 (Required) copy assignment.

Private Member Functions

Bool compatible (const DataType &compareme, const DataType &tome) const
 A utility to check if two types are compatible.

Private Attributes

Record itsUnsetRecord
 An unset record to return with protected unset() function.

Detailed Description

Class to provide option parsing routines for display classes.

Intended use:

Internal

Review Status

Reviewed By:
Peter Barnes
Date Reviewed:
1999/10/27
Test programs:
tDisplayOptions

Prerequisite

Etymology

DisplayOptions contains methods for parsing "Options" for various "Display" classes.

Synopsis

DisplayOptions is a simple class which provides methods for parsing Records containing fields which conform to "options" as used in the Display Library classes. Consider a record having the following structure:

    rec.minimum.value = 4.0
    rec.minimum.otherfield = "some text"
    rec.maximum = 8.0

The DisplayOptions methods can be used to extract the values of the minimum and maximum fields of the Record rec, regardless of whether the value itself is stored in a value sub-field, or at the next higher level. The DisplayOptions methods also offer the capability to detect "unset" Record values.

This class can be used as-is, or inherited from by higher-level classes.

Example

The following example shows the use of DisplayOptions as a stand-alone class.

    /* assume some Record "rec" is to be parsed */
    DisplayOptions dopt;
    Bool error;
   
    Float min = 0.0;
    if (dopt.readOptionRecord(min, error, rec, "minimum") && !error) {
      cerr << "minimum found and changed, new value is " << min << endl;
    }
    
    String color;
    Bool colorIsUnset = False;
    if (dopt.readOptionRecord(color, colorIsUnset, error,
                              rec, "color") && !error) {
      if (colorIsUnset) {
        cerr << "color found and unset" << endl;
      } else {
        cerr << "color found and changed, new value is " << color << endl;
      }
    }

Motivation

Options are used prolifically throughout the display classes, so some unified processing of options is desirable.

Thrown Exceptions

.

To Do

Definition at line 116 of file DisplayOptions.h.


Constructor & Destructor Documentation

Constructor.

virtual casa::DisplayOptions::~DisplayOptions ( ) [inline, virtual]

Destructor.

Definition at line 124 of file DisplayOptions.h.

casa::DisplayOptions::DisplayOptions ( const DisplayOptions other) [protected]

(Required) copy constructor.


Member Function Documentation

Bool casa::DisplayOptions::compatible ( const DataType &  compareme,
const DataType &  tome 
) const [private]

A utility to check if two types are compatible.

(I.e. double is "compatible" with int. Used by readOptionRecord.

Bool casa::DisplayOptions::isUnset ( const Record rec) const

Return True or False indicating if the provided Record is equal to an "unset" Record.

void casa::DisplayOptions::operator= ( const DisplayOptions other) [protected]

(Required) copy assignment.

template<class T >
Bool casa::DisplayOptions::readOptionRecord ( Vector< T > &  target,
Bool error,
const Record rec,
const String fieldname 
) const

Find the field fieldname in Record rec, containing the requested type (Bool, String, Float, Int) in itself or its "value" sub-field, and return the value in target.

If the field doesn't exist, or does not contain the requested type, or a "value" sub-field containing the requested type, then error is set True. When error is False, the return value indicates whether target was modified. The Float version will also read records containing Ints or Doubles, and cast their value to Float.

template<class T >
Bool casa::DisplayOptions::readOptionRecord ( T &  target,
Bool error,
const Record rec,
const String fieldname 
) const
virtual Bool casa::DisplayOptions::readOptionRecord ( String target,
Bool unsetTarget,
Bool error,
const Record rec,
const String fieldname 
) const [virtual]

Find the field fieldname in Record rec, containing the requested type (String) in itself or its "value" sub-field, and return the value in target.

If the field (or "value" sub-field) instead contains an "unset" Record, then unsetTarget is set True. If the field doesn't exist, or does not contain the requested type (String) or an "unset" Record, or a "value" sub-field containing either of these, then error is set True. When error is False, the return value indicates whether target (or unsetTarget) was modified.

Record casa::DisplayOptions::unset ( ) const [inline]

Return a Record which is an "unset" Record, ie.

has a field with name String("i_am_unset") whose value is String("i_am_unset").

Definition at line 163 of file DisplayOptions.h.

References itsUnsetRecord.


Member Data Documentation

An unset record to return with protected unset() function.

Definition at line 185 of file DisplayOptions.h.

Referenced by unset().


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