casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DParameterSwitch.h
Go to the documentation of this file.
1 //# DParameterSwitch.h: store and retrieve Boolean parameters (switches)
2 //# Copyright (C) 2000,2001,2002
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_DPARAMETERSWITCH_H
29 #define TRIALDISPLAY_DPARAMETERSWITCH_H
30 
31 //#include <casa/aips.h>
33 
34 namespace casa { //# NAMESPACE CASA - BEGIN
35 
36 // <summary>
37 // Implementation of DisplayParameter to store choice 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 // DParameterSwitch is an implementation of a DisplayParameter
51 // providing a boolean (switch) parameter type.
52 // </etymology>
53 
54 // <synopsis>
55 
56 // This class is derived from <linkto
57 // class=DisplayParameter>DisplayParameter</linkto> and provides a
58 // boolean switch parameter. Parameters can be true or false.
59 // They cannot be unset.
60 
61 // </synopsis>
62 
63 // <example>
64 // <srcblock>
65 
66 // DParameterSwitch pswitch("myswitch", "Axis labels",
67 // "Do you want to draw axis labels?",
68 // true,true);
69 //
70 // // ...
71 //
72 // // update the parameter from some Record
73 // pswitch.fromRecord(rec);
74 //
75 // // examine the value of the parameter
76 // if (pswitch.value()) {
77 // // ...
78 // }
79 // </srcblock>
80 // </example>
81 
82 // <motivation>
83 // Switches are common.
84 // </motivation>
85 
86 // <thrown>
87 // <li> None.
88 // </thrown>
89 
90 // <todo asof="2002/04/22">
91 // <li> Nothing known.
92 // </todo>
93 
95 
96  public:
97 
98  // Constructor taking the name of the parameter, a short
99  // description, some help text, a default value, an initial value,
100  // the context of the parameter.
102  const casacore::String help,
103  const casacore::Bool defaultvalue, const casacore::Bool value,
104  const casacore::String context="");
105 
106  // (Required) copy constructor.
107  DParameterSwitch(const DParameterSwitch& other);
108 
109  // Destructor.
110  virtual ~DParameterSwitch();
111 
112  // (Required) copy assignment.
114 
115  // Parse <src>record</src>, and update this parameter. Return
116  // <src>true</src> if the parameter is changed, otherwise return
117  // <src>false</src>.
118  virtual casacore::Bool fromRecord(const casacore::RecordInterface& record);
119 
120  // Place a record describing this parameter in a sub-field of
121  // <src>record</src> with name matching that of this parameter. If
122  // <src>overwrite</src> is <src>true</src>, then any existing field
123  // with matching name will be overwritten. If <src>fullrecord</src>
124  // is <src>true</src>, then a complete description of the parameter
125  // is given, otherwise just its current value is stored in
126  // <src>record</src>. Presently <src>fullrecord</src> is ignored.
127  virtual void toRecord(casacore::RecordInterface& record, const casacore::Bool fullrecord = true,
128  const casacore::Bool overwrite = false);
129 
130  // Return the default for this parameter.
132  return itsDefaultValue;
133  }
134 
135  // Return the current value of this parameter.
137  return itsValue;
138  }
139 
140  // Set or change the default value for this parameter.
141  void setDefaultValue(const casacore::Bool defaultvalue) {
142  itsDefaultValue = defaultvalue;
143  }
144 
145  // Set or change the current value.
146  void setValue(const casacore::Bool value) {
147  itsValue = value;
148  }
149 
150  protected:
151 
152  // (Required) default constructor.
154 
155  private:
156 
157  // Store for the default of this parameter.
159 
160  // Store for the value of this parameter.
162 
163  };
164 
165 
166 } //# NAMESPACE CASA - END
167 
168 #endif
casacore::String name() const
Return the name of this parameter.
DParameterSwitch & operator=(const DParameterSwitch &other)
(Required) copy assignment.
void setValue(const casacore::Bool value)
Set or change the current value.
casacore::String help() const
Return the help for this parameter.
casacore::String description() const
Return the description of this parameter.
casacore::Bool value() const
Return the current value of this parameter.
casacore::Bool itsValue
Store for the value of this parameter.
void setDefaultValue(const casacore::Bool defaultvalue)
Set or change the default value for this parameter.
casacore::String context() const
Return the context of 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...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool defaultValue() const
Return the default for this parameter.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Bool itsDefaultValue
Store for the default of this parameter.
DParameterSwitch()
(Required) default constructor.
Abstract base class for Record classes.
virtual ~DParameterSwitch()
Destructor.
virtual casacore::Bool fromRecord(const casacore::RecordInterface &record)
Parse record, and update this parameter.
Implementation of DisplayParameter to store choice parameters.
Base class for storing and parsing of parameters for display classes.