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 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class RefTable;
41 class BaseColumnDesc;
42 class TableRecord;
43 class Slicer;
44 class IPosition;
45 template<class T> class Vector;
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 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  // It can change shape if the underlying column can.
141  virtual Bool canChangeShape() const;
142 
143  // It can handle a scalar column if the underlying column
144  // can handle cells in a scalar column.
145  virtual Bool canAccessScalarColumn (Bool& reask) const;
146 
147  // It can handle an array column if the underlying column
148  // can handle cells in an array column.
149  virtual Bool canAccessArrayColumn (Bool& reask) const;
150 
151  // It can handle a cell slice if the underlying column can do it.
152  virtual Bool canAccessSlice (Bool& reask) const;
153 
154  // It can handle a column slice if the underlying column
155  // can handle a collection of cells in a column and a column slice.
156  virtual Bool canAccessColumnSlice (Bool& reask) const;
157 
158  // It can handle cells in a scalar column if the underlying column
159  // can do it.
160  virtual Bool canAccessScalarColumnCells (Bool& reask) const;
161 
162  // It can handle cells in an array column if the underlying column
163  // can do it.
164  virtual Bool canAccessArrayColumnCells (Bool& reask) const;
165 
166  // Initialize the rows from startRownr till endRownr (inclusive)
167  // with the default value defined in the column description (if defined).
168  void initialize (uInt startRownr, uInt endRownr);
169 
170  // Get the value from a particular cell.
171  // This can be a scalar or an array.
172  virtual void get (uInt rownr, void* dataPtr) const;
173 
174  // Get a slice of an N-dimensional array in a particular cell.
175  virtual void getSlice (uInt rownr, const Slicer&, void* dataPtr) const;
176 
177  // Get the vector of all scalar values in a column.
178  virtual void getScalarColumn (void* dataPtr) const;
179 
180  // Get the array of all array values in a 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 getArrayColumn (void* dataPtr) const;
184 
185  // Get subsections from all arrays in the column.
186  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
187  // The arrays in the column have to have the same shape in all cells.
188  virtual void getColumnSlice (const Slicer&, void* dataPtr) const;
189 
190  // Get the vector of some scalar values in a column.
191  virtual void getScalarColumnCells (const RefRows& rownrs,
192  void* dataPtr) const;
193 
194  // Get the array of some array values in a column.
195  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
196  // The arrays in the column have to have the same shape in all cells.
197  virtual void getArrayColumnCells (const RefRows& rownrs,
198  void* dataPtr) const;
199 
200  // Get subsections from some arrays in the column.
201  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
202  // The arrays in the column have to have the same shape in all cells.
203  virtual void getColumnSliceCells (const RefRows& rownrs,
204  const Slicer&, void* dataPtr) const;
205 
206  // Put the value in a particular cell.
207  // This can be a scalar or an array.
208  virtual void put (uInt rownr, const void* dataPtr);
209 
210  // Put a slice of an N-dimensional array in a particular cell.
211  virtual void putSlice (uInt rownr, const Slicer&, const void* dataPtr);
212 
213  // Put the vector of all scalar values in the column.
214  virtual void putScalarColumn (const void* dataPtr);
215 
216  // Put the array of all array values in the column.
217  // If the column contains n-dim arrays, the source array is (n+1)-dim.
218  // The arrays in the column have to have the same shape in all cells.
219  virtual void putArrayColumn (const void* dataPtr);
220 
221  // Put into subsections of all table arrays in the column.
222  // If the column contains n-dim arrays, the source array is (n+1)-dim.
223  // The arrays in the column have to have the same shape in all cells.
224  virtual void putColumnSlice (const Slicer&, const void* dataPtr);
225 
226  // Get the vector of some scalar values in a column.
227  virtual void putScalarColumnCells (const RefRows& rownrs,
228  const void* dataPtr);
229 
230  // Get the array of some array values in a column.
231  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
232  // The arrays in the column have to have the same shape in all cells.
233  virtual void putArrayColumnCells (const RefRows& rownrs,
234  const void* dataPtr);
235 
236  // Put subsections of some arrays in the column.
237  // If the column contains n-dim arrays, the source array is (n+1)-dim.
238  // The arrays in the column have to have the same shape in all cells.
239  virtual void putColumnSliceCells (const RefRows& rownrs,
240  const Slicer&, const void* dataPtr);
241 
242  // Get the underlying column cache.
244 
245  // Set the maximum cache size (in bytes) to be used by a storage manager.
246  virtual void setMaximumCacheSize (uInt nbytes);
247 
248  // Add this column and its data to the Sort object.
249  // It may allocate some storage on the heap, which will be saved
250  // in the argument dataSave.
251  // The function freeSortKey must be called to free this storage.
252  virtual void makeSortKey (Sort&, CountedPtr<BaseCompare>& cmpObj,
253  Int order, const void*& dataSave);
254 
255  // Free storage on the heap allocated by makeSortkey().
256  // The pointer will be set to zero.
257  virtual void freeSortKey (const void*& dataSave);
258 
259  // Allocate value buffers for the table iterator.
260  // Also get a comparison functiuon if undefined.
261  // The function freeIterBuf must be called to free the buffers.
262  virtual void allocIterBuf (void*& lastVal, void*& curVal,
263  CountedPtr<BaseCompare>& cmpObj);
264 
265  // Free the value buffers allocated by allocIterBuf.
266  virtual void freeIterBuf (void*& lastVal, void*& curVal);
267 
268 protected:
272 };
273 
274 
275 
276 
277 } //# NAMESPACE CASACORE - END
278 
279 #endif
casacore::Slicer
Definition: Slicer.h:290
casacore::RefColumn::canAccessArrayColumnCells
virtual Bool canAccessArrayColumnCells(Bool &reask) const
It can handle cells in an array column if the underlying column can do it.
casacore::RefColumn::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::RefColumn::getScalarColumnCells
virtual void getScalarColumnCells(const RefRows &rownrs, void *dataPtr) const
Get the vector of some scalar values in a column.
casacore::IPosition
Definition: IPosition.h:120
casacore::RefColumn::getArrayColumn
virtual void getArrayColumn(void *dataPtr) const
Get the array of all array values in a column.
casacore::RefColumn::getColumnSlice
virtual void getColumnSlice(const Slicer &, void *dataPtr) const
Get subsections from all arrays in the column.
casacore::RefColumn::keywordSet
virtual TableRecord & keywordSet()
casacore::RefColumn
Definition: RefColumn.h:91
casacore::TableRecord
Definition: TableRecord.h:183
casacore::RefColumn::~RefColumn
~RefColumn()
casacore::CountedPtr
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
casacore::RefColumn::refTabPtr_p
RefTable * refTabPtr_p
Definition: RefColumn.h:269
casacore::RefColumn::allocIterBuf
virtual void allocIterBuf(void *&lastVal, void *&curVal, CountedPtr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
casacore::RefColumn::getSlice
virtual void getSlice(uInt rownr, const Slicer &, void *dataPtr) const
Get a slice of an N-dimensional array in a particular cell.
casacore::RefColumn::getScalarColumn
virtual void getScalarColumn(void *dataPtr) const
Get the vector of all scalar values in a column.
casacore::RefColumn::isStored
virtual Bool isStored() const
Test if the column is stored (otherwise it is virtual).
casacore::RefColumn::putScalarColumn
virtual void putScalarColumn(const void *dataPtr)
Put the vector of all scalar values in the column.
casacore::RefColumn::nrow
virtual uInt nrow() const
Get nr of rows in the column.
casacore::RefColumn::columnCache
virtual ColumnCache & columnCache()
Get the underlying column cache.
casacore::RefColumn::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::RefColumn::setShape
virtual void setShape(uInt rownr, const IPosition &shape)
Set the shape of the array in the given row.
casacore::RefColumn::putArrayColumnCells
virtual void putArrayColumnCells(const RefRows &rownrs, const void *dataPtr)
Get the array of some array values in a column.
casacore::RefColumn::isWritable
virtual Bool isWritable() const
Test if the column is writable in the parent table.
casacore::RefColumn::setMaximumCacheSize
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
casacore::RefColumn::isDefined
virtual Bool isDefined(uInt rownr) const
Test if a value in a particular cell has been defined.
casacore::BaseColumn::tileShape
virtual IPosition tileShape(uInt rownr) const
Get the tile shape of an array in a particular cell.
casacore::RefColumn::shapeColumn
virtual IPosition shapeColumn() const
Get the global shape of an array (i.e.
casacore::RefColumn::getArrayColumnCells
virtual void getArrayColumnCells(const RefRows &rownrs, void *dataPtr) const
Get the array of some array values in a column.
casacore::RefColumn::putSlice
virtual void putSlice(uInt rownr, const Slicer &, const void *dataPtr)
Put a slice of an N-dimensional array in a particular cell.
casacore::RefColumn::freeSortKey
virtual void freeSortKey(const void *&dataSave)
Free storage on the heap allocated by makeSortkey().
casacore::RefColumn::initialize
void initialize(uInt startRownr, uInt endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
casacore::RefRows
Definition: RefRows.h:86
casacore::BaseColumn
Definition: BaseColumn.h:99
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::RefColumn::RefColumn
RefColumn(const BaseColumnDesc *, RefTable *, BaseColumn *referencedColumn)
Construct the RefColumn.
casacore::RefColumn::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::RefColumn::putArrayColumn
virtual void putArrayColumn(const void *dataPtr)
Put the array of all array values in the column.
casacore::RefColumn::canAccessScalarColumnCells
virtual Bool canAccessScalarColumnCells(Bool &reask) const
It can handle cells in a scalar column if the underlying column can do it.
casacore::BaseColumnDesc
Definition: BaseColDesc.h:108
casacore::Int
int Int
Definition: aipstype.h:50
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::RefColumn::ndimColumn
virtual uInt ndimColumn() const
Get the global #dimensions of an array (i.e.
casacore::RefColumn::makeSortKey
virtual void makeSortKey(Sort &, CountedPtr< BaseCompare > &cmpObj, Int order, const void *&dataSave)
Add this column and its data to the Sort object.
casacore::Sort
Sort on one or more keys, ascending and/or descending.
Definition: Sort.h:249
casacore::RefColumn::get
virtual void get(uInt rownr, void *dataPtr) const
Get the value from a particular cell.
casacore::ColumnCache
Definition: ColumnCache.h:84
casacore::RefColumn::colPtr_p
BaseColumn * colPtr_p
Definition: RefColumn.h:270
casacore::RefColumn::rwKeywordSet
virtual TableRecord & rwKeywordSet()
Get access to the column keyword set.
casacore::RefColumn::ndim
virtual uInt ndim(uInt rownr) const
Get the #dimensions of an array in a particular cell.
casacore::RefColumn::getColumnSliceCells
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &, void *dataPtr) const
Get subsections from some arrays in the column.
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::RefColumn::putColumnSliceCells
virtual void putColumnSliceCells(const RefRows &rownrs, const Slicer &, const void *dataPtr)
Put subsections of some arrays in the column.
casacore::RefColumn::colCache_p
ColumnCache colCache_p
Definition: RefColumn.h:271
casacore::RefColumn::putColumnSlice
virtual void putColumnSlice(const Slicer &, const void *dataPtr)
Put into subsections of all table arrays in the column.
casacore::RefColumn::canChangeShape
virtual Bool canChangeShape() const
It can change shape if the underlying column can.
casacore::RefColumn::put
virtual void put(uInt rownr, const void *dataPtr)
Put the value in a particular cell.
casacore::RefColumn::shape
virtual IPosition shape(uInt rownr) const
Get the shape of an array in a particular cell.
casacore::RefColumn::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::RefTable
Definition: RefTable.h:105
casacore::RefColumn::freeIterBuf
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
casacore::RefColumn::canAccessSlice
virtual Bool canAccessSlice(Bool &reask) const
It can handle a cell slice if the underlying column can do it.
casacore::RefColumn::putScalarColumnCells
virtual void putScalarColumnCells(const RefRows &rownrs, const void *dataPtr)
Get the vector of some scalar values in a column.