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