casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
AttValPoiTol.h
Go to the documentation of this file.
00001 //# AttValPoiTol.h: template for tolerant and aliased 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_ATTVALPOITOL_H
00029 #define TRIALDISPLAY_ATTVALPOITOL_H
00030 
00031 #include <casa/aips.h>
00032 #include <display/Display/AttValTol.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 // <summary> 
00037 // Templated class for aliased, tolerant AttributeValues.
00038 // </summary>
00039 
00040 // <use visibility=local>
00041  
00042 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tAttribute" demos="">
00043 // </reviewed>
00044 
00045 // <prerequisite>
00046 // <li> <linkto class="AttributeValue">AttributeValue</linkto>
00047 // <li> <linkto class="AttributeValuePoi">AttributeValuePoi</linkto>
00048 // <li> <linkto class="AttributeValueTol">AttributeValueTol</linkto>
00049 // </prerequisite>
00050 
00051 // <etymology> 
00052 // "AttributeValuePoiTol" is a contraction of "Attribute Value", 
00053 // "Pointer" and "Tolerance", and stores an Attribute by aliasing
00054 // it with a pointer and associating it with some tolerance.
00055 // </etymology>
00056 
00057 // <synopsis>
00058 // An AttributeValuePoiTol combines the aliasing (via a pointer)
00059 // provided by the <linkto class="AttributeValuePoi">
00060 // AttributeValuePoi </linkto> class, and the tolerance provided by
00061 // the <linkto class="AttributeValueTol"> AttributeValueTol </linkto>
00062 // class.  See these classes for examples.
00063 // </synopsis>
00064 
00065 // <motivation> 
00066 // The motivation for this class is to be able to provide in-built
00067 // tolerance and aliasing for AttributeValues.
00068 // </motivation>
00069 
00070 // <todo asof="2000/01/17">
00071 // </todo>
00072 
00073 template <class T> class AttributeValuePoiTol : public AttributeValueTol<T> {
00074 
00075  public:
00076 
00077   // Constructor for a pointer to a scalar, and a tolerance.
00078   AttributeValuePoiTol(T* value, const T &tolerance, const Bool strict);
00079 
00080   // Constructor for a pointer to a <src>Vector</src>, and a scalar
00081   // tolerance.
00082   AttributeValuePoiTol(Vector<T>* value, const T &tolerance, 
00083                        const Bool strict);
00084   
00085   // Copy constructor.
00086   AttributeValuePoiTol(const AttributeValuePoiTol<T> &other);
00087 
00088   // Destructor.
00089   virtual ~AttributeValuePoiTol();
00090 
00091   // Assignment operator.
00092   const AttributeValuePoiTol<T>& operator=(const AttributeValuePoiTol<T> &other);
00093 
00094   // Return a new copy of the AttributeValuePoiTol (virtual constructor).
00095   virtual AttributeValueBase *clone() const;
00096 
00097   // Add <src>other</src> to <src>*this</src>.  Needs to over-ride
00098   // base class definition because the pointers need to be 
00099   // dereferenced prior to addition.
00100   virtual void operator+=(const AttributeValueBase &other);
00101 
00102 
00103   // Change the value of the AttributeValue.
00104   // <group>
00105   virtual void setValue(const T& value);
00106   virtual void setValue(const Vector<T>& value);
00107   // </group>
00108 
00109   // Get the DataType of the aliased variable.
00110   virtual DataType getPointerType() const;
00111 
00112   // Return class name
00113   virtual String className() const {return String("AttributeValuePoiTol");};
00114 
00115  private:
00116 
00117   // Update the variable that is aliased to the AttributeValuePoiTol.
00118   void updatePointerValue() const;
00119   
00120   // Pointer to the aliased variable. Only one is ever active depending
00121   // upon how the object was constructed.  The memory allocated to these pointers
00122   // does not belong to this object.
00123   // <group>
00124   Vector<T>* itsVectorPointerPtr;
00125   T* itsScalarPointerPtr;
00126   // </group>
00127 
00128   // The pointer DataType
00129   DataType itsPointerType;   
00130 
00131   // Cast from Base class
00132   const AttributeValuePoiTol<T>& myCast (const AttributeValueBase& other) const;
00133 
00134   // Default constructor  
00135   AttributeValuePoiTol();
00136   
00137 
00138   //# Make parent members known.
00139 public:
00140   using AttributeValueTol<T>::getType;
00141   using AttributeValueTol<T>::getValue;
00142   using AttributeValueTol<T>::getStrictness;
00143 };
00144 
00145 
00146 } //# NAMESPACE CASA - END
00147 #ifndef AIPS_NO_TEMPLATE_SRC
00148 #include <display/Display/AttValPoiTol.tcc>
00149 #endif
00150 #endif