AttValTol.h

Go to the documentation of this file.
00001 //# AttValTol.h: templated class for tolerant AttributeValues
00002 //# Copyright (C) 1996,1997,1999,2000,2001
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_ATTVALTOL_H
00029 #define TRIALDISPLAY_ATTVALTOL_H
00030 
00031 #include <casa/aips.h>
00032 #include <display/Display/AttVal.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036         class AttValBase;
00037 
00038 // <summary>
00039 // Templated class for storing Attributes which have a tolerance.
00040 // </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tAttribute" demos="">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 // <li> <linkto class="AttributeValue">AttributeValue</linkto>
00049 // </prerequisite>
00050 
00051 // <etymology>
00052 // "AttributeValueTol" is a contraction of "Attribute Value" and
00053 // "Tolerance", and stores an Attribute which has associated with
00054 // it some tolerance to be observed in matching with other
00055 // Attributes.
00056 // </etymology>
00057 
00058 // <synopsis>
00059 // An AttributeValueTol differs from a <linkto class="AttributeValue">
00060 // AttributeValue</linkto> in that it has associated with it a certain
00061 // tolerance, which will be observed when matching the value with
00062 // other AttributeValues.  This means that values do not have to match
00063 // exactly in order for the AttributeValueTols to match.  Tolerant
00064 // matching is defined as <src>abs(val1-val2) <= tolerance1</src>.
00065 // Remember though that in general both Attributes must independently
00066 // match each other for a match to exist, and so it is normally also a
00067 // requirement that <src>abs(val1 - val2) <= tolerance2</src> when the
00068 // second Attribute also has tolerance specified.
00069 // </synopsis>
00070 
00071 // <example>
00072 // If we have
00073 //
00074 // <srcBlock>
00075 // AttributeValueTol<Float> Att1(3.0, 1.2, False);
00076 // AttributeValueTol<Float> Att2(2.0, 1.1, False);
00077 // AttributeValueTol<Float> Att3(2.1, 0.5, False);
00078 // </srcBlock>
00079 //
00080 // then:
00081 // <li> <src>Att1==Att2</src> returns <src>True</src>,
00082 // <li> <src>Att2==Att3</src> returns <src>True</src>,
00083 // <li> but <src>Att3==Att1</src> returns <src>False</src>.
00084 // </example>
00085 //
00086 // <motivation>
00087 // The motivation for this class is to be able to provide some
00088 // in-built tolerance ("fuzziness") to AttributeValues.  For example,
00089 // this approach might be used in selecting channel maps to display
00090 // when matching on radial velocity.
00091 // </motivation>
00092 // <todo asof="2000/01/17">
00093 // </todo>
00094 
00095 
00096         template <class T> class AttributeValueTol : public AttributeValue<T> {
00097 
00098         public:
00099                 // Constructor for a scalar, with specified scalar tolerance and
00100                 // strictness.
00101                 AttributeValueTol(const T &value, const T &tolerance, const Bool strict);
00102 
00103                 // Constructor for a <src>Vector</src> value, with specified scalar
00104                 // tolerance and strictness.
00105                 AttributeValueTol(const Vector<T> &value, const T &tolerance, const Bool strict);
00106 
00107                 // Copy contructor.
00108                 AttributeValueTol(const AttributeValueTol<T> &other);
00109 
00110                 // Destructor.
00111                 virtual ~AttributeValueTol();
00112 
00113                 // Assignment operator.
00114                 const AttributeValueTol<T> &operator=(const AttributeValueTol<T>& other);
00115 
00116                 // Return a new copy of the AttributeValueTol (virtual constructor).
00117                 virtual AttributeValueBase *clone() const;
00118 
00119                 // Change or retrieve the scalar tolerance.
00120                 // <group>
00121                 virtual void setTolerance(T value) {
00122                         itsValueTolerance = value;
00123                 };
00124                 virtual T getTolerance() const {
00125                         return itsValueTolerance;
00126                 };
00127                 // </group>
00128 
00129                 // Return class name
00130                 virtual String className() const {
00131                         return String("AttributeValueTol");
00132                 };
00133 
00134         protected:
00135 
00136                 // Implements when the values of two Attributes match, taking note
00137                 // of tolerance in this particular implementation.
00138                 virtual Bool matches(const AttributeValueBase& other) const;
00139 
00140         private:
00141 
00142                 // The value of the tolerance
00143                 T itsValueTolerance;
00144 
00145                 // Does the actual matching
00146                 Bool myMatch(const AttributeValue<T>& other) const;
00147 
00148                 // Default constructor
00149                 AttributeValueTol();
00150 
00151                 //# Make parent members known.
00152         public:
00153                 using AttributeValue<T>::getType;
00154                 using AttributeValue<T>::getValue;
00155                 using AttributeValue<T>::getStrictness;
00156         };
00157 
00158 } //# NAMESPACE CASA - END
00159 
00160 #ifndef AIPS_NO_TEMPLATE_SRC
00161 #include <display/Display/AttValTol.tcc>
00162 #endif //# AIPS_NO_TEMPLATE_SRC
00163 
00164 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1