casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TVecTemp.h
Go to the documentation of this file.
00001 //# TVecTemp.h: Templated table vectors held in memory as a temporary
00002 //# Copyright (C) 1994,1995,1999
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: TVecTemp.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_TVECTEMP_H
00029 #define TABLES_TVECTEMP_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <tables/Tables/TVec.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 template<class T> class Vector;
00039 
00040 
00041 // <summary>
00042 // Templated table vectors held in memory as a temporary
00043 // </summary>
00044 
00045 // <use visibility=local>
00046 
00047 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00048 // </reviewed>
00049 
00050 // <prerequisite>
00051 //# Classes you should understand before using this one.
00052 //   <li> TabVecRep
00053 // </prerequisite>
00054 
00055 // <etymology>
00056 // TabVecTemp is the class dealing with a table vector when used as
00057 // a temporary in math operations.
00058 // </etymology>
00059 
00060 // <synopsis> 
00061 // TabVecTemp objects enable the use of Vector objects as table vectors.
00062 // They are used for 2 purposes:
00063 // <ol>
00064 // <li> To convert a Vector to a TableVector. This is used to
00065 //        allow the use of Vectors in TableVector expressions.
00066 //        The TabVecTemp object uses the Vector copy constructor,
00067 //        which is very cheap due to its reference semantics.
00068 // <li> To hold the result of an operation (like addition) on
00069 //        two TableVector objects.
00070 // </ol>
00071 // </synopsis> 
00072 
00073 // <motivation>
00074 // TabVecTemp is derived from TabVecRep and as such a letter for
00075 // the envelope class TableVector.
00076 // </motivation>
00077 
00078 // <templating arg=T>
00079 //  <li> Default constructor
00080 //  <li> Copy constructor
00081 //  <li> Assignment operator
00082 // </templating>
00083 
00084 // <todo asof="$DATE:$">
00085 //# A List of bugs, limitations, extensions or planned refinements.
00086 //   <li> In the future temporary results may need to use a file,
00087 //          because table vectors can potentially be very, very long.
00088 // </todo>
00089 
00090 
00091 template<class T> class TabVecTemp : public TabVecRep<T>
00092 {
00093   //# Make members of parent class known.
00094 protected:
00095   using TabVecRep<T>::tag_p;
00096   using TabVecRep<T>::nrel_p;
00097 
00098 public:
00099     // Create table vector containing the given Vector (reference semantics).
00100     // It will set the origin to zero.
00101     TabVecTemp (const Vector<T>&);
00102 
00103     // Create table vector containing a Vector with given length.
00104     TabVecTemp (uInt leng);
00105 
00106     // Destruct the object.
00107     ~TabVecTemp();
00108 
00109     // Return a reference to a value.
00110     inline const T& operator() (uInt index) const;
00111 
00112     // Return a reference to a value.
00113     inline T& operator() (uInt index);
00114 
00115     // Get a value (virtual function).
00116     T value (uInt index) const;
00117     // Get a value (virtual function).
00118     void getVal (uInt index, T&) const;
00119 
00120     // Put a value (virtual function).
00121     void putVal (uInt index, const T&);
00122 
00123     // Set entire vector to a value.
00124     void set (const T&);
00125 
00126 protected:
00127     Vector<T>* vecPtr_p;
00128 };
00129 
00130 
00131 
00132 //# Return a reference to a value.
00133 template<class T>
00134 inline const T& TabVecTemp<T>::operator() (uInt index) const
00135     { return (*vecPtr_p)(index); }
00136 template<class T>
00137 inline T& TabVecTemp<T>::operator() (uInt index)
00138     { return (*vecPtr_p)(index); }
00139 
00140 
00141 
00142 } //# NAMESPACE CASA - END
00143 
00144 #ifndef CASACORE_NO_AUTO_TEMPLATES
00145 #include <tables/Tables/TVecTemp.tcc>
00146 #endif //# CASACORE_NO_AUTO_TEMPLATES
00147 #endif