casacore
RefColumn.h
Go to the documentation of this file.
1 //# RefColumn.h: A column in a reference table
2 //# Copyright (C) 1994,1995,1996,1997,1998
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_REFCOLUMN_H
29 #define TABLES_REFCOLUMN_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/casa/Arrays/ArrayFwd.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class RefTable;
42 class BaseColumnDesc;
43 class TableRecord;
44 class Slicer;
45 class IPosition;
46 
47 
48 // <summary>
49 // A column in a reference table
50 // </summary>
51 
52 // <use visibility=local>
53 
54 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
55 // </reviewed>
56 
57 // <prerequisite>
58 //# Classes you should understand before using this one.
59 // <li> RefTable
60 // <li> BaseColumn
61 // </prerequisite>
62 
63 // <etymology>
64 // RefTable represents a column in a RefTable. A RefTable is a table
65 // referencing another table, usually as the result of a select, etc..
66 // </etymology>
67 
68 // <synopsis>
69 // RefColumn handles the access of a column in a RefTable.
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 RefColumn 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 RefColumn : public BaseColumn
91 {
92 public:
93 
94  // Construct the RefColumn. It will point to the given column
95  // description, RefTable and referenced column.
96  // The RefTable will be used to convert the rownr to the rownr
97  // in the referenced column.
98  RefColumn (const BaseColumnDesc*, RefTable*, BaseColumn* referencedColumn);
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  // This is the keyword set in the referenced column.
110  // <group>
113  // </group>
114 
115  // Get nr of rows in the column.
116  virtual rownr_t nrow() const;
117 
118  // Test if a value in a particular cell has been defined.
119  virtual Bool isDefined (rownr_t rownr) const;
120 
121  // Set the shape of the array in the given row.
122  virtual void setShape (rownr_t rownr, const IPosition& shape);
123 
124  // Set the shape and tile shape of the array in the given row.
125  virtual void setShape (rownr_t 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 (rownr_t rownr) const;
136 
137  // Get the shape of an array in a particular cell.
138  virtual IPosition shape (rownr_t rownr) const;
139 
140  // It can change shape if the underlying column can.
141  virtual Bool canChangeShape() const;
142 
143  // Initialize the rows from startRownr till endRownr (inclusive)
144  // with the default value defined in the column description (if defined).
145  void initialize (rownr_t startRownr, rownr_t endRownr);
146 
147  // Get the value from a particular cell.
148  // This can be a scalar or an array.
149  virtual void get (rownr_t rownr, void* dataPtr) const;
150 
151  // Get an array from a particular cell.
152  virtual void getArray (rownr_t rownr, ArrayBase& dataPtr) const;
153 
154  // Get a slice of an N-dimensional array in a particular cell.
155  virtual void getSlice (rownr_t rownr, const Slicer&, ArrayBase& dataPtr) const;
156 
157  // Get the vector of all scalar values in a column.
158  virtual void getScalarColumn (ArrayBase& dataPtr) const;
159 
160  // Get the array of all array values in a 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 getArrayColumn (ArrayBase& dataPtr) const;
164 
165  // Get subsections from all arrays in the column.
166  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
167  // The arrays in the column have to have the same shape in all cells.
168  virtual void getColumnSlice (const Slicer&, ArrayBase& dataPtr) const;
169 
170  // Get the vector of some scalar values in a column.
171  virtual void getScalarColumnCells (const RefRows& rownrs,
172  ArrayBase& dataPtr) const;
173 
174  // Get the array of some array values in a 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 getArrayColumnCells (const RefRows& rownrs,
178  ArrayBase& dataPtr) const;
179 
180  // Get subsections from some arrays in the column.
181  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
182  // The arrays in the column have to have the same shape in all cells.
183  virtual void getColumnSliceCells (const RefRows& rownrs,
184  const Slicer&, ArrayBase& dataPtr) const;
185 
186  // Put the value in a particular cell.
187  // This can be a scalar or an array.
188  virtual void put (rownr_t rownr, const void* dataPtr);
189 
190  // Put the array value in a particular cell.
191  virtual void putArray (rownr_t rownr, const ArrayBase& dataPtr);
192 
193  // Put a slice of an N-dimensional array in a particular cell.
194  virtual void putSlice (rownr_t rownr, const Slicer&, const ArrayBase& dataPtr);
195 
196  // Put the vector of all scalar values in the column.
197  virtual void putScalarColumn (const ArrayBase& dataPtr);
198 
199  // Put the array of all array values in the column.
200  // If the column contains n-dim arrays, the source array is (n+1)-dim.
201  // The arrays in the column have to have the same shape in all cells.
202  virtual void putArrayColumn (const ArrayBase& dataPtr);
203 
204  // Put into subsections of all table arrays in the column.
205  // If the column contains n-dim arrays, the source array is (n+1)-dim.
206  // The arrays in the column have to have the same shape in all cells.
207  virtual void putColumnSlice (const Slicer&, const ArrayBase& dataPtr);
208 
209  // Get the vector of some scalar values in a column.
210  virtual void putScalarColumnCells (const RefRows& rownrs,
211  const ArrayBase& dataPtr);
212 
213  // Get the array of some array values in a column.
214  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
215  // The arrays in the column have to have the same shape in all cells.
216  virtual void putArrayColumnCells (const RefRows& rownrs,
217  const ArrayBase& dataPtr);
218 
219  // Put subsections of some arrays in the column.
220  // If the column contains n-dim arrays, the source array is (n+1)-dim.
221  // The arrays in the column have to have the same shape in all cells.
222  virtual void putColumnSliceCells (const RefRows& rownrs,
223  const Slicer&, const ArrayBase& dataPtr);
224 
225  // Get the underlying column cache.
227 
228  // Set the maximum cache size (in bytes) to be used by a storage manager.
229  virtual void setMaximumCacheSize (uInt nbytes);
230 
231  // Add this column and its data to the Sort object.
232  // It may allocate some storage on the heap, which will be saved
233  // in the argument dataSave.
234  // The function freeSortKey must be called to free this storage.
235  virtual void makeSortKey (Sort&, CountedPtr<BaseCompare>& cmpObj,
236  Int order, CountedPtr<ArrayBase>& dataSave);
237 
238  // Allocate value buffers for the table iterator.
239  // Also get a comparison functiuon if undefined.
240  // The function freeIterBuf must be called to free the buffers.
241  virtual void allocIterBuf (void*& lastVal, void*& curVal,
242  CountedPtr<BaseCompare>& cmpObj);
243 
244  // Free the value buffers allocated by allocIterBuf.
245  virtual void freeIterBuf (void*& lastVal, void*& curVal);
246 
247 protected:
251 };
252 
253 
254 
255 
256 } //# NAMESPACE CASACORE - END
257 
258 #endif
Non-templated base class for templated Array class.
Definition: ArrayBase.h:73
virtual IPosition tileShape(rownr_t rownr) const
Get the tile shape of an array in a particular cell.
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
RefTable * refTabPtr_p
Definition: RefColumn.h:248
virtual void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the array in the given row.
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 put(rownr_t rownr, const void *dataPtr)
Put the value in a particular cell.
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 putColumnSliceCells(const RefRows &rownrs, const Slicer &, const ArrayBase &dataPtr)
Put subsections of some arrays in the column.
virtual uInt ndimColumn() const
Get the global #dimensions of an array (i.e.
virtual void get(rownr_t rownr, void *dataPtr) const
Get the value from a particular cell.
BaseColumn * colPtr_p
Definition: RefColumn.h:249
virtual void getSlice(rownr_t rownr, const Slicer &, ArrayBase &dataPtr) const
Get a slice of an N-dimensional array in a particular cell.
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 TableRecord & keywordSet()
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
virtual uInt ndim(rownr_t rownr) const
Get the #dimensions of an array in a particular cell.
virtual void putArrayColumnCells(const RefRows &rownrs, const ArrayBase &dataPtr)
Get the array of some array values in a column.
virtual TableRecord & rwKeywordSet()
Get access to the column keyword set.
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
virtual void getArrayColumnCells(const RefRows &rownrs, ArrayBase &dataPtr) const
Get the array of some array values in a column.
virtual void getScalarColumnCells(const RefRows &rownrs, ArrayBase &dataPtr) const
Get the vector of some scalar values in a column.
virtual void putScalarColumnCells(const RefRows &rownrs, const ArrayBase &dataPtr)
Get the vector of some scalar values in a column.
virtual void getScalarColumn(ArrayBase &dataPtr) const
Get the vector of all scalar values in a column.
ColumnCache colCache_p
Definition: RefColumn.h:250
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &, ArrayBase &dataPtr) const
Get subsections from some arrays in the column.
virtual Bool isStored() const
Test if the column is stored (otherwise it is virtual).
virtual void getColumnSlice(const Slicer &, ArrayBase &dataPtr) const
Get subsections from all arrays in the column.
virtual IPosition shape(rownr_t rownr) const
Get the shape of an array in a particular cell.
virtual void putArray(rownr_t rownr, const ArrayBase &dataPtr)
Put the array value in a particular cell.
virtual Bool canChangeShape() const
It can change shape if the underlying column can.
virtual ColumnCache & columnCache()
Get the underlying column cache.
virtual void putColumnSlice(const Slicer &, const ArrayBase &dataPtr)
Put into subsections of all table arrays in the column.
virtual void makeSortKey(Sort &, CountedPtr< BaseCompare > &cmpObj, Int order, CountedPtr< ArrayBase > &dataSave)
Add this column and its data to the Sort object.
RefColumn(const BaseColumnDesc *, RefTable *, BaseColumn *referencedColumn)
Construct the RefColumn.
virtual void getArray(rownr_t rownr, ArrayBase &dataPtr) const
Get an array from a particular cell.
virtual Bool isWritable() const
Test if the column is writable in the parent table.
virtual Bool isDefined(rownr_t rownr) const
Test if a value in a particular cell has been defined.
virtual rownr_t nrow() const
Get nr of rows in the column.
virtual void getArrayColumn(ArrayBase &dataPtr) const
Get the array of all array values in a column.
virtual void putScalarColumn(const ArrayBase &dataPtr)
Put the vector of all scalar values in the column.
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.
virtual void putArrayColumn(const ArrayBase &dataPtr)
Put the array of all array values in the column.
Sort on one or more keys, ascending and/or descending.
Definition: Sort.h:248
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46