casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DParameterString.h
Go to the documentation of this file.
1 //# DParameterString.h: class to store and retrieve casacore::String parameters
2 //# Copyright (C) 2000
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TRIALDISPLAY_DPARAMETERSTRING_H
29 #define TRIALDISPLAY_DPARAMETERSTRING_H
30 
31 #include <casa/aips.h>
33 
34 namespace casa { //# NAMESPACE CASA - BEGIN
35 
36 // <summary>
37 // Implementation of DisplayParameter to store casacore::String parameters.
38 // </summary>
39 
40 // <use visibility=export>
41 
42 // <reviewed reviewer="" date="" test="" demos="">
43 // </reviewed>
44 
45 // <prerequisite>
46 // <li> <linkto class=DisplayParameter>DisplayParameter</linkto>
47 // </prerequisite>
48 
49 // <etymology>
50 // DParameterString is an implementation of a DisplayParameter
51 // providing a casacore::String parameter type.
52 // </etymology>
53 
54 // <synopsis>
55 // This class is derived from <linkto
56 // class=DisplayParameter>DisplayParameter</linkto> and provides a
57 // casacore::String-type parameter. casacore::String parameters simply have a String
58 // value, and a default casacore::String value. They cannot be unset.
59 // </synopsis>
60 
61 // <example>
62 
63 // A DParameterString can easily be used to store and update any
64 // parameter which can be expressed as a String. In the following
65 // example, a DParameterString is constructed to store some text to be
66 // used for axis labelling:
67 // <srcblock>
68 // DParameterString pstring("xaxislabel", "X Axis Label",
69 // "Enter the text to appear alongside the X Axis");
70 //
71 // // ...
72 //
73 // // update the parameter from some Record
74 // pstring.fromRecord(rec);
75 //
76 // // examine the value of the parameter
77 // if (pstring.value() == "Four frogs found fabulous frocks") {
78 // // ...
79 // }
80 // </srcblock>
81 // </example>
82 
83 // <motivation>
84 // Many parameters are naturally Strings, or can be expressed as
85 // Strings, hence this class.
86 // </motivation>
87 
88 // <thrown>
89 // <li> None.
90 // </thrown>
91 
92 // <todo asof="2000/01/28">
93 // <li> Nothing known.
94 // </todo>
95 
97 
98  public:
99 
100  // Constructor taking the name of the parameter, a short
101  // description, some help text, a default value, an initial value,
102  // and flags indicating whether the parameter can be unset and is
103  // editable.
105  const casacore::String help, const casacore::String defaultvalue,
107  const casacore::Bool editable = true);
108 
109  // (Required) copy constructor.
110  DParameterString(const DParameterString &other);
111 
112  // Destructor.
113  virtual ~DParameterString();
114 
115  // (Required) copy assignment.
117 
118  // Parse <src>record</src>, and update this parameter if a field
119  // exists whose name matches that of this parameter. Return
120  // <src>true</src> if the parameter is changed, otherwise return
121  // <src>false</src>.
122  virtual casacore::Bool fromRecord(const casacore::RecordInterface &record);
123 
124  // Place a record describing this parameter in a sub-field of
125  // <src>record</src> with name matching that of this parameter. If
126  // <src>overwrite</src> is <src>true</src>, then any existing field
127  // with matching name will be overwritten. If <src>fullrecord</src>
128  // is <src>true</src>, then a complete description of the parameter
129  // is given, otherwise just its current value is stored in
130  // <src>record</src>. Presently <src>fullrecord</src> is ignored.
131  virtual void toRecord(casacore::RecordInterface &record, const casacore::Bool fullrecord = true,
132  const casacore::Bool overwrite = false);
133 
134  // Return the default for this parameter.
136  return itsDefault;
137  }
138 
139  // Return the current value of this parameter.
141  return itsValue;
142  }
143 
144  protected:
145 
146  // (Required) default constructor.
148 
149  private:
150 
151  // Store for the default of this parameter.
153 
154  // Store for the value of this parameter.
156 
157  };
158 
159 
160 } //# NAMESPACE CASA - END
161 
162 #endif
casacore::String itsValue
Store for the value of this parameter.
casacore::String name() const
Return the name of this parameter.
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...
casacore::String value()
Return the current value of this parameter.
casacore::String help() const
Return the help for this parameter.
virtual ~DParameterString()
Destructor.
casacore::String description() const
Return the description of this parameter.
DParameterString & operator=(const DParameterString &other)
(Required) copy assignment.
casacore::Bool editable() const
Return whether this parameter is editable.
casacore::String defaultValue()
Return the default for this parameter.
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 par...
casacore::String context() const
Return the context of this parameter.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Implementation of DisplayParameter to store casacore::String parameters.
casacore::String itsDefault
Store for the default of this parameter.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Abstract base class for Record classes.
DParameterString()
(Required) default constructor.
Base class for storing and parsing of parameters for display classes.