casacore
ArrayColumnFunc.h
Go to the documentation of this file.
1 //# ArrayColumnFunbc.h: Functors to operate on an ArrayColumn
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef TABLES_ARRAYCOLUMNFUNC_H
29 #define TABLES_ARRAYCOLUMNFUNC_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/Tables/ArrayColumn.h>
34 #include <casacore/casa/Arrays/Slicer.h>
35 #include <casacore/casa/Arrays/Array.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39  // <summary> Abstract baseclass for slices functors </summary>
40  // <synopsis>
41  // There are several ArrayColumn functions to get or put irregular array
42  // slices. ArrayColumn::handleSlices is used to perform all common
43  // operations using a functor derived from this base class.
44  // </synopsis>
45  template<typename T>
46  class BaseSlicesFunctor
47  {
48  public:
50  {}
51  virtual void apply (const Slicer& slicer, Array<T>& arr) = 0;
52  };
53 
54  // <summary> Functor to get irregular array slices from a cell</summary>
55  template<typename T>
56  class GetCellSlices : public BaseSlicesFunctor<T>
57  {
58  public:
59  GetCellSlices (const ArrayColumn<T>& col, uInt rownr)
60  : itsCol(col), itsRow(rownr)
61  {}
62  virtual void apply (const Slicer& slicer, Array<T>& arr)
63  { itsCol.getSlice (itsRow, slicer, arr); }
64  private:
65  const ArrayColumn<T>& itsCol;
67  };
68 
69  // <summary> Functor to get irregular array slices from a column</summary>
70  template<typename T>
71  class GetColumnSlices : public BaseSlicesFunctor<T>
72  {
73  public:
74  GetColumnSlices (const ArrayColumn<T>& col)
75  : itsCol(col)
76  {}
77  virtual void apply (const Slicer& slicer, Array<T>& arr)
78  { itsCol.getColumn (slicer, arr); }
79  private:
80  const ArrayColumn<T>& itsCol;
81  };
82 
83  // <summary> Functor to put irregular array slices into a cell </summary>
84  template<typename T>
85  class PutCellSlices : public BaseSlicesFunctor<T>
86  {
87  public:
88  PutCellSlices (ArrayColumn<T>& col, uInt rownr)
89  : itsCol(col), itsRow(rownr)
90  {}
91  virtual void apply (const Slicer& slicer, Array<T>& arr)
92  { itsCol.putSlice (itsRow, slicer, arr); }
93  private:
96  };
97 
98  // <summary> Functor to get irregular array slices from a column</summary>
99  template<typename T>
100  class PutColumnSlices : public BaseSlicesFunctor<T>
101  {
102  public:
104  : itsCol(col)
105  {}
106  virtual void apply (const Slicer& slicer, Array<T>& arr)
107  { itsCol.putColumn (slicer, arr); }
108  private:
110  };
111 
112 } //# NAMESPACE CASACORE - END
113 
114 #endif
casacore::Slicer
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
casacore::GetCellSlices::itsRow
uInt itsRow
Definition: ArrayColumnFunc.h:67
casacore::GetCellSlices::itsCol
const ArrayColumn< T > & itsCol
Definition: ArrayColumnFunc.h:66
casacore::PutCellSlices::apply
virtual void apply(const Slicer &slicer, Array< T > &arr)
Definition: ArrayColumnFunc.h:92
casacore::BaseSlicesFunctor::~BaseSlicesFunctor
virtual ~BaseSlicesFunctor()
Definition: ArrayColumnFunc.h:49
casacore::PutCellSlices::itsCol
ArrayColumn< T > & itsCol
Definition: ArrayColumnFunc.h:95
casacore::ArrayColumn
Read and write access to an array table column with arbitrary data type.
Definition: CopyRecord.h:48
casacore::GetCellSlices::apply
virtual void apply(const Slicer &slicer, Array< T > &arr)
Definition: ArrayColumnFunc.h:63
casacore::BaseSlicesFunctor::apply
virtual void apply(const Slicer &slicer, Array< T > &arr)=0
casacore::PutCellSlices::PutCellSlices
PutCellSlices(ArrayColumn< T > &col, uInt rownr)
Definition: ArrayColumnFunc.h:89
casacore::GetCellSlices
Functor to get irregular array slices from a cell.
Definition: ArrayColumnFunc.h:57
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::GetColumnSlices::apply
virtual void apply(const Slicer &slicer, Array< T > &arr)
Definition: ArrayColumnFunc.h:78
casacore::PutColumnSlices::itsCol
ArrayColumn< T > & itsCol
Definition: ArrayColumnFunc.h:110
casacore::GetColumnSlices::itsCol
const ArrayColumn< T > & itsCol
Definition: ArrayColumnFunc.h:81
casacore::PutColumnSlices::apply
virtual void apply(const Slicer &slicer, Array< T > &arr)
Definition: ArrayColumnFunc.h:107
casacore::BaseSlicesFunctor
Abstract baseclass for slices functors.
Definition: ArrayColumn.h:43
casacore::GetColumnSlices::GetColumnSlices
GetColumnSlices(const ArrayColumn< T > &col)
Definition: ArrayColumnFunc.h:75
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::PutCellSlices::itsRow
uInt itsRow
Definition: ArrayColumnFunc.h:96
casacore::PutColumnSlices
Functor to get irregular array slices from a column.
Definition: ArrayColumnFunc.h:101
casacore::PutCellSlices
Functor to put irregular array slices into a cell
Definition: ArrayColumnFunc.h:86
casacore::PutColumnSlices::PutColumnSlices
PutColumnSlices(ArrayColumn< T > &col)
Definition: ArrayColumnFunc.h:104
casacore::GetColumnSlices
Functor to get irregular array slices from a column.
Definition: ArrayColumnFunc.h:72
casacore::Array
template <class T, class U> class vector;
Definition: Array.h:166
casacore::GetCellSlices::GetCellSlices
GetCellSlices(const ArrayColumn< T > &col, uInt rownr)
Definition: ArrayColumnFunc.h:60