casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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 
100  ~ConcatColumn();
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>
111  virtual TableRecord& rwKeywordSet();
112  virtual TableRecord& keywordSet();
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.
232  virtual ColumnCache& columnCache();
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
virtual TableRecord & rwKeywordSet()
Get access to the column keyword set.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
virtual void putArrayColumn(const void *dataPtr)
Put the array of all array values in the column.
virtual void putColumnSliceCells(const RefRows &rownrs, const Slicer &, const void *dataPtr)
Put subsections of some arrays in the column.
virtual Bool canAccessScalarColumnCells(Bool &reask) const
It can handle cells in a scalar column if the underlying column can do it.
std::vector< double > Vector
Definition: ds9context.h:24
Non-templated base class for templated Array class.
Definition: ArrayBase.h:74
virtual IPosition shape(uInt rownr) const
Get the shape of an array in a particular cell.
ColumnCache colCache_p
Definition: ConcatColumn.h:293
virtual uInt ndimColumn() const
Get the global #dimensions of an array (i.e.
virtual IPosition tileShape(uInt rownr) const
Get the tile shape of an array in a particular cell.
ConcatColumn(const BaseColumnDesc *, ConcatTable *)
Construct the ConcatColumn.
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
virtual void putColumnSlice(const Slicer &, const void *dataPtr)
Put into subsections of all table arrays in the column.
An abstract base class for table column descriptions.
Definition: BaseColDesc.h:107
void accessRows(const RefRows &rownrs, const Slicer *ns, void *dataPtr, AccessRowsFunc *) const
Access the data with multiple rows combined.
virtual Bool canChangeShape() const
It can change shape if the underlying column can.
virtual void putArrayColumnCells(const RefRows &rownrs, const void *dataPtr)
Get the array of some array values in a column.
static void putColumnPart(BaseColumn *col, const Slicer *, ArrayBase *arr)
virtual TableRecord & keywordSet()
virtual uInt nrow() const
Get nr of rows in the column.
virtual uInt ndim(uInt rownr) const
Get the #dimensions of an array in a particular cell.
static void getRowsPart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase *array)
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 getArrayColumnCells(const RefRows &rownrs, void *dataPtr) const
Get the array of some array values in a column.
virtual Bool canAccessScalarColumn(Bool &reask) const
It can handle a scalar column if the underlying column can handle cells in a scalar column...
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
void accessColumn(const Slicer *ns, void *dataPtr, AccessColumnFunc *) const
Access the data for an entire column.
virtual void put(uInt rownr, const void *dataPtr)
Put the value in a particular cell.
static void putRowsSlicePart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase *array)
Block< BaseColumn * > refColPtr_p
Definition: ConcatColumn.h:292
static void putRowsPart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase *array)
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
virtual void setShape(uInt rownr, const IPosition &shape)
Set the shape of the array in the given row.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A caching object for a table column.
Definition: ColumnCache.h:83
virtual Bool isWritable() const
Test if the column is writable in the parent table.
virtual Bool canAccessArrayColumnCells(Bool &reask) const
It can handle cells in an array column if the underlying column can do it.
static void putColumnSlicePart(BaseColumn *col, const Slicer *ns, ArrayBase *arr)
static void getColumnPart(BaseColumn *col, const Slicer *, ArrayBase *arr)
Define the access functions.
virtual void allocIterBuf(void *&lastVal, void *&curVal, CountedPtr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
virtual IPosition shapeColumn() const
Get the global shape of an array (i.e.
void initialize(uInt startRownr, uInt endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
void AccessColumnFunc(BaseColumn *col, const Slicer *, ArrayBase *array)
Define the function to handle access to an entire column.
Definition: ConcatColumn.h:248
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
simple 1-D array
virtual Bool canAccessSlice(Bool &reask) const
It can handle a cell slice if the underlying column can do it.
void setColumnCache(uInt tableNr, const ColumnCache &) const
Set the column cache to the cache of the given table.
virtual Bool canAccessArrayColumn(Bool &reask) const
It can handle an array column if the underlying column can handle cells in an array column...
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...
virtual void putSlice(uInt rownr, const Slicer &, const void *dataPtr)
Put a slice of an N-dimensional array in a particular cell.
TableRecord keywordSet_p
Definition: ConcatColumn.h:294
virtual Bool isStored() const
Test if the column is stored (otherwise it is virtual).
virtual Bool isDefined(uInt rownr) const
Test if a value in a particular cell has been defined.
ConcatTable * refTabPtr_p
Definition: ConcatColumn.h:291
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &, void *dataPtr) const
Get subsections from some arrays in the column.
Class to view a concatenation of tables as a single table.
Definition: ConcatTable.h:118
virtual ColumnCache & columnCache()
Get the underlying column cache.
virtual void getArrayColumn(void *dataPtr) const
Get the array of all array values in a column.
static void getRowsSlicePart(BaseColumn *col, const RefRows &rows, const Slicer *, ArrayBase *array)
virtual void getSlice(uInt rownr, const Slicer &, void *dataPtr) const
Get a slice of an N-dimensional array in a particular cell.
A column in a concatenated table.
Definition: ConcatColumn.h:91
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
unsigned int uInt
Definition: aipstype.h:51
virtual void getColumnSlice(const Slicer &, void *dataPtr) const
Get subsections from all arrays in the column.
Abstract base class for a table column.
Definition: BaseColumn.h:98
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42