DParameterSwitch.h

Classes

DParameterSwitch -- Implementation of DisplayParameter to store choice parameters. (full description)

class DParameterSwitch : public DisplayParameter

Interface

Public Members
DParameterSwitch(const String name, const String description, const String help, const Bool defaultvalue, const Bool value, const String context="")
DParameterSwitch(const DParameterSwitch& other)
virtual ~DParameterSwitch()
DParameterSwitch& operator=(const DParameterSwitch& other)
virtual Bool fromRecord(const RecordInterface& record)
virtual void toRecord(RecordInterface& record, const Bool fullrecord = True, const Bool overwrite = False)
Bool defaultValue() const
Bool value() const
void setDefaultValue(const Bool defaultvalue)
void setValue(const Bool value)
Protected Members
DParameterSwitch()

Description

Prerequisite

Etymology

DParameterSwitch is an implementation of a DisplayParameter providing a boolean (switch) parameter type.

Synopsis

This class is derived from DisplayParameter and provides a boolean switch parameter. Parameters can be True or False. They cannot be unset.

Example

    
    DParameterSwitch pswitch("myswitch", "Axis labels", 
                             "Do you want to draw axis labels?",
                             True,True);
    
    // ...
    
    // update the parameter from some Record
    pswitch.fromRecord(rec);
    
    // examine the value of the parameter
    if (pswitch.value()) {
    // ...
    }
    

Motivation

Switches are common.

Thrown Exceptions

To Do

Member Description

DParameterSwitch(const String name, const String description, const String help, const Bool defaultvalue, const Bool value, const String context="")

Constructor taking the name of the parameter, a short description, some help text, a default value, an initial value, the context of the parameter.

DParameterSwitch(const DParameterSwitch& other)

(Required) copy constructor.

virtual ~DParameterSwitch()

Destructor.

DParameterSwitch& operator=(const DParameterSwitch& other)

(Required) copy assignment.

virtual Bool fromRecord(const RecordInterface& record)

Parse record, and update this parameter. Return True if the parameter is changed, otherwise return False.

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. 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.

Bool defaultValue() const

Return the default for this parameter.

Bool value() const

Return the current value of this parameter.

void setDefaultValue(const Bool defaultvalue)

Set or change the default value for this parameter.

void setValue(const Bool value)

Set or change the current value.

DParameterSwitch()

(Required) default constructor.