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 Attributes | List of all members
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

Public Member Functions

 DParameterChoice (const casacore::String name, const casacore::String description, const casacore::String help, const casacore::Vector< casacore::String > &options, const casacore::String defaultvalue, const casacore::String value, const casacore::String context="", const casacore::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. More...
 
 DParameterChoice (const casacore::String name, const casacore::String description, const casacore::String help, const ColormapDefinition::colormapnamemap &options, const casacore::String defaultvalue, const casacore::String value, const casacore::String context="", const casacore::Bool editable=false)
 
 DParameterChoice (const DParameterChoice &other)
 (Required) copy constructor. More...
 
virtual ~DParameterChoice ()
 Destructor. More...
 
DParameterChoiceoperator= (const DParameterChoice &other)
 (Required) copy assignment. More...
 
virtual casacore::Bool fromRecord (const casacore::RecordInterface &record)
 Parse record, and update this parameter if a field exists whose name matches that of this parameter. More...
 
virtual void toRecord (casacore::RecordInterface &record, const casacore::Bool fullrecord=true, const casacore::Bool overwrite=false)
 Place a record describing this parameter in a sub-field of record with name matching that of this parameter. More...
 
casacore::Vector
< casacore::String
options () const
 Return the list of allowed options for this parameter. More...
 
casacore::String defaultValue ()
 Return the default for this parameter. More...
 
casacore::String value ()
 Return the current value of this parameter. More...
 
void setEditable (const casacore::Bool editable)
 Set or change if this parameter is editable (determines wether choice or userchoice is returned in the record. More...
 
void setOptions (const casacore::Vector< casacore::String > &options)
 Set or change the list of allowed options for this parameter. More...
 
void setDefaultValue (const casacore::String defaultvalue)
 Set or change the default value for this parameter. More...
 
void setValue (const casacore::String value)
 Set or change the current value. More...
 
const casacore::Stringoperator= (const casacore::String &value)
 Convenient syntax to set (only) the value. More...
 
casacore::Bool existsOption (const casacore::String value)
 Determine whether this value exists in the list of options. More...
 
- Public Member Functions inherited from casa::DisplayParameter
virtual ~DisplayParameter ()
 Destructor. More...
 
casacore::String name () const
 Return the name of this parameter. More...
 
casacore::String description () const
 Return the description of this parameter. More...
 
casacore::String help () const
 Return the help for this parameter. More...
 
casacore::String context () const
 Return the context of this parameter. More...
 
casacore::Bool allowUnset () const
 Return whether this parameter can be unset. More...
 
casacore::Bool editable () const
 Return whether this parameter is editable. More...
 
void setName (const casacore::String name)
 Set or change the name of this parameter to that specified. More...
 
void setDescription (const casacore::String description)
 Set or change the description of this parameter to what is specified. More...
 
void setHelp (const casacore::String help)
 Set or change the help for this parameter to what is specified. More...
 
void setContext (const casacore::String context)
 Set or change the context of this parameter to what is specified. More...
 
void setAllowUnset (const casacore::Bool allowunset)
 Set or change whether this parameter may be unset, according to the function argument value. More...
 
void setEditable (const casacore::Bool editable)
 Set or change whether this parameter is editable according to the function argument. More...
 

Protected Member Functions

 DParameterChoice ()
 (Required) default constructor. More...
 
- Protected Member Functions inherited from casa::DisplayParameter
 DisplayParameter (const casacore::String name, const casacore::String description, const casacore::String help, const casacore::String context="", const casacore::Bool allowunset=false, const casacore::Bool editable=true)
 Constructor taking the name of the parameter, a short description, some help text, and flags indicating whether the parameter can be unset and is editable. More...
 
 DisplayParameter (const DisplayParameter &other)
 Copy constructor using copy semantics. More...
 
 DisplayParameter ()
 Default constructor yielding a useless DisplayParameter. More...
 
DisplayParameteroperator= (const DisplayParameter &other)
 Copy assignment. More...
 
casacore::Record baseDescription ()
 Return a basic description of this parameter; used by virtual implementations of toRecord method to fill out a casacore::Record describing this DisplayParameter. More...
 
const DisplayOptionsdisplayOptions () const
 Return the DisplayOptions to use for parsing Records. More...
 

Private Attributes

casacore::Bool itsEditable
 
casacore::Vector
< casacore::String
itsOptions
 Store for the allowed options for this parameter. More...
 
casacore::String itsDefaultValue
 Store for the default of this parameter. More...
 
casacore::String itsValue
 Store for the value of this parameter. More...
 

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. casacore::Choice parameters simply have a vector of possible casacore::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:

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 casacore::String  name,
const casacore::String  description,
const casacore::String  help,
const casacore::Vector< casacore::String > &  options,
const casacore::String  defaultvalue,
const casacore::String  value,
const casacore::String  context = "",
const casacore::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 casacore::String  name,
const casacore::String  description,
const casacore::String  help,
const ColormapDefinition::colormapnamemap options,
const casacore::String  defaultvalue,
const casacore::String  value,
const casacore::String  context = "",
const casacore::Bool  editable = false 
)
casa::DParameterChoice::DParameterChoice ( const DParameterChoice other)

(Required) copy constructor.

virtual casa::DParameterChoice::~DParameterChoice ( )
virtual

Destructor.

casa::DParameterChoice::DParameterChoice ( )
protected

(Required) default constructor.

Member Function Documentation

casacore::String casa::DParameterChoice::defaultValue ( )
inline

Return the default for this parameter.

Definition at line 155 of file DParameterChoice.h.

References itsDefaultValue.

casacore::Bool casa::DParameterChoice::existsOption ( const casacore::String  value)

Determine whether this value exists in the list of options.

virtual casacore::Bool casa::DParameterChoice::fromRecord ( const casacore::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 casacore::String& casa::DParameterChoice::operator= ( const casacore::String value)
inline

Convenient syntax to set (only) the value.

Definition at line 186 of file DParameterChoice.h.

References itsValue, and value().

casacore::Vector<casacore::String> casa::DParameterChoice::options ( ) const
inline

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 casacore::String  defaultvalue)
inline

Set or change the default value for this parameter.

Definition at line 176 of file DParameterChoice.h.

References itsDefaultValue.

void casa::DParameterChoice::setEditable ( const casacore::Bool  editable)
inline

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

Definition at line 166 of file DParameterChoice.h.

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

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

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

Definition at line 171 of file DParameterChoice.h.

References itsOptions, and options().

Referenced by casa::DParameterMapKeyChoice::setOptions().

void casa::DParameterChoice::setValue ( const casacore::String  value)
inline

Set or change the current value.

Definition at line 181 of file DParameterChoice.h.

References itsValue, and value().

virtual void casa::DParameterChoice::toRecord ( casacore::RecordInterface record,
const casacore::Bool  fullrecord = true,
const casacore::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.

casacore::String casa::DParameterChoice::value ( void  )
inline

Member Data Documentation

casacore::String casa::DParameterChoice::itsDefaultValue
private

Store for the default of this parameter.

Definition at line 206 of file DParameterChoice.h.

Referenced by defaultValue(), and setDefaultValue().

casacore::Bool casa::DParameterChoice::itsEditable
private

Definition at line 201 of file DParameterChoice.h.

Referenced by setEditable().

casacore::Vector<casacore::String> casa::DParameterChoice::itsOptions
private

Store for the allowed options for this parameter.

Definition at line 203 of file DParameterChoice.h.

Referenced by options(), and setOptions().

casacore::String casa::DParameterChoice::itsValue
private

Store for the value of this parameter.

Definition at line 209 of file DParameterChoice.h.

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


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