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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1