casa
$Rev:20696$
|
00001 //# DParameterString.h: class to store and retrieve String parameters 00002 //# Copyright (C) 2000 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef TRIALDISPLAY_DPARAMETERSTRING_H 00029 #define TRIALDISPLAY_DPARAMETERSTRING_H 00030 00031 #include <casa/aips.h> 00032 #include <display/Display/DisplayParameter.h> 00033 00034 namespace casa { //# NAMESPACE CASA - BEGIN 00035 00036 // <summary> 00037 // Implementation of DisplayParameter to store String parameters. 00038 // </summary> 00039 00040 // <use visibility=export> 00041 00042 // <reviewed reviewer="" date="" test="" demos=""> 00043 // </reviewed> 00044 00045 // <prerequisite> 00046 // <li> <linkto class=DisplayParameter>DisplayParameter</linkto> 00047 // </prerequisite> 00048 00049 // <etymology> 00050 // DParameterString is an implementation of a DisplayParameter 00051 // providing a String parameter type. 00052 // </etymology> 00053 00054 // <synopsis> 00055 // This class is derived from <linkto 00056 // class=DisplayParameter>DisplayParameter</linkto> and provides a 00057 // String-type parameter. String parameters simply have a String 00058 // value, and a default String value. They cannot be unset. 00059 // </synopsis> 00060 00061 // <example> 00062 00063 // A DParameterString can easily be used to store and update any 00064 // parameter which can be expressed as a String. In the following 00065 // example, a DParameterString is constructed to store some text to be 00066 // used for axis labelling: 00067 // <srcblock> 00068 // DParameterString pstring("xaxislabel", "X Axis Label", 00069 // "Enter the text to appear alongside the X Axis"); 00070 // 00071 // // ... 00072 // 00073 // // update the parameter from some Record 00074 // pstring.fromRecord(rec); 00075 // 00076 // // examine the value of the parameter 00077 // if (pstring.value() == "Four frogs found fabulous frocks") { 00078 // // ... 00079 // } 00080 // </srcblock> 00081 // </example> 00082 00083 // <motivation> 00084 // Many parameters are naturally Strings, or can be expressed as 00085 // Strings, hence this class. 00086 // </motivation> 00087 00088 // <thrown> 00089 // <li> None. 00090 // </thrown> 00091 00092 // <todo asof="2000/01/28"> 00093 // <li> Nothing known. 00094 // </todo> 00095 00096 class DParameterString : public DisplayParameter { 00097 00098 public: 00099 00100 // Constructor taking the name of the parameter, a short 00101 // description, some help text, a default value, an initial value, 00102 // and flags indicating whether the parameter can be unset and is 00103 // editable. 00104 DParameterString(const String name, const String description, 00105 const String help, const String defaultvalue, 00106 const String value, const String context = "", 00107 const Bool editable = True); 00108 00109 // (Required) copy constructor. 00110 DParameterString(const DParameterString &other); 00111 00112 // Destructor. 00113 virtual ~DParameterString(); 00114 00115 // (Required) copy assignment. 00116 DParameterString &operator=(const DParameterString &other); 00117 00118 // Parse <src>record</src>, and update this parameter if a field 00119 // exists whose name matches that of this parameter. Return 00120 // <src>True</src> if the parameter is changed, otherwise return 00121 // <src>False</src>. 00122 virtual Bool fromRecord(const RecordInterface &record); 00123 00124 // Place a record describing this parameter in a sub-field of 00125 // <src>record</src> with name matching that of this parameter. If 00126 // <src>overwrite</src> is <src>True</src>, then any existing field 00127 // with matching name will be overwritten. If <src>fullrecord</src> 00128 // is <src>True</src>, then a complete description of the parameter 00129 // is given, otherwise just its current value is stored in 00130 // <src>record</src>. Presently <src>fullrecord</src> is ignored. 00131 virtual void toRecord(RecordInterface &record, const Bool fullrecord = True, 00132 const Bool overwrite = False); 00133 00134 // Return the default for this parameter. 00135 String defaultValue() 00136 { return itsDefault; } 00137 00138 // Return the current value of this parameter. 00139 String value() 00140 { return itsValue; } 00141 00142 protected: 00143 00144 // (Required) default constructor. 00145 DParameterString(); 00146 00147 private: 00148 00149 // Store for the default of this parameter. 00150 String itsDefault; 00151 00152 // Store for the value of this parameter. 00153 String itsValue; 00154 00155 }; 00156 00157 00158 } //# NAMESPACE CASA - END 00159 00160 #endif