DParameterSwitch.h

Go to the documentation of this file.
00001 //# DParameterSwitch.h: store and retrieve Boolean parameters (switches)
00002 //# Copyright (C) 2000,2001,2002
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_DPARAMETERSWITCH_H
00029 #define TRIALDISPLAY_DPARAMETERSWITCH_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 choice 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 // DParameterSwitch is an implementation of a DisplayParameter
00051 // providing a boolean (switch) parameter type.
00052 // </etymology>
00053 
00054 // <synopsis>
00055 
00056 // This class is derived from <linkto
00057 // class=DisplayParameter>DisplayParameter</linkto> and provides a
00058 // boolean switch parameter. Parameters can be True or False.
00059 // They cannot be unset.
00060 
00061 // </synopsis>
00062 
00063 // <example>
00064 // <srcblock>
00065 
00066 // DParameterSwitch pswitch("myswitch", "Axis labels",
00067 //                          "Do you want to draw axis labels?",
00068 //                          True,True);
00069 //
00070 // // ...
00071 //
00072 // // update the parameter from some Record
00073 // pswitch.fromRecord(rec);
00074 //
00075 // // examine the value of the parameter
00076 // if (pswitch.value()) {
00077 // // ...
00078 // }
00079 // </srcblock>
00080 // </example>
00081 
00082 // <motivation>
00083 // Switches are common.
00084 // </motivation>
00085 
00086 // <thrown>
00087 // <li> None.
00088 // </thrown>
00089 
00090 // <todo asof="2002/04/22">
00091 // <li> Nothing known.
00092 // </todo>
00093 
00094         class DParameterSwitch : public DisplayParameter {
00095 
00096         public:
00097 
00098                 // Constructor taking the name of the parameter, a short
00099                 // description, some help text, a default value, an initial value,
00100                 // the context of the parameter.
00101                 DParameterSwitch(const String name, const String description,
00102                                  const String help,
00103                                  const Bool defaultvalue, const Bool value,
00104                                  const String context="");
00105 
00106                 // (Required) copy constructor.
00107                 DParameterSwitch(const DParameterSwitch& other);
00108 
00109                 // Destructor.
00110                 virtual ~DParameterSwitch();
00111 
00112                 // (Required) copy assignment.
00113                 DParameterSwitch& operator=(const DParameterSwitch& other);
00114 
00115                 // Parse <src>record</src>, and update this parameter.  Return
00116                 // <src>True</src> if the parameter is changed, otherwise return
00117                 // <src>False</src>.
00118                 virtual Bool fromRecord(const RecordInterface& record);
00119 
00120                 // Place a record describing this parameter in a sub-field of
00121                 // <src>record</src> with name matching that of this parameter.  If
00122                 // <src>overwrite</src> is <src>True</src>, then any existing field
00123                 // with matching name will be overwritten.  If <src>fullrecord</src>
00124                 // is <src>True</src>, then a complete description of the parameter
00125                 // is given, otherwise just its current value is stored in
00126                 // <src>record</src>.  Presently <src>fullrecord</src> is ignored.
00127                 virtual void toRecord(RecordInterface& record, const Bool fullrecord = True,
00128                                       const Bool overwrite = False);
00129 
00130                 // Return the default for this parameter.
00131                 Bool defaultValue() const {
00132                         return itsDefaultValue;
00133                 }
00134 
00135                 // Return the current value of this parameter.
00136                 Bool value() const {
00137                         return itsValue;
00138                 }
00139 
00140                 // Set or change the default value for this parameter.
00141                 void setDefaultValue(const Bool defaultvalue) {
00142                         itsDefaultValue = defaultvalue;
00143                 }
00144 
00145                 // Set or change the current value.
00146                 void setValue(const Bool value) {
00147                         itsValue = value;
00148                 }
00149 
00150         protected:
00151 
00152                 // (Required) default constructor.
00153                 DParameterSwitch();
00154 
00155         private:
00156 
00157                 // Store for the default of this parameter.
00158                 Bool itsDefaultValue;
00159 
00160                 // Store for the value of this parameter.
00161                 Bool itsValue;
00162 
00163         };
00164 
00165 
00166 } //# NAMESPACE CASA - END
00167 
00168 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1