DParameterString.h

Classes

DParameterString -- Implementation of DisplayParameter to store String parameters. (full description)

class DParameterString : public DisplayParameter

Interface

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

Description

Prerequisite

Etymology

DParameterString is an implementation of a DisplayParameter providing a String parameter type.

Synopsis

This class is derived from DisplayParameter and provides a String-type parameter. String parameters simply have a String value, and a default String value. They cannot be unset.

Example

A DParameterString can easily be used to store and update any parameter which can be expressed as a String. In the following example, a DParameterString is constructed to store some text to be used for axis labelling:

    DParameterString pstring("xaxislabel", "X Axis Label", 
                             "Enter the text to appear alongside the X Axis");
    
    // ...
    
    // update the parameter from some Record
    pstring.fromRecord(rec);
    
    // examine the value of the parameter
    if (pstring.value() == "Four frogs found fabulous frocks") {
    // ...
    }
    

Motivation

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

Thrown Exceptions

To Do

Member Description

DParameterString(const String name, const String description, const String help, const String defaultvalue, const String value, const String context = "", const Bool editable = True)

Constructor taking the name of the parameter, a short description, some help text, a default value, an initial value, and flags indicating whether the parameter can be unset and is editable.

DParameterString(const DParameterString &other)

(Required) copy constructor.

virtual ~DParameterString()

Destructor.

DParameterString &operator=(const DParameterString &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. 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.

String defaultValue()

Return the default for this parameter.

String value()

Return the current value of this parameter.

DParameterString()

(Required) default constructor.