casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ArrayColumnFunc.h
Go to the documentation of this file.
00001 //# ArrayColumnFunbc.h: Functors to operate on an ArrayColumn
00002 //# Copyright (C) 2009
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: ArrayColumnFunc.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_ARRAYCOLUMNFUNC_H
00029 #define TABLES_ARRAYCOLUMNFUNC_H
00030 
00031 //# Includes
00032 #include <tables/Tables/ArrayColumn.h>
00033 #include <casa/Arrays/Slicer.h>
00034 #include <casa/Arrays/Array.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038   // <summary> Abstract baseclass for slices functors </summary>
00039   // <synopsis>
00040   // There are several ArrayColumn functions to get or put irregular array
00041   // slices. ArrayColumn::handleSlices is used to perform all common
00042   // operations using a functor derived from this base class.
00043   // </synopsis>
00044   template<typename T>
00045   class BaseSlicesFunctor
00046   {
00047   public:
00048     virtual ~BaseSlicesFunctor()
00049     {}
00050     virtual void apply (const Slicer& slicer, Array<T>& arr) = 0;
00051   };
00052 
00053   // <summary> Functor to get irregular array slices from a cell</summary>
00054   template<typename T>
00055   class GetCellSlices : public BaseSlicesFunctor<T>
00056   {
00057   public:
00058     GetCellSlices (const ROArrayColumn<T>& col, uInt rownr)
00059       : itsCol(col), itsRow(rownr)
00060     {}
00061     virtual void apply (const Slicer& slicer, Array<T>& arr)
00062       { itsCol.getSlice (itsRow, slicer, arr); }
00063   private:
00064     const ROArrayColumn<T>& itsCol;
00065     uInt                   itsRow;
00066   };
00067 
00068   // <summary> Functor to get irregular array slices from a column</summary>
00069   template<typename T>
00070   class GetColumnSlices : public BaseSlicesFunctor<T>
00071   {
00072   public:
00073     GetColumnSlices (const ROArrayColumn<T>& col)
00074       : itsCol(col)
00075     {}
00076     virtual void apply (const Slicer& slicer, Array<T>& arr)
00077       { itsCol.getColumn (slicer, arr); }
00078   private:
00079     const ROArrayColumn<T>& itsCol;
00080   };
00081 
00082   // <summary> Functor to put irregular array slices into a cell </summary>
00083   template<typename T>
00084   class PutCellSlices : public BaseSlicesFunctor<T>
00085   {
00086   public:
00087     PutCellSlices (ArrayColumn<T>& col, uInt rownr)
00088       : itsCol(col), itsRow(rownr)
00089     {}
00090     virtual void apply (const Slicer& slicer, Array<T>& arr)
00091       { itsCol.putSlice (itsRow, slicer, arr); }
00092   private:
00093     ArrayColumn<T>& itsCol;
00094     uInt            itsRow;
00095   };
00096 
00097   // <summary> Functor to get irregular array slices from a column</summary>
00098   template<typename T>
00099   class PutColumnSlices : public BaseSlicesFunctor<T>
00100   {
00101   public:
00102     PutColumnSlices (ArrayColumn<T>& col)
00103       : itsCol(col)
00104     {}
00105     virtual void apply (const Slicer& slicer, Array<T>& arr)
00106       { itsCol.putColumn (slicer, arr); }
00107   private:
00108     ArrayColumn<T>& itsCol;
00109   };
00110 
00111 } //# NAMESPACE CASA - END
00112 
00113 #endif