casacore
ConcatColumn.h
Go to the documentation of this file.
1 //# ConcatColumn.h: A column in a concatenated table
2 //# Copyright (C) 2008
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_CONCATCOLUMN_H
29 #define TABLES_CONCATCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/Tables/BaseColumn.h>
35 #include <casacore/tables/Tables/ColumnCache.h>
36 #include <casacore/tables/Tables/TableRecord.h>
37 #include <casacore/casa/Arrays/ArrayFwd.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41  //# Forward Declarations
42  class ConcatTable;
43  class BaseColumnDesc;
44  class TableRecord;
45  class Slicer;
46  class IPosition;
47 
48  // <summary>
49  // A column in a concatenated table
50  // </summary>
51 
52  // <use visibility=local>
53 
54  // <reviewed reviewer="UNKNOWN" date="" tests="">
55  // </reviewed>
56 
57  // <prerequisite>
58  //# Classes you should understand before using this one.
59  // <li> ConcatTable
60  // <li> BaseColumn
61  // </prerequisite>
62 
63  // <etymology>
64  // ConcatTable represents a column in a ConcatTable. A ConcatTable is a table
65  // referencing another table, usually as the result of a select, etc..
66  // </etymology>
67 
68  // <synopsis>
69  // ConcatColumn handles the access of a column in a ConcatTable.
70  // It calls the corresponding function in the referenced column
71  // while converting the given row number to the row number in the
72  // referenced table.
73  // </synopsis>
74 
75  // <motivation>
76  // This class is untyped, i.e. not templated.
77  // Every call is sent to the underlying referenced BaseColumn which
78  // is typed by the virtual function mechanism.
79  // A ConcatColumn can never be used directly. A user always has to
80  // construct a typed ArrayColumn or ScalarColumn object to access a column.
81  // This means everyting is fully type safe.
82  // </motivation>
83 
84  // <todo asof="$DATE:$">
85  //# A List of bugs, limitations, extensions or planned refinements.
86  // <li> Act upon removal of rows or the underlying column
87  // </todo>
88 
89 
90  class ConcatColumn : public BaseColumn
91  {
92  public:
93  // Construct the ConcatColumn. It will point to the given column
94  // description, ConcatTable and referenced column.
95  // The ConcatTable will be used to convert the rownr to the rownr
96  // in the referenced column.
98 
100 
101  // Test if the column is writable in the parent table.
102  virtual Bool isWritable() const;
103 
104  // Test if the column is stored (otherwise it is virtual).
105  virtual Bool isStored() const;
106 
107  // Get access to the column keyword set.
108  // The initial keyword set is a copy of the keyword set of the first table.
109  // <group>
112  // </group>
113 
114  // Get nr of rows in the column.
115  virtual rownr_t nrow() const;
116 
117  // Test if a value in a particular cell has been defined.
118  virtual Bool isDefined (rownr_t rownr) const;
119 
120  // Set the shape of the array in the given row.
121  virtual void setShape (rownr_t rownr, const IPosition& shape);
122 
123  // Set the shape and tile shape of the array in the given row.
124  virtual void setShape (rownr_t rownr, const IPosition& shape,
125  const IPosition& tileShape);
126 
127  // Get the global #dimensions of an array (i.e. for all rows).
128  virtual uInt ndimColumn() const;
129 
130  // Get the global shape of an array (i.e. for all rows).
131  virtual IPosition shapeColumn() const;
132 
133  // Get the #dimensions of an array in a particular cell.
134  virtual uInt ndim (rownr_t rownr) const;
135 
136  // Get the shape of an array in a particular cell.
137  virtual IPosition shape (rownr_t rownr) const;
138 
139  // Get the tile shape of an array in a particular cell.
140  virtual IPosition tileShape (rownr_t rownr) const;
141 
142  // It can change shape if the underlying column can.
143  virtual Bool canChangeShape() const;
144 
145  // Initialize the rows from startRownr till endRownr (inclusive)
146  // with the default value defined in the column description (if defined).
147  virtual void initialize (rownr_t startRownr, rownr_t endRownr);
148 
149  // Get a value from a particular cell.
150  virtual void get (rownr_t rownr, void* dataPtr) const;
151 
152  // Get a slice of an N-dimensional array in a particular cell.
153  virtual void getSlice (rownr_t rownr, const Slicer&, ArrayBase& dataPtr) const;
154 
155  // Get the array of all array values in a column.
156  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
157  // The arrays in the column have to have the same shape in all cells.
158  virtual void getArrayColumn (ArrayBase& dataPtr) const;
159 
160  // Get subsections from all arrays in the column.
161  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
162  // The arrays in the column have to have the same shape in all cells.
163  virtual void getColumnSlice (const Slicer&, ArrayBase& dataPtr) const;
164 
165  // Get an array from a particular cell.
166  virtual void getArray (rownr_t rownr, ArrayBase& dataPtr) const;
167 
168  // Get the array of some array values in a column.
169  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
170  // The arrays in the column have to have the same shape in all cells.
171  virtual void getArrayColumnCells (const RefRows& rownrs,
172  ArrayBase& dataPtr) const;
173 
174  // Get subsections from some arrays in the column.
175  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
176  // The arrays in the column have to have the same shape in all cells.
177  virtual void getColumnSliceCells (const RefRows& rownrs,
178  const Slicer&, ArrayBase& dataPtr) const;
179 
180  // Put the scalar value in a particular cell.
181  virtual void put (rownr_t rownr, const void* dataPtr);
182 
183  // Put the array value in a particular cell.
184  virtual void putArray (rownr_t rownr, const ArrayBase& dataPtr);
185 
186  // Put a slice of an N-dimensional array in a particular cell.
187  virtual void putSlice (rownr_t rownr, const Slicer&, const ArrayBase& dataPtr);
188 
189  // Put the array of all array values in the column.
190  // If the column contains n-dim arrays, the source array is (n+1)-dim.
191  // The arrays in the column have to have the same shape in all cells.
192  virtual void putArrayColumn (const ArrayBase& dataPtr);
193 
194  // Put into subsections of all table arrays in the column.
195  // If the column contains n-dim arrays, the source array is (n+1)-dim.
196  // The arrays in the column have to have the same shape in all cells.
197  virtual void putColumnSlice (const Slicer&, const ArrayBase& dataPtr);
198 
199  // Get the array of some array values in a column.
200  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
201  // The arrays in the column have to have the same shape in all cells.
202  virtual void putArrayColumnCells (const RefRows& rownrs,
203  const ArrayBase& dataPtr);
204 
205  // Put subsections of some arrays in the column.
206  // If the column contains n-dim arrays, the source array is (n+1)-dim.
207  // The arrays in the column have to have the same shape in all cells.
208  virtual void putColumnSliceCells (const RefRows& rownrs,
209  const Slicer&, const ArrayBase& dataPtr);
210 
211  // Get the underlying column cache.
213 
214  // Set the maximum cache size (in bytes) to be used by a storage manager.
215  virtual void setMaximumCacheSize (uInt nbytes);
216 
217  // Allocate value buffers for the table iterator.
218  // Also get a comparison function if undefined.
219  // The function freeIterBuf must be called to free the buffers.
220  virtual void allocIterBuf (void*& lastVal, void*& curVal,
221  CountedPtr<BaseCompare>& cmpObj);
222 
223  // Free the value buffers allocated by allocIterBuf.
224  virtual void freeIterBuf (void*& lastVal, void*& curVal);
225 
226  private:
227  // Define the function to handle access to an entire column.
228  typedef void AccessColumnFunc (BaseColumn* col,
229  const Slicer*, ArrayBase& array);
230 
231  // Define the function to handle access to a number of rows.
232  typedef void AccessRowsFunc (BaseColumn* col, const RefRows& rows,
233  const Slicer*, ArrayBase& array);
234 
235  // Access the data for an entire column.
236  void accessColumn (const Slicer* ns,
237  ArrayBase& dataPtr,
238  AccessColumnFunc*) const;
239 
240  // Access the data with multiple rows combined.
241  void accessRows (const RefRows& rownrs,
242  const Slicer* ns,
243  ArrayBase& dataPtr,
244  AccessRowsFunc*) const;
245 
246  // Define the access functions.
247  static void getColumnPart (BaseColumn* col,
248  const Slicer*, ArrayBase& arr);
249  static void putColumnPart (BaseColumn* col,
250  const Slicer*, ArrayBase& arr);
251  static void getColumnSlicePart (BaseColumn* col,
252  const Slicer* ns, ArrayBase& arr);
253  static void putColumnSlicePart (BaseColumn* col,
254  const Slicer* ns, ArrayBase& arr);
255  static void getRowsPart (BaseColumn* col, const RefRows& rows,
256  const Slicer*, ArrayBase& array);
257  static void putRowsPart (BaseColumn* col, const RefRows& rows,
258  const Slicer*, ArrayBase& array);
259  static void getRowsSlicePart (BaseColumn* col, const RefRows& rows,
260  const Slicer*, ArrayBase& array);
261  static void putRowsSlicePart (BaseColumn* col, const RefRows& rows,
262  const Slicer*, ArrayBase& array);
263  // </group>
264 
265  protected:
266  // Set the column cache to the cache of the given table.
267  // The row numbers will be adjusted as needed.
268  void setColumnCache (uInt tableNr, const ColumnCache&) const;
269 
270  //# Data members
275  };
276 
277 } //# NAMESPACE CASACORE - END
278 
279 #endif
Non-templated base class for templated Array class.
Definition: ArrayBase.h:73
simple 1-D array
Definition: Block.h:200
virtual void putArrayColumnCells(const RefRows &rownrs, const ArrayBase &dataPtr)
Get the array of some array values in a column.
virtual void putColumnSliceCells(const RefRows &rownrs, const Slicer &, const ArrayBase &dataPtr)
Put subsections of some arrays in the column.
virtual ColumnCache & columnCache()
Get the underlying column cache.
static void putColumnSlicePart(BaseColumn *col, const Slicer *ns, ArrayBase &arr)
static void putColumnPart(BaseColumn *col, const Slicer *, ArrayBase &arr)
virtual IPosition tileShape(rownr_t rownr) const
Get the tile shape of an array in a particular cell.
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
ConcatColumn(const BaseColumnDesc *, ConcatTable *)
Construct the ConcatColumn.
virtual void get(rownr_t rownr, void *dataPtr) const
Get a value from a particular cell.
virtual TableRecord & keywordSet()
void accessRows(const RefRows &rownrs, const Slicer *ns, ArrayBase &dataPtr, AccessRowsFunc *) const
Access the data with multiple rows combined.
virtual Bool isDefined(rownr_t rownr) const
Test if a value in a particular cell has been defined.
static void getRowsSlicePart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
static void getColumnPart(BaseColumn *col, const Slicer *, ArrayBase &arr)
Define the access functions.
virtual TableRecord & rwKeywordSet()
Get access to the column keyword set.
virtual void putArray(rownr_t rownr, const ArrayBase &dataPtr)
Put the array value in a particular cell.
virtual void getArrayColumn(ArrayBase &dataPtr) const
Get the array of all array values in a column.
virtual void putArrayColumn(const ArrayBase &dataPtr)
Put the array of all array values in the column.
virtual uInt ndim(rownr_t rownr) const
Get the #dimensions of an array in a particular cell.
virtual IPosition shape(rownr_t rownr) const
Get the shape of an array in a particular cell.
virtual void initialize(rownr_t startRownr, rownr_t endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
virtual void getColumnSlice(const Slicer &, ArrayBase &dataPtr) const
Get subsections from all arrays in the column.
void AccessColumnFunc(BaseColumn *col, const Slicer *, ArrayBase &array)
Define the function to handle access to an entire column.
Definition: ConcatColumn.h:228
virtual void getArray(rownr_t rownr, ArrayBase &dataPtr) const
Get an array from a particular cell.
virtual void putColumnSlice(const Slicer &, const ArrayBase &dataPtr)
Put into subsections of all table arrays in the column.
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
static void getColumnSlicePart(BaseColumn *col, const Slicer *ns, ArrayBase &arr)
virtual void putSlice(rownr_t rownr, const Slicer &, const ArrayBase &dataPtr)
Put a slice of an N-dimensional array in a particular cell.
virtual void put(rownr_t rownr, const void *dataPtr)
Put the scalar value in a particular cell.
virtual uInt ndimColumn() const
Get the global #dimensions of an array (i.e.
virtual void setShape(rownr_t rownr, const IPosition &shape, const IPosition &tileShape)
Set the shape and tile shape of the array in the given row.
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &, ArrayBase &dataPtr) const
Get subsections from some arrays in the column.
static void getRowsPart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
virtual Bool isStored() const
Test if the column is stored (otherwise it is virtual).
virtual Bool isWritable() const
Test if the column is writable in the parent table.
static void putRowsPart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
void accessColumn(const Slicer *ns, ArrayBase &dataPtr, AccessColumnFunc *) const
Access the data for an entire column.
virtual IPosition shapeColumn() const
Get the global shape of an array (i.e.
virtual void getSlice(rownr_t rownr, const Slicer &, ArrayBase &dataPtr) const
Get a slice of an N-dimensional array in a particular cell.
virtual void getArrayColumnCells(const RefRows &rownrs, ArrayBase &dataPtr) const
Get the array of some array values in a column.
static void putRowsSlicePart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
virtual void allocIterBuf(void *&lastVal, void *&curVal, CountedPtr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
virtual Bool canChangeShape() const
It can change shape if the underlying column can.
virtual void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the array in the given row.
virtual rownr_t nrow() const
Get nr of rows in the column.
void AccessRowsFunc(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase &array)
Define the function to handle access to a number of rows.
Definition: ConcatColumn.h:232
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
Block< BaseColumn * > refColPtr_p
Definition: ConcatColumn.h:272
void setColumnCache(uInt tableNr, const ColumnCache &) const
Set the column cache to the cache of the given table.
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1929
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
TableRecord keywordSet_p
Definition: ConcatColumn.h:274
ConcatTable * refTabPtr_p
Definition: ConcatColumn.h:271
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
ColumnCache colCache_p
Definition: ConcatColumn.h:273