casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
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::LatticePADisplayData< casacore::Float > 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 >

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

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

Private Attributes

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

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" casacore::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 casacore::Record "rec" is to be parsed */
if (dopt.readOptionRecord(min, error, rec, "minimum") && !error) {
cerr << "minimum found and changed, new value is " << min << endl;
}
casacore::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

casa::DisplayOptions::DisplayOptions ( )

Constructor.

virtual casa::DisplayOptions::~DisplayOptions ( )
inlinevirtual

Destructor.

Definition at line 124 of file DisplayOptions.h.

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

(Required) copy constructor.

Member Function Documentation

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

A utility to check if two types are compatible.

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

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

Return true or false indicating if the provided casacore::Record is equal to an "unset" Record.

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

(Required) copy assignment.

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

Find the field fieldname in casacore::Record rec, containing the requested type (casacore::Bool, casacore::String, casacore::Float, casacore::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 casacore::Float version will also read records containing Ints or Doubles, and cast their value to Float.

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

Find the field fieldname in casacore::Record rec, containing the requested type (casacore::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" casacore::Record, then unsetTarget is set true. If the field doesn't exist, or does not contain the requested type (casacore::String) or an "unset" casacore::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.

casacore::Record casa::DisplayOptions::unset ( ) const
inline

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

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

Definition at line 163 of file DisplayOptions.h.

References itsUnsetRecord.

Member Data Documentation

casacore::Record casa::DisplayOptions::itsUnsetRecord
private

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

Definition at line 186 of file DisplayOptions.h.

Referenced by unset().


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