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

Implementation of DisplayParameter to store choice parameters. More...

#include <DParameterChoice.h>

Inheritance diagram for casa::DParameterChoice:
casa::DisplayParameter casa::DParameterColorChoice casa::DParameterFontChoice casa::DParameterMapKeyChoice

List of all members.

Public Member Functions

 DParameterChoice (const String name, const String description, const String help, const Vector< String > &options, const String defaultvalue, const String value, const String context="", const Bool editable=False)
 Constructor taking the name of the parameter, a short description, some help text, a list of allowed options, a default value, an initial value, the context of the parameter, and a flag indicating whether the parameter is editable.
 DParameterChoice (const String name, const String description, const String help, const ColormapDefinition::colormapnamemap &options, const String defaultvalue, const String value, const String context="", const Bool editable=False)
 DParameterChoice (const DParameterChoice &other)
 (Required) copy constructor.
virtual ~DParameterChoice ()
 Destructor.
DParameterChoiceoperator= (const DParameterChoice &other)
 (Required) copy assignment.
virtual Bool fromRecord (const RecordInterface &record)
 Parse record, and update this parameter if a field exists whose name matches that of this parameter.
virtual void toRecord (RecordInterface &record, const Bool fullrecord=True, const Bool overwrite=False)
 Place a record describing this parameter in a sub-field of record with name matching that of this parameter.
Vector< Stringoptions () const
 Return the list of allowed options for this parameter.
String defaultValue ()
 Return the default for this parameter.
String value ()
 Return the current value of this parameter.
void setEditable (const Bool editable)
 Set or change if this parameter is editable (determines wether choice or userchoice is returned in the record.
void setOptions (const Vector< String > &options)
 Set or change the list of allowed options for this parameter.
void setDefaultValue (const String defaultvalue)
 Set or change the default value for this parameter.
void setValue (const String value)
 Set or change the current value.
const Stringoperator= (const String &value)
 Convenient syntax to set (only) the value.
Bool existsOption (const String value)
 Determine whether this value exists in the list of options.

Protected Member Functions

 DParameterChoice ()
 (Required) default constructor.

Private Attributes

Bool itsEditable
 Store for whether this parameter is editable.
Vector< StringitsOptions
 Store for the allowed options for this parameter.
String itsDefaultValue
 Store for the default of this parameter.
String itsValue
 Store for the value of this parameter.

Detailed Description

Implementation of DisplayParameter to store choice parameters.

Intended use:

Public interface

Prerequisite

Etymology

DParameterChoice is an implementation of a DisplayParameter providing a choice parameter type.

Synopsis

This class is derived from DisplayParameter and provides a choice-type parameter. Choice parameters simply have a vector of possible String selections, and a default selection. They cannot be unset.

Example

A DParameterChoice can easily be used to store and update any parameter which can be expressed as a selection from two or more options. In the following example, a DParameterChoice is constructed to provide the name of the font to use in axis labelling:

    Vector<String> fonts(4);
    fonts(0) = "roman";
    // ..\.
    DParameterChoice pchoice("font", "Label font", 
                             "Select the font to use for axis labelling",
                             fonts, fonts(0), fonts(0));
   
    // ..\.
    
    // update the parameter from some Record
    pchoice.fromRecord(rec);
   
    // examine the value of the parameter
    if (pchoice.value() == "italic") {
    // ..\.
    }

Motivation

Many parameters are naturally choices, or can be expressed as choices, hence this class.

Thrown Exceptions

To Do

Definition at line 104 of file DParameterChoice.h.


Constructor & Destructor Documentation

casa::DParameterChoice::DParameterChoice ( const String  name,
const String  description,
const String  help,
const Vector< String > &  options,
const String  defaultvalue,
const String  value,
const String  context = "",
const Bool  editable = False 
)

Constructor taking the name of the parameter, a short description, some help text, a list of allowed options, a default value, an initial value, the context of the parameter, and a flag indicating whether the parameter is editable.

Obviously the defaultvalue and value parameters must exist in the list of allowed options, otherwise an exception is thrown.

casa::DParameterChoice::DParameterChoice ( const String  name,
const String  description,
const String  help,
const ColormapDefinition::colormapnamemap options,
const String  defaultvalue,
const String  value,
const String  context = "",
const Bool  editable = False 
)

(Required) copy constructor.

Destructor.

(Required) default constructor.


Member Function Documentation

Return the default for this parameter.

Definition at line 154 of file DParameterChoice.h.

References itsDefaultValue.

Determine whether this value exists in the list of options.

virtual Bool casa::DParameterChoice::fromRecord ( const RecordInterface record) [virtual]

Parse record, and update this parameter if a field exists whose name matches that of this parameter.

Return True if the parameter is changed, otherwise return False.

Implements casa::DisplayParameter.

DParameterChoice& casa::DParameterChoice::operator= ( const DParameterChoice other)

(Required) copy assignment.

const String& casa::DParameterChoice::operator= ( const String value) [inline]

Convenient syntax to set (only) the value.

Definition at line 179 of file DParameterChoice.h.

References itsValue, and value().

Return the list of allowed options for this parameter.

Definition at line 150 of file DParameterChoice.h.

References itsOptions.

Referenced by setOptions().

void casa::DParameterChoice::setDefaultValue ( const String  defaultvalue) [inline]

Set or change the default value for this parameter.

Definition at line 171 of file DParameterChoice.h.

References itsDefaultValue.

void casa::DParameterChoice::setEditable ( const Bool  editable) [inline]

Set or change if this parameter is editable (determines wether choice or userchoice is returned in the record.

Reimplemented from casa::DisplayParameter.

Definition at line 163 of file DParameterChoice.h.

References casa::DisplayParameter::editable(), and itsEditable.

void casa::DParameterChoice::setOptions ( const Vector< String > &  options) [inline]

Set or change the list of allowed options for this parameter.

Reimplemented in casa::DParameterMapKeyChoice.

Definition at line 167 of file DParameterChoice.h.

References itsOptions, and options().

void casa::DParameterChoice::setValue ( const String  value) [inline]

Set or change the current value.

Definition at line 175 of file DParameterChoice.h.

References itsValue, and value().

virtual void casa::DParameterChoice::toRecord ( RecordInterface record,
const Bool  fullrecord = True,
const Bool  overwrite = False 
) [virtual]

Place a record describing this parameter in a sub-field of record with name matching that of this parameter.

If overwrite is True, then any existing field with matching name will be overwritten. If fullrecord is True, then a complete description of the parameter is given, otherwise just its current value is stored in record. Presently fullrecord is ignored.

Implements casa::DisplayParameter.


Member Data Documentation

Store for the default of this parameter.

Definition at line 197 of file DParameterChoice.h.

Referenced by defaultValue(), and setDefaultValue().

Store for whether this parameter is editable.

Reimplemented from casa::DisplayParameter.

Definition at line 192 of file DParameterChoice.h.

Referenced by setEditable().

Store for the allowed options for this parameter.

Definition at line 194 of file DParameterChoice.h.

Referenced by options(), and setOptions().

Store for the value of this parameter.

Definition at line 200 of file DParameterChoice.h.

Referenced by operator=(), setValue(), and value().


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